/* 棍维Project — 东方Project 风格 UI */
:root {
  --bg: #0b0a12;
  --panel: #12101c;
  --panel2: #1a1628;
  --border: #5c4a2e;
  --border-lite: #8a7348;
  --gold: #d4b56a;
  --gold2: #f0d78c;
  --text: #f2e6c8;
  --muted: #9a8b6e;
  --accent: #e8c878;
  --accent2: #c45c8a;
  --hi: #ff6b8a;
  --sc: #ffe08a;
  --warn: #fbbf24;
  --danger: #f87171;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  --serif: "Songti SC", "SimSun", "Noto Serif SC", "Times New Roman", serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app { width: 100%; height: 100%; position: relative; }

/* ===== 加载界面 ===== */
#load-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: #0b0a12;
  transition: opacity 0.6s ease;
}
#load-screen.done {
  opacity: 0; pointer-events: none;
}
.load-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 0%, #2a1840 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, #1a1028 0%, #0b0a12 60%);
}
.load-frame {
  position: relative; z-index: 1;
  text-align: center;
  padding: 48px 64px;
  border: 2px solid var(--border);
  background: linear-gradient(180deg, rgba(18,16,28,.92), rgba(11,10,18,.94));
  box-shadow: 0 0 60px rgba(212,181,106,.12), inset 0 0 40px rgba(0,0,0,.3);
  min-width: 340px;
}
.load-title {
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 6px;
  text-shadow: 0 0 24px rgba(212,181,106,.35);
}
.load-title span { font-size: 28px; color: var(--muted); }
.load-sub {
  font-family: var(--serif);
  color: var(--muted);
  font-size: 14px;
  margin: 14px 0 28px;
  letter-spacing: 4px;
}
.load-bar-wrap {
  width: 280px; height: 6px;
  margin: 0 auto 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  position: relative;
}
.load-bar { width: 100%; height: 100%; overflow: hidden; }
.load-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, #c45c8a, var(--gold));
  box-shadow: 0 0 10px rgba(212,181,106,.5);
  transition: width 0.15s linear;
}
.load-text {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.load-hint {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
  letter-spacing: 1px;
}

.screen {
  position: absolute; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, #2a1840 0%, transparent 55%),
    radial-gradient(ellipse at 80% 100%, #1a1028 0%, var(--bg) 60%);
}
.screen.active { display: flex; }

/* ===== 菜单背景：扫描线 + 和风暗纹 ===== */
.menu-bg {
  position: absolute; inset: 0;
  background:
    linear-gradient(transparent 50%, rgba(0,0,0,.28) 50%),
    repeating-linear-gradient(
      90deg,
      transparent 0, transparent 48px,
      rgba(212,181,106,.03) 48px, rgba(212,181,106,.03) 49px
    ),
    radial-gradient(circle at 20% 80%, rgba(196,92,138,.12), transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(232,200,120,.1), transparent 40%);
  background-size: 100% 3px, auto, auto, auto;
  pointer-events: none;
}
.menu-title-art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(11,10,18,.55) 0%, rgba(11,10,18,.82) 100%),
    url('../assets/ui/title_banner.jpg') center / cover no-repeat;
  opacity: 0.55;
  pointer-events: none;
  filter: saturate(0.95) contrast(1.05);
}
.menu-title-art.ready { animation: artFade 1.2s ease; }
@keyframes artFade {
  from { opacity: 0; }
  to { opacity: 0.55; }
}

.th-ornament {
  position: absolute;
  width: 80px; height: 80px;
  border: 2px solid rgba(212,181,106,.35);
  pointer-events: none;
  z-index: 2;
}
.th-ornament.top-left { top: 24px; left: 24px; border-right: none; border-bottom: none; }
.th-ornament.top-right { top: 24px; right: 24px; border-left: none; border-bottom: none; }

/* ===== 东方风面板 ===== */
.menu-panel, .th-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 92vw);
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  text-align: center;
}
.menu-panel.wide, .th-panel.wide { width: min(680px, 94vw); }

