:root {
  --hero-blue: #266ede;
  --hero-blue-dark: #1b54b0;
  --shoe-red: #e8483e;
  --shoe-red-dark: #c43229;
  --ink: #1a1c24;
  --cream-light: #fff4ba;
  --cream-deep: #ffe096;
  --card-bg: #fffdf2;
  --accent-yellow: #ffd43b;
  --ok-green: #1f9d55;
  --lifejacket-orange: #ff7a1a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  background: linear-gradient(180deg, var(--cream-light) 0%, var(--cream-deep) 100%);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* 上の帯 */
.top-bar {
  background: var(--cream-light);
  border-bottom: 3px solid var(--ink);
  position: sticky;
  top: 0;
  z-index: 30;
}

.top-bar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.brand-link::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background: var(--hero-blue);
  border: 2.5px solid var(--ink);
  border-radius: 4px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 22px;
  padding: 11px 9px;
  border-radius: 6px;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--cream-deep);
}

.sub-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background: var(--shoe-red);
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 6px 11px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}

.sub-badge:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--ink);
}

@media (max-width: 375px) {
  .top-bar-inner { padding: 8px; gap: 6px; }
  .brand-link { font-size: 0.95rem; gap: 4px; }
  .top-nav { gap: 6px; }
  .nav-link { font-size: 0.8rem; line-height: 22px; padding: 11px 6px; }
  .sub-badge { font-size: 0.75rem; padding: 5px 8px; }
}

/* メイン・真ん中の縦の枠 */
.page-main {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 8px 0 16px;
  width: 100%;
}

.game-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: min(calc(100dvh - 64px), 740px);
  min-height: 560px;
  margin: 0 auto;
  border-top: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: #04142c;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

@media (min-width: 440px) {
  .page-main {
    padding: 14px 12px 20px;
  }

  .game-frame {
    border: 3.5px solid var(--ink);
    border-radius: 18px;
    box-shadow: 0 6px 0 var(--ink);
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 沈降中の長押し案内 */
.sink-controls {
  position: absolute;
  left: 12px;
  right: 78px;
  bottom: 14px;
  z-index: 10;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.sink-controls[hidden] {
  display: none !important;
}

.fast-sink-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 244, 186, 0.94);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}

.fast-sink-btn.is-active {
  background: var(--accent-yellow);
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.fast-sink-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--hero-blue);
  border: 2px solid var(--ink);
}

.fast-sink-btn.is-active .fast-sink-dot {
  background: var(--shoe-red);
}

/* 問題・説明・結果のオーバーレイカード */
.ui-panel {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 20;
  background: var(--card-bg);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 4px 0 var(--ink);
  max-height: 60%;
  overflow-y: auto;
}

.ui-panel.is-result {
  max-height: 76%;
}

.ui-panel[hidden] {
  display: none !important;
}

.panel-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.panel-badge {
  display: inline-block;
  background: var(--hero-blue);
  color: #ffffff;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 2px 9px;
  border: 2px solid var(--ink);
  border-radius: 999px;
}

.panel-badge.is-correct {
  background: var(--ok-green);
}

.panel-badge.is-wrong {
  background: var(--shoe-red);
}

.panel-badge.is-spot {
  background: var(--lifejacket-orange);
}

.panel-depth-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: #3b4052;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.38;
  color: var(--ink);
}

.panel-text {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
  color: #252836;
}

.panel-note {
  margin: 0 0 10px;
  padding: 7px 9px;
  background: var(--cream-light);
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.42;
  color: var(--ink);
}

/* 選択肢・操作ボタン */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--ink);
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: transform 0.08s ease, background-color 0.12s ease;
}

.game-btn:hover,
.game-btn:focus-visible {
  background: var(--cream-light);
  outline: none;
}

.game-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.game-btn.is-primary {
  justify-content: center;
  text-align: center;
  background: var(--hero-blue);
  color: #ffffff;
  font-size: 0.96rem;
}

.game-btn.is-primary:hover,
.game-btn.is-primary:focus-visible {
  background: var(--hero-blue-dark);
}

.game-btn.is-warm {
  justify-content: center;
  text-align: center;
  background: var(--accent-yellow);
  color: var(--ink);
  font-size: 0.96rem;
}

