:root {
  --bg: #111827;
  --panel: rgba(255, 255, 255, 0.96);
  --border: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --muted: #475569;
  --accent: #b45309;
  --accent-bright: #d97706;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', sans-serif;
  background: radial-gradient(circle at 50% 35%, #1e293b 0%, #0f172a 100%);
  color: var(--text);
}

.hidden { display: none !important; }

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.board-pane {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 52px 16px 190px;
}

.hud {
  position: absolute;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-top-left { left: 14px; }
.hud-top-right { right: 14px; }

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.hud-pill:hover { background: rgba(30, 41, 59, 0.95); }
.hud-pill.is-active {
  background: #d97706;
  border-color: #fbbf24;
  color: #ffffff;
}
.hud-pill.hud-accent {
  background: rgba(37, 99, 235, 0.88);
  border-color: rgba(147, 197, 253, 0.5);
}

.hud-pill-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.hud-sep { opacity: 0.45; }
.hud-step-count { color: #fbbf24; font-variant-numeric: tabular-nums; }
.icon-chevron { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.4; }

.popover {
  position: absolute;
  top: 52px;
  z-index: 30;
  width: min(320px, calc(100vw - 28px));
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  padding: 10px;
}

.popover-left { left: 14px; }
.popover-header {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  padding: 4px 8px 8px;
}

.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-list-btn {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-list-btn:hover { background: #f1f5f9; }
.step-list-btn.active { background: #fef3c7; color: #92400e; font-weight: 800; }

.board-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-height: 100%;
  max-width: 100%;
}

.board-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.status-pill {
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
}

.status-muted {
  background: rgba(15, 23, 42, 0.72);
  color: #cbd5e1;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.quiz-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  background: #2563eb;
}

.quiz-badge.is-correct { background: #16a34a; }
.quiz-badge.is-wrong { background: #dc2626; }

.go-board-container {
  width: min(56dvh, 92vw, 520px);
  height: min(56dvh, 92vw, 520px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.go-board-svg {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
}

.go-board-svg.is-interactive .go-hit-cell {
  cursor: pointer;
}

/* ===== 下部：ゆっくり字幕＆プレイヤー ===== */
.caption-pane {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  padding: 0 16px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.35) 68%, transparent 100%);
}

.dialogue-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  width: min(1140px, 100%);
  pointer-events: none;
}

.yukkuri-slot {
  position: relative;
  flex: 0 0 clamp(104px, 12vw, 168px);
  width: clamp(104px, 12vw, 168px);
  height: clamp(86px, 10vw, 140px);
  pointer-events: none;
  opacity: 0.72;
  transform: scale(0.92);
  transform-origin: bottom center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4));
}

.yukkuri-slot.is-speaking {
  opacity: 1;
  transform: scale(1.02);
  animation: yukkuri-bob 0.65s ease-in-out infinite alternate;
}

@keyframes yukkuri-bob {
  0% { transform: scale(1.02) translateY(0px); }
  100% { transform: scale(1.02) translateY(-3px); }
}

.yukkuri-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

.yukkuri-left .yukkuri-stage {
  transform: scaleX(-1);
}

.yukkuri-part {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.caption-card {
  pointer-events: auto;
  flex: 1 1 auto;
  max-width: 780px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-bright);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.caption-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.speaker-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  color: #ffffff;
}

.speaker-reimu { background: #be185d; }
.speaker-marisa { background: #92400e; }

.section-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
}

.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 10.5px;
  font-weight: 700;
}

.step-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.subtitle-text {
  margin: 6px 0 2px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.65;
  color: #1e293b;
}

.fact-list {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

.next-action-wrap {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-next-step, .btn-next-lesson {
  padding: 6px 14px;
  border-radius: 999px;
  border: none;
  background: #16a34a;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.btn-next-lesson {
  background: #d97706;
}

.player-bar {
  pointer-events: auto;
  width: min(820px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fafc;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #e2e8f0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ctrl-btn:hover { background: rgba(255, 255, 255, 0.12); }
.ctrl-btn svg { width: 17px; height: 17px; fill: currentColor; }

.ctrl-play {
  background: #d97706;
  color: #ffffff;
}

.ctrl-play:hover { background: #b45309; }

.timeline {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.tl-dot {
  flex: 1 1 0;
  max-width: 38px;
  height: 6px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  padding: 0;
}

.tl-dot.is-quiz {
  background: rgba(96, 165, 250, 0.45);
}

.tl-dot.active {
  background: #fbbf24;
  height: 8px;
}

.tl-dot.is-solved {
  background: #34d399;
}

.tts-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ctrl-tts.is-on { color: #34d399; }

.ctrl-rate-btn {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  color: #f8fafc;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.player-hint {
  font-size: 11.5px;
  color: #94a3b8;
  min-width: 42px;
  text-align: right;
}

@media (max-width: 720px) {
  .yukkuri-slot { display: none; }
  .board-pane { padding-bottom: 170px; }
  .go-board-container {
    width: min(50dvh, 94vw);
    height: min(50dvh, 94vw);
  }
}