.th-panel-frame {
  padding: 1.75rem 1.6rem 1.4rem;
  background:
    linear-gradient(180deg, rgba(30,24,44,.96) 0%, rgba(16,12,24,.97) 100%);
  border: 2px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(240,215,140,.15),
    0 18px 50px rgba(0,0,0,.55),
    inset 0 0 40px rgba(212,181,106,.04);
  position: relative;
}
.th-panel-frame::before,
.th-panel-frame::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid var(--gold);
  opacity: 0.7;
}
.th-panel-frame::before { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.th-panel-frame::after { bottom: 6px; right: 6px; border-left: none; border-top: none; }

.game-brand {
  font-family: var(--serif);
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--gold);
  margin-bottom: 0.35rem;
  opacity: 0.85;
}
.game-title {
  font-family: var(--serif);
  font-size: clamp(2rem, 5.5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold2);
  text-shadow:
    0 0 20px rgba(232,200,120,.35),
    0 2px 0 #3a2a10;
}
.game-title span {
  font-weight: 400;
  font-size: 0.55em;
  letter-spacing: 0.2em;
  margin-left: 0.2em;
  color: #e8b4c8;
}
.game-subtitle {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0.45rem 0 1.4rem;
  letter-spacing: 0.22em;
  font-family: var(--serif);
}
.panel-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin-bottom: 1.1rem;
  color: var(--gold2);
  letter-spacing: 0.18em;
  text-shadow: 0 0 12px rgba(232,200,120,.3);
}

.menu-nav { display: flex; flex-direction: column; gap: 0.4rem; }
.menu-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 0;
  font-size: 1.05rem;
  font-family: var(--serif);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
  text-align: left;
  position: relative;
}
.menu-btn .star {
  opacity: 0;
  color: var(--hi);
  margin-right: 0.4rem;
  transition: opacity .12s;
}
.menu-btn:hover, .menu-btn:focus, .menu-btn.selected {
  border-color: rgba(212,181,106,.45);
  background: linear-gradient(90deg, rgba(212,181,106,.12), transparent 70%);
  color: #fff8e8;
  outline: none;
}
.menu-btn:hover .star, .menu-btn.selected .star { opacity: 1; }
.menu-btn.ghost {
  background: transparent;
  color: var(--muted);
  margin-top: 0.75rem;
  text-align: center;
  border: 1px solid rgba(154,139,110,.3);
}
.menu-btn.ghost:hover { color: var(--gold); border-color: var(--border-lite); }
.menu-hint {
  margin-top: 1.1rem;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.12em;
}

/* 难度 */
.diff-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
  text-align: left;
}
.diff-btn {
  appearance: none;
  border: 1px solid rgba(92,74,46,.7);
  background: rgba(12,10,18,.75);
  color: var(--text);
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, box-shadow .12s, background .12s;
  position: relative;
}
.diff-btn::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--diff-color, var(--gold));
  opacity: 0.85;
}
.diff-btn:hover, .diff-btn.selected {
  border-color: var(--diff-color, var(--gold));
  background: rgba(30,24,44,.95);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--diff-color, #d4b56a) 35%, transparent);
}
.diff-rank {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  font-weight: 700;
}
.diff-name {
  font-family: var(--serif);
  font-size: 1.2rem;
  margin: 0.15rem 0 0.25rem;
  color: #fff6e0;
}
.diff-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.diff-meta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-family: var(--mono);
  color: rgba(212,181,106,.75);
}