.game-btn.is-red {
  justify-content: center;
  text-align: center;
  background: var(--shoe-red);
  color: #ffffff;
}

.game-btn.is-red:hover,
.game-btn.is-red:focus-visible {
  background: var(--shoe-red-dark);
}

.choice-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  margin-right: 8px;
  background: var(--cream-deep);
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 900;
  flex-shrink: 0;
}

/* 結果画面 */
.result-summary {
  background: var(--cream-light);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  padding: 9px 10px;
  margin-bottom: 10px;
  text-align: center;
}

.result-rank {
  display: inline-block;
  background: var(--accent-yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.85rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.result-score {
  margin: 2px 0;
  font-size: 1.2rem;
  font-weight: 900;
}

.result-depth {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 800;
  color: #2f3545;
}

.result-q-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-top: 7px;
}

.result-q-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  background: #ffffff;
}

.result-q-pill.is-ok {
  background: #d8f5e3;
  color: #146c38;
}

.result-q-pill.is-ng {
  background: #ffe3e0;
  color: #b5261e;
}

.result-video-lead {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.result-review {
  margin: 0 0 10px;
  padding: 9px 10px;
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  text-align: left;
}

.result-review.is-all-clear {
  background: #f2fbf5;
}

.result-review-title {
  margin: 0 0 6px;
  font-size: 0.84rem;
  font-weight: 900;
  color: var(--ink);
}

.result-review-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.result-review-item {
  padding-top: 6px;
  border-top: 1.5px dashed rgba(26, 28, 36, 0.22);
}

.result-review-item:first-child {
  padding-top: 0;
  border-top: none;
}

.result-review-head {
  margin: 0 0 2px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 900;
}

.result-review-q {
  color: var(--ink);
}

.result-review-ans {
  color: var(--shoe-red-dark);
  background: #fff0ed;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
}

.result-review-note {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.42;
  color: #2c3140;
}

.game-btn.is-video-cta {
  background: var(--shoe-red);
  color: #ffffff;
  font-size: 0.9rem;
  padding: 10px;
}

.game-btn.is-video-cta:hover,
.game-btn.is-video-cta:focus-visible {
  background: var(--shoe-red-dark);
}

.game-btn.is-site-video {
  background: var(--cream-light);
  color: var(--ink);
  font-size: 0.8rem;
  padding: 7px 8px;
}

.game-btn.is-lab-btn {
  justify-content: center;
  text-align: center;
  background: #e8f3ff;
  color: var(--ink);
  font-size: 0.84rem;
  margin-top: 6px;
}

.panel-note-inline {
  margin: 7px 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  color: #4a5064;
  line-height: 1.35;
}

/* 自由実験モード（スライダー＆深さチップ） */
.lab-slider-wrap {
  margin: 4px 0 8px;
}

.lab-depth-slider {
  width: 100%;
  margin: 2px 0 6px;
  accent-color: var(--hero-blue);
  cursor: pointer;
}

.lab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lab-chip {
  appearance: none;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 900;
  padding: 3px 7px;
  background: #ffffff;
  color: var(--ink);
  border: 1.8px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}

.lab-chip:hover,
.lab-chip:focus-visible {
  background: var(--accent-yellow);
}

.lab-live-note {
  margin: 0 0 8px;
  padding: 6px 8px;
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.4;
}

.lab-action-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 6px;
}

.lab-action-row .game-btn {
  justify-content: center;
  text-align: center;
  padding: 8px 6px;
  font-size: 0.82rem;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.result-actions .game-btn {
  justify-content: center;
  text-align: center;
  font-size: 0.84rem;
  padding: 9px 8px;
}

.result-actions .span-full {
  grid-column: 1 / -1;
}

/* 下の帯 */
.bottom-bar {
  border-top: 3px solid var(--ink);
  background: var(--cream-deep);
  padding: 12px;
}

.bottom-bar-inner {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 6px;
}

.footer-links a {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: underline;
}

.copyright {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
}

@media (max-width: 375px) {
  .ui-panel {
    padding: 10px;
  }

  .panel-title {
    font-size: 0.95rem;
  }

  .panel-text {
    font-size: 0.83rem;
  }

  .game-btn {
    padding: 8px 10px;
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