/* Player select */
.player-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.player-card {
  border: 1px solid rgba(92,74,46,.75);
  background: rgba(16,12,24,.9);
  padding: 1.25rem 0.75rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
}
.player-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 0 18px rgba(212,181,106,.15);
}
.player-orb {
  width: 48px; height: 48px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  box-shadow: 0 0 20px currentColor;
}
.player-orb.blue {
  background: radial-gradient(circle at 35% 35%, #fff, #7dd3fc 40%, #2563eb 80%);
  color: #7dd3fc;
}
.player-orb.pink {
  background: radial-gradient(circle at 35% 35%, #fff, #f9a8d4 40%, #db2777 80%);
  color: #f9a8d4;
}
.player-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 160px;
  margin: 0 auto 0.65rem;
  background-size: cover;
  background-position: center top;
  border: 1px solid rgba(212,181,106,.45);
  box-shadow: 0 0 16px rgba(212,181,106,.12);
}
.player-card h3 {
  font-family: var(--serif);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  color: var(--gold2);
}
.player-card p { font-size: 0.75rem; color: var(--muted); }

/* Stage grid */
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
  text-align: left;
}
.stage-btn {
  border: 1px solid rgba(92,74,46,.7);
  background: rgba(16,12,24,.9);
  color: var(--text);
  padding: 0.75rem;
  cursor: pointer;
  text-align: left;
  font-family: var(--serif);
}
.stage-btn:hover { border-color: var(--gold); }
.stage-btn small { display: block; color: var(--muted); margin-top: 0.25rem; font-size: 0.7rem; font-family: var(--font); }
.stage-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Practice */
.practice-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
  margin-bottom: 1rem;
}
.practice-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.practice-form label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}
.practice-form select,
.practice-form input[type="number"] {
  background: #0c0a12;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem;
  font-size: 1rem;
  font-family: var(--mono);
}
.row-btns {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Keys */
.keys-hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 1rem; }
.key-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(16,12,24,.9);
  border: 1px solid rgba(92,74,46,.7);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--serif);
}
.key-row.listening {
  border-color: var(--warn);
  box-shadow: 0 0 0 1px rgba(251,191,36,.4);
}
.key-row kbd {
  background: #0c0a12;
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  font-family: var(--mono);
  min-width: 2.5rem;
  color: var(--gold2);
}

/* Manual */
.manual-panel { max-height: 90vh; overflow: hidden; }
.manual-panel .th-panel-frame {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.manual-body {
  text-align: left;
  overflow-y: auto;
  max-height: 60vh;
  padding: 0.35rem 0.4rem 1rem;
  font-size: 0.88rem;
  line-height: 1.65;
  color: #d8cbb0;
}
.manual-chapter {
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.18);
}
.manual-chapter:last-child {
  border-bottom: none;
  margin-bottom: 0.25rem;
}
.manual-body h3 {
  color: var(--gold);
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
  letter-spacing: 0.04em;
}
.manual-body p {
  margin: 0;
  white-space: normal;
}

/* ===== 游戏三栏 ===== */
#screen-game {
  background: #06050a;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}
/* 结局故事：全屏空白 + 对话，无左右栏/版面装饰 */
#screen-game.ending-cinematic {
  background: #000;
}
#screen-game.ending-cinematic .panel-left,
#screen-game.ending-cinematic .panel-right {
  display: none !important;
}
#screen-game.ending-cinematic .game-layout {
  grid-template-columns: 1fr;
  background: #000;
}
#screen-game.ending-cinematic .panel-center {
  max-width: min(100vw, 560px);
  margin: 0 auto;
  width: 100%;
  background: #000;
}
#screen-game.ending-cinematic .playfield-wrap {
  background: #000;
  border: none;
  box-shadow: none;
}
#screen-game.ending-cinematic #playfield {
  background: #000;
  opacity: 1;
}
#screen-game.ending-cinematic .letter-banner,
#screen-game.ending-cinematic .touch-keys,
#screen-game.ending-cinematic .stage-label {
  display: none !important;
}
#screen-game.ending-cinematic .dialogue-box {
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.65) 25%, rgba(0, 0, 0, 0.92) 100%);
}
.game-layout {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.panel-left, .panel-right, .panel-center {
  min-width: 0;
  min-height: 0;
  position: relative;
}
.panel-left {
  background: #08060e;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
#bg3d {
  width: 100%;
  height: 100%;
  display: block;
}
.overlay-fx {
  position: absolute; inset: 0;
  pointer-events: none;
  background: linear-gradient(transparent 50%, rgba(0,0,0,.14) 50%);
  background-size: 100% 3px;
  mix-blend-mode: overlay;
  opacity: 0.55;
}
.stage-label {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  font-size: 0.72rem;
  color: rgba(240,215,140,.65);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--mono);
  z-index: 2;
  text-shadow: 0 1px 4px #000;
}

.panel-center {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 50%, #14101c 0%, #08060e 80%);
  padding: 0.5rem;
}
.playfield-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 450 / 600;
}
#playfield {
  width: 100%;
  height: 100%;
  object-fit: contain;
  aspect-ratio: 450 / 600;
  display: block;
  margin: auto;
  background: #0a0810;
  border: 2px solid var(--border);
  box-shadow:
    0 0 0 1px rgba(240,215,140,.12),
    inset 0 0 30px rgba(0,0,0,.4);
  image-rendering: auto;
  max-width: 100%;
  max-height: 100%;
}

/* Dialogue — 东方对话框 + 立绘 */
.dialogue-box {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 5%;
  background: rgba(12, 10, 18, 0.92);
  border: 2px solid rgba(212,181,106,.5);
  padding: 0.55rem 0.65rem 0.45rem;
  z-index: 10;
  box-shadow: 0 0 24px rgba(0,0,0,.55);
}
.dialogue-box.hidden { display: none; }
.dialogue-layout {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  min-height: 88px;
}
.dialogue-portrait-wrap {
  flex: 0 0 72px;
  display: flex;
  align-items: flex-end;
}
.dialogue-portrait {
  width: 72px;
  height: 96px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid rgba(212,181,106,.55);
  box-shadow: 0 0 12px rgba(212,181,106,.2);
  background: #1a1424;
}
.dialogue-portrait.hidden { display: none; }
.dialogue-content { flex: 1; min-width: 0; }
.dialogue-name {
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  letter-spacing: 0.08em;
}
.dialogue-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #f2e6c8;
  min-height: 2.6em;
}
.dialogue-hint {
  text-align: right;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.3rem;
  letter-spacing: 0.08em;
}

.flash-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 20;
  pointer-events: none;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(248,113,113,.85);
  letter-spacing: 0.2em;
  animation: flashPulse 0.15s ease infinite alternate;
}
.flash-msg.hidden, .letter-banner.hidden, .game-overlay.hidden { display: none; }

/* 暂停 / 结束 共用叠加层 */
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.game-overlay-blur {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(10px) saturate(0.85);
  -webkit-backdrop-filter: blur(10px) saturate(0.85);
  background: rgba(6, 5, 12, 0.52);
}
.game-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(92%, 280px);
  text-align: center;
  padding: 1.1rem 1rem 0.85rem;
  border: 1px solid rgba(232, 200, 120, 0.35);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(28, 22, 40, 0.92), rgba(12, 10, 18, 0.94));
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.55), 0 0 18px rgba(232, 200, 120, 0.12);
}
.game-overlay-title {
  font-family: var(--serif);
  font-size: 1.55rem;
  letter-spacing: 0.22em;
  color: var(--gold2);
  text-shadow: 0 0 18px rgba(232, 200, 120, 0.45);
  margin: 0 0 0.55rem;
}
.game-overlay.mode-result .game-overlay-title {
  letter-spacing: 0.12em;
  font-size: 1.35rem;
}
.game-overlay-body {
  margin: 0 0 0.85rem;
  font-family: inherit;
  font-size: 0.78rem;
  line-height: 1.55;
  color: #d8cbb0;
  white-space: pre-wrap;
  text-align: left;
  max-height: 28vh;
  overflow-y: auto;
}
.game-overlay-body:empty { display: none; }
.game-overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.game-overlay-actions .overlay-btn {
  width: 100%;
  margin: 0;
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
}
.game-overlay-actions .overlay-btn.hidden { display: none !important; }
.game-overlay-actions .overlay-btn.selected,
.game-overlay-actions .overlay-btn:focus-visible {
  outline: 1px solid var(--gold2);
  box-shadow: 0 0 12px rgba(232, 200, 120, 0.35);
}
.game-overlay-hint {
  margin: 0.65rem 0 0;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}
@keyframes flashPulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.letter-banner {
  position: absolute;
  top: 2.5%;
  right: 2.5%;
  left: auto;
  transform: none;
  text-align: right;
  z-index: 8;
  pointer-events: none;
  max-width: 58%;
  opacity: 1;
  transition: opacity 0.12s linear;
}
.letter-name {
  font-family: var(--serif);
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffe08a;
  text-shadow: 0 0 10px rgba(251,191,36,.55), 0 1px 2px rgba(0,0,0,.85);
  letter-spacing: 0.04em;
  line-height: 1.35;
  word-break: break-word;
}
.letter-bonus {
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #f9a8d4;
  text-shadow: 0 0 8px rgba(244,114,182,.45), 0 1px 2px rgba(0,0,0,.85);
}
.letter-timer {
  margin-top: 0.1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(255,255,255,.78);
  text-shadow: 0 1px 2px rgba(0,0,0,.85);
}

/* 右侧分数板 — TH 风格 */
.panel-right {
  background: linear-gradient(180deg, #14101c 0%, #0c0a12 100%);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.score-panel, .th-score {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.75rem;
  min-height: 0;
}
.th-score-title {
  font-family: var(--serif);
  text-align: center;
  color: var(--gold2);
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(92,74,46,.6);
  text-shadow: 0 0 10px rgba(232,200,120,.25);
}
.stat-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  font-size: clamp(0.7rem, 1.35vw, 0.84rem);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-family: var(--serif);
}
.stat-row strong {
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}
.stat-row.th-hi strong { color: var(--hi); }
.stat-row.th-sc strong { color: var(--sc); }

.icon-row {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.icon-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.icon-dot.life {
  background: #ff7a9a;
  color: #ff7a9a;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  border-radius: 0;
  width: 12px; height: 12px;
}
.icon-dot.bomb {
  background: #c4b5fd;
  color: #c4b5fd;
  border-radius: 2px;
  transform: rotate(45deg);
  width: 9px; height: 9px;
}

.edit-bar {
  flex: 1;
  height: 10px;
  background: #1a1524;
  overflow: hidden;
  border: 1px solid rgba(92,74,46,.6);
  max-width: 120px;
  margin-left: auto;
}
.edit-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c45c8a, #e8c878);
  transition: width 0.08s linear;
}
.edit-fill.full {
  box-shadow: 0 0 10px rgba(232,200,120,.7);
  animation: editGlow 0.6s ease infinite alternate;
}
@keyframes editGlow {
  from { filter: brightness(1); }
  to { filter: brightness(1.35); }
}

.touch-keys {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(92,74,46,.55);
  margin-top: auto;
  position: relative;
  z-index: 30;
  pointer-events: auto;
}
.touch-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #221a30, #14101c);
  color: var(--gold2);
  padding: 1rem 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--serif);
  letter-spacing: 0.08em;
  cursor: pointer;
  min-height: 52px;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  z-index: 31;
}
.touch-btn:active, .touch-btn.active {
  background: #2a2040;
  border-color: var(--gold);
  transform: scale(0.97);
}
.touch-btn.bomb:active, .touch-btn.bomb.active {
  border-color: #c4b5fd;
  background: #241848;
}
.touch-btn.pause:active, .touch-btn.pause.active {
  border-color: #7dd3fc;
  background: #142838;
}

/* Result */
.result-panel { max-width: min(560px, 94vw); }
.result-body {
  text-align: left;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #d8cbb0;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 1.25rem;
  white-space: pre-wrap;
}
.result-body .score-line {
  font-family: var(--mono);
  color: var(--gold);
  margin: 0.5rem 0;
}

@media (max-width: 820px) {
  .game-layout {
    grid-template-columns: 0 1fr minmax(100px, 28vw);
  }
  .panel-left { display: none; }
}
@media (max-width: 520px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .panel-left { display: none; }
  .panel-right {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 38vh;
  }
  .stat-block { flex-direction: row; flex-wrap: wrap; gap: 0.4rem 1rem; }
  .stat-row { min-width: 40%; }
  .touch-keys { padding-bottom: env(safe-area-inset-bottom, 0); }
  .player-cards { grid-template-columns: 1fr; }
}
