/* 黃昏路燈值班員：黃昏的台灣巷弄，藍色琺瑯路牌、值班表的紙夾板（刻意單一主題） */
:root {
  color-scheme: light;
  --ink: #3b2f3a;         /* 墨色，主要文字 */
  --ink-soft: #6a5a68;
  --paper: #fffaf0;       /* 紙 */
  --paper-2: #f6ecd9;
  --sun: #ffc861;         /* 夕陽黃，主要按鈕 */
  --sun-deep: #f29f45;
  --dusk: #5a4a91;        /* 黃昏紫 */
  --sign: #1f5aa6;        /* 路牌藍 */
  --lamp: #ffd35c;        /* 路燈暖黃 */
  --stamp: #d8343f;       /* 值班章的紅 */
  --green: #35584a;       /* 路燈桿的綠 */
  --shadow: rgba(40, 24, 48, 0.28);

  --font: "Huninn", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", "WenQuanYi Zen Hei", sans-serif;
  --font-num: "Baloo 2", "Huninn", "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  --grid-x: 0px;          /* 由 JS 依畫面更新 */
  --grid-w: 100vw;
  --grid-y: 0px;
  --grid-h: 100vh;
}

[hidden] { display: none !important; }

html { height: 100%; box-sizing: border-box; background: #2d2547; }
*, *::before, *::after { box-sizing: inherit; }

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #2d2547;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui button, #ui .panel, #ui .roster-board { pointer-events: auto; }

button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--lamp);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; color: #fffaf0; }

/* ---------- 按鈕 ---------- */
.btn {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 11px 22px;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-indent: 0.08em;
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(59, 47, 58, 0.28), 0 10px 22px rgba(20, 10, 30, 0.22);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(59, 47, 58, 0.28), 0 4px 10px rgba(20, 10, 30, 0.2); }
.btn-primary { background: var(--sun); }
.btn-primary:hover { background: #ffd47f; }
.btn-ghost { background: var(--paper); }
.btn-ghost:hover { background: #fff4de; }

.btn-link {
  display: block;
  margin: 8px auto 0;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink-soft);
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.95);
  box-shadow: 0 3px 0 rgba(59, 47, 58, 0.25), 0 6px 14px rgba(20, 10, 30, 0.2);
  transition: transform 0.1s ease;
}
.icon-btn:active { transform: translateY(2px); }
.icon-btn svg { width: 22px; height: 22px; fill: var(--ink); }
.icon-btn svg .stroke, .ctl-btn svg .stroke { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn-small { width: 40px; height: 40px; border-radius: 12px; }
.js-sound[aria-pressed="true"] .icon-sound-off,
.js-sound[aria-pressed="false"] .icon-sound-on { display: none; }

.screen { position: absolute; inset: 0; }

.toolbar {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  display: flex;
  gap: 8px;
  z-index: 3;
}

/* ---------- 首頁：藍色琺瑯路牌 ---------- */
.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 64px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.title-sign {
  position: relative;
  max-width: min(92%, 440px);
  padding: 12px 30px 16px;
  border-radius: 14px;
  background: var(--sign);
  color: #fff;
  text-align: center;
  box-shadow: inset 0 0 0 3px #1f5aa6, inset 0 0 0 6px #fff, 0 6px 0 #173f75, 0 16px 30px rgba(20, 10, 40, 0.35);
  transform: rotate(-1.6deg);
  animation: sign-in 0.9s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  pointer-events: auto;
}
.sign-bolt { position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #dfe6f0; box-shadow: inset -1px -1px 0 rgba(0, 0, 0, 0.3); }
.sign-bolt-l { left: 11px; }
.sign-bolt-r { right: 11px; }
.sign-kicker { margin: 0 0 2px; font-size: 13px; letter-spacing: 0.3em; opacity: 0.92; }
.title-main {
  margin: 0;
  font-size: clamp(24px, min(8.8vw, 7.6vh), 46px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  white-space: nowrap;
}
.title-sub {
  margin: 16px 0 0;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(59, 47, 58, 0.55);
  color: #fff6de;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-align: center;
  animation: fade-up 0.8s 0.3s ease both;
}
.title-bottom { margin-top: auto; width: 100%; max-width: 420px; text-align: center; animation: fade-up 0.8s 0.5s ease both; }
.title-actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.title-records { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 8px; margin-top: 8px; }
.title-progress {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(59, 47, 58, 0.62);
  color: #fff3cf;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.title-records .title-progress { margin: 0; }
.title-album { min-height: 44px; margin: 0; background: rgba(59, 47, 58, 0.82); color: #fff3cf; }

@keyframes sign-in {
  0% { transform: translateY(-40px) rotate(-8deg); opacity: 0; }
  100% { transform: translateY(0) rotate(-1.6deg); opacity: 1; }
}
@keyframes fade-up {
  0% { transform: translateY(12px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

/* ---------- 值班表 ---------- */
.roster-screen {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: rgba(30, 20, 45, 0.35);
}
.roster-board {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 10px 10px;
  border-radius: 18px;
  background: #a8764c;
  box-shadow: 0 8px 0 #7d5433, 0 18px 40px rgba(20, 10, 30, 0.4);
  animation: fade-up 0.35s ease both;
}
.clip {
  position: absolute;
  top: -8px;
  left: 50%;
  width: 96px;
  height: 22px;
  margin-left: -48px;
  border-radius: 8px 8px 12px 12px;
  background: linear-gradient(#e3e6ec, #aab0bc);
  box-shadow: 0 3px 0 #7f8592;
}
.roster-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 8px;
  border-radius: 12px 12px 0 0;
  background: var(--paper);
}
.roster-titles { flex: 1; min-width: 0; }
.roster-title { margin: 0; font-size: 23px; font-weight: 400; letter-spacing: 0.12em; line-height: 1.25; }
.roster-sum { margin: 0; color: var(--ink-soft); font-size: 14px; font-variant-numeric: tabular-nums; }
.roster-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 2px 10px 12px;
  border-radius: 0 0 12px 12px;
  background: var(--paper) repeating-linear-gradient(transparent 0 31px, rgba(90, 120, 170, 0.14) 31px 32px);
}
.zone-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 2px 4px;
  color: var(--dusk);
  font-size: 15px;
  letter-spacing: 0.2em;
}
.zone-head::after { content: ""; flex: 1; height: 2px; border-radius: 1px; background: rgba(90, 74, 145, 0.25); }
.zone-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.street-row {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 8px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 0 rgba(59, 47, 58, 0.14);
  text-align: left;
  transition: transform 0.1s ease, background-color 0.15s ease;
}
.street-row:hover:not([disabled]) { background: #fff8e6; transform: translateY(-1px); }
.street-row:active:not([disabled]) { transform: translateY(1px); }
.street-row[disabled] { background: rgba(255, 255, 255, 0.5); box-shadow: none; cursor: default; color: #8a7d88; }
.row-num {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sign);
  color: #fff;
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 16px;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 1.5px var(--sign);
}
.street-row[disabled] .row-num { background: #b9b0bb; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1.5px #b9b0bb; }
.row-name { display: block; font-size: 16.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { display: block; color: var(--ink-soft); font-size: 12.5px; line-height: 1.3; }
.street-row[disabled] .row-sub { color: #8a7d88; }
.row-stars { display: flex; gap: 2px; }
.row-stars i { width: 17px; height: 17px; background: #ddd3c8; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.row-stars i.on { background: var(--sun-deep); }
.row-lock { width: 20px; height: 20px; fill: #a99fab; }
.stamp {
  position: absolute;
  right: 74px;
  top: 50%;
  margin-top: -17px;
  width: 50px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(216, 52, 63, 0.75);
  border-radius: 50%;
  color: rgba(216, 52, 63, 0.85);
  font-size: 12px;
  letter-spacing: 0.05em;
  transform: rotate(-14deg);
  pointer-events: none;
}
.tonight-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--lamp);
  color: var(--ink);
  font-size: 11.5px;
  vertical-align: 2px;
  animation: glow 1.6s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 10px 2px rgba(255, 211, 92, 0.9); } }

/* ---------- 遊戲中的資訊列 ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 0;
  display: flex;
  justify-content: center;
}
.hud-bar {
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.94);
  box-shadow: 0 3px 0 rgba(59, 47, 58, 0.2), 0 8px 18px rgba(20, 10, 30, 0.2);
  pointer-events: auto;
}
.hud .icon-btn { box-shadow: none; background: var(--paper-2); }
.hud-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.hud-zone { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-name { font-size: 17px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 2px 8px;
  border-radius: 10px;
  background: #3b2f3a;
  color: #fff3cf;
  font-size: 12.5px;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hud-stats b { font-family: var(--font-num); font-weight: 800; font-size: 15px; color: var(--lamp); }
.hud-stats small { font-size: 11.5px; color: #e8d9c0; }
.mini-lamp { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 6px var(--lamp); vertical-align: 0; }

/* ---------- 下面的操作按鈕 ---------- */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 0 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
}
.ctl-btn {
  position: relative;
  min-width: 92px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.96);
  box-shadow: 0 4px 0 rgba(59, 47, 58, 0.3), 0 10px 18px rgba(20, 10, 30, 0.25);
  font-size: 17px;
  letter-spacing: 0.06em;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.ctl-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(59, 47, 58, 0.3); }
.ctl-btn svg { width: 22px; height: 22px; flex: none; }
.ctl-btn[disabled] { opacity: 0.5; cursor: default; }
.ctl-hint { background: #fff1c2; }
.hint-count {
  position: absolute;
  top: -7px;
  right: -5px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  background: var(--sun-deep);
  color: #fff;
  font-family: var(--font-num);
  font-weight: 800;
  font-style: normal;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 0 rgba(59, 47, 58, 0.3);
}

/* ---------- 字幕 ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  width: max-content;
  max-width: min(92%, 440px);
  transform: translateX(-50%);
  padding: 8px 16px 9px;
  border-radius: 8px 8px 16px 8px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(59, 47, 58, 0.22), 0 10px 20px rgba(20, 10, 30, 0.25);
  text-align: center;
  animation: toast-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.toast-title { display: block; font-weight: 400; font-size: 16px; color: var(--dusk); }
.toast-text { display: block; font-size: 14.5px; line-height: 1.45; text-wrap: pretty; }
.toast.out { animation: toast-out 0.3s ease both; }
/* 字幕的位置：格子上面、下面、電腦的左邊、橫拿手機的左下 */
.toast.at-bottom { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); }
.toast.at-left,
.toast.at-side { transform: none; text-align: left; animation: fade-only 0.35s ease both; }
.toast.at-left { left: 16px; top: calc(var(--grid-y) + 16px); max-width: min(320px, calc(var(--grid-x) - var(--gap-w) - 32px)); }
.toast.at-side {
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  width: calc(var(--grid-x) - env(safe-area-inset-left, 0px) - 16px - var(--gap-w));
  max-width: 260px;
}
.toast.at-left.out, .toast.at-side.out { animation: fade-only 0.3s ease reverse both; }
@keyframes toast-in { 0% { transform: translate(-50%, -10px); opacity: 0; } 100% { transform: translate(-50%, 0); opacity: 1; } }
@keyframes toast-out { to { transform: translate(-50%, -8px); opacity: 0; } }

/* ---------- 教學的手指 ---------- */
.tap-hint { position: absolute; width: 0; height: 0; z-index: 2; }
.tap-ring {
  position: absolute;
  left: -30px;
  top: -30px;
  width: 60px;
  height: 60px;
  border: 3px solid rgba(255, 250, 230, 0.95);
  border-radius: 50%;
  animation: ring 1.4s ease-out infinite;
}
.tap-finger {
  position: absolute;
  left: -2px;
  top: 6px;
  width: 38px;
  height: 46px;
  filter: drop-shadow(0 3px 3px rgba(20, 10, 30, 0.35));
  animation: tap 1.4s ease-in-out infinite;
}
@keyframes ring { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes tap { 0%, 100% { transform: translate(6px, 10px); } 40% { transform: translate(0, 0); } 55% { transform: translate(0, 2px) scale(0.95); } }

.skip-hint {
  position: absolute;
  left: 0;
  right: 0;
  width: max-content;
  margin: 0 auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  font-size: 14px;
  animation: fade-up 0.6s 1.5s ease both;
}

/* ---------- 結算卡 ---------- */
.sheet-layer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 10px;
}
.panel {
  width: 100%;
  max-width: 460px;
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 -6px 30px rgba(10, 8, 30, 0.35);
}
.result-card {
  position: relative;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 16px 18px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-radius: 22px 22px 0 0;
  text-align: center;
  animation: sheet-up 0.55s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}
@keyframes sheet-up { 0% { transform: translateY(100%); } 100% { transform: none; } }
/* 蓋在結算卡右上角的值班章 */
.res-stamp {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 64px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2.5px solid rgba(216, 52, 63, 0.8);
  border-radius: 50%;
  color: rgba(216, 52, 63, 0.9);
  font-size: 14px;
  letter-spacing: 0.05em;
  transform: rotate(-14deg);
  animation: stamp-in 0.35s 1.1s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  pointer-events: none;
}
@keyframes stamp-in {
  0% { transform: scale(2.2) rotate(-30deg); opacity: 0; }
  100% { transform: scale(1) rotate(-14deg); opacity: 1; }
}
.result-kicker { margin: 0; padding: 0 52px; color: var(--dusk); font-size: 14px; letter-spacing: 0.1em; text-wrap: balance; }
.panel-title { margin: 2px 0 4px; font-size: 25px; font-weight: 400; letter-spacing: 0.1em; }
.stars-big { display: flex; justify-content: center; gap: 10px; margin: 2px 0 4px; }
.stars-big .star {
  width: 44px;
  height: 44px;
  background: #e2d8cc;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.stars-big .star.on { background: var(--sun-deep); animation: star-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.stars-big .star.on:nth-child(2) { animation-delay: 0.25s; }
.stars-big .star.on:nth-child(3) { animation-delay: 0.5s; }
@keyframes star-pop { 0% { transform: scale(0.2) rotate(-40deg); } 100% { transform: none; } }
.result-note {
  margin: -2px auto 10px;
  max-width: 340px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #fff1c2;
  font-size: 14.5px;
  line-height: 1.5;
}
.result-moves { margin: 0 0 8px; color: var(--ink-soft); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tonight { margin: 0 0 12px; padding: 10px 10px 8px; border-radius: 14px; background: #2f2a4f; color: #fff3cf; }
.tonight-title { margin: 0 0 6px; font-size: 15px; font-weight: 400; letter-spacing: 0.2em; }
.win-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 10px; text-align: left; }
.win-list li { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; line-height: 1.3; }
.win-list canvas { flex: none; width: 58px; height: 40px; border-radius: 6px; box-shadow: 0 0 0 2px #f5f0e6, 0 0 12px rgba(255, 200, 120, 0.5); }
.result-album { min-height: 44px; margin: 3px auto 0; color: #fff3cf; }
.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-actions .btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }

.window-album {
  width: min(620px, calc(100% - 28px));
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 28px);
  padding: 0;
  border: 1px solid #d69b64;
  border-radius: 22px;
  background: #26213c;
  color: #fff0cf;
  box-shadow: 0 20px 60px rgba(17, 10, 28, 0.55);
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.window-album::backdrop { background: rgba(25, 20, 44, 0.68); }
.window-album summary:focus-visible { outline: 2px solid #ffe1a3; outline-offset: 3px; }
.album-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #26213c;
  border-bottom: 1px solid #67557c;
}
.album-head h2 { margin: 0; font-size: 25px; font-weight: 400; letter-spacing: 0.08em; }
.album-count { margin: 0; color: #dacee4; font-size: 14px; }
.album-close {
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid #ecba83;
  border-radius: 11px;
  background: #fff0cf;
  color: #39283f;
  white-space: nowrap;
}
.album-empty { margin: 0; padding: 26px 18px; text-align: center; }
.album-streets { display: grid; gap: 10px; padding: 12px; }
.album-streets:empty { display: none; }
.album-street { padding: 0 12px; border: 1px solid #655277; border-radius: 13px; background: #3b3150; }
.album-street summary { min-height: 44px; padding-block: 10px; cursor: pointer; }
.album-street summary::marker { color: #ffd697; }
.album-scenes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 142px), 1fr)); gap: 12px; margin-bottom: 13px; }
.album-scenes figure { margin: 0; }
.album-scenes canvas { display: block; width: 100%; height: auto; border: 2px solid #e7b17a; border-radius: 8px; }
.album-scenes figcaption { padding-top: 5px; text-align: center; text-wrap: balance; }

/* ---------- 說明 ---------- */
.modal-layer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: rgba(30, 20, 45, 0.55);
  z-index: 5;
}
.panel-help {
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 18px 18px 16px;
  animation: fade-up 0.3s ease both;
}
.panel-help .panel-title { text-align: center; }
.help-lead { margin: 4px 0 10px; font-size: 15px; }
.help-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.help-list li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; }
.help-list p { margin: 0; font-size: 14.5px; line-height: 1.5; }
.help-list b { font-weight: 400; color: var(--dusk); }
.help-icon { width: 44px; height: 44px; border-radius: 12px; background: #3a3462; display: grid; place-items: center; }
.help-icon svg { width: 38px; height: 38px; }
.help-stars { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 12px 0 8px; }
.help-stars span { padding: 2px 10px; border-radius: 999px; background: var(--paper-2); font-size: 13.5px; }
.help-keys { margin: 0 0 10px; color: var(--ink-soft); font-size: 13.5px; }
.help-toggles { margin: 0 0 12px; }
.btn-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--paper-2);
  font-size: 14.5px;
  text-align: left;
}
.btn-toggle b { font-weight: 400; padding: 2px 10px; border-radius: 999px; background: var(--green); color: #fff; }
.btn-toggle[aria-pressed="false"] b { background: #b9b0bb; }
.panel-help .panel-actions { grid-template-columns: 1fr; }

/* ---------- 橫拿手機：資訊在左邊、按鈕在右邊 ---------- */
body[data-layout="side"] .hud {
  left: calc(env(safe-area-inset-left, 0px) + 8px);
  right: auto;
  top: 0;
  bottom: 0;
  width: calc(var(--grid-x) - env(safe-area-inset-left, 0px) - 16px - var(--gap-w, 0px));
  max-width: 260px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 0 0;
  align-items: flex-start;
}
body[data-layout="side"] .hud-bar { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "back title title" "stats stats stats" "sound help ."; }
body[data-layout="side"] #btnBack { grid-area: back; }
body[data-layout="side"] .hud-title { grid-area: title; }
body[data-layout="side"] .hud-stats { grid-area: stats; flex-direction: row; justify-content: space-between; gap: 10px; }
body[data-layout="side"] #btnSoundHud { grid-area: sound; }
body[data-layout="side"] #btnHelpHud { grid-area: help; }
body[data-layout="side"] .controls {
  left: auto;
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  padding: 0;
}
body[data-layout="side"] .title-screen { padding-top: calc(env(safe-area-inset-top, 0px) + 14px); }
body[data-layout="side"] .title-bottom { max-width: 460px; }
body[data-layout="side"] .result-card { max-width: 560px; }

/* 很矮的畫面 */
@media (max-height: 600px) {
  .title-screen { padding-top: calc(env(safe-area-inset-top, 0px) + 54px); }
  .title-sub { margin-top: 10px; font-size: 14px; }
  .btn { min-height: 44px; padding: 9px 18px; font-size: 18px; }
  .ctl-btn { height: 48px; min-width: 84px; font-size: 16px; }
  .stars-big .star { width: 36px; height: 36px; }
  .panel-title { font-size: 22px; }
  .toast { top: calc(env(safe-area-inset-top, 0px) + 58px); }
}
@media (max-width: 360px) {
  .hud { padding-left: 6px; padding-right: 6px; }
  .hud-bar { gap: 4px; padding: 4px; }
  .hud .icon-btn-small { width: 34px; height: 34px; border-radius: 10px; }
  .hud .icon-btn svg { width: 19px; height: 19px; }
  .hud-stats { padding: 2px 6px; font-size: 11px; }
  .hud-stats b { font-size: 13.5px; }
  .hud-stats small { font-size: 10.5px; }
}
@media (max-width: 350px) {
  .res-stamp { width: 52px; height: 36px; font-size: 12px; top: 10px; right: 10px; }
  .ctl-btn { min-width: 0; padding: 0 12px; gap: 4px; font-size: 15.5px; }
  .hud-zone { font-size: 10.5px; }
  .hud-name { font-size: 14.5px; }
  .panel-actions .btn { font-size: 17px; letter-spacing: 0.04em; }
  .win-list { grid-template-columns: 1fr 1fr; }
  .win-list canvas { width: 46px; height: 32px; }
}

/* 減少動態：拿掉晃動和彈跳，改成溫和的淡入 */
@media (prefers-reduced-motion: reduce) {
  .title-sign, .title-sub, .title-bottom, .roster-board, .toast, .result-card, .panel-help, .skip-hint,
  .stars-big .star.on, .res-stamp { animation: fade-only 0.5s ease both; }
  .stars-big .star.on:nth-child(2) { animation-delay: 0.2s; }
  .stars-big .star.on:nth-child(3) { animation-delay: 0.4s; }
  .toast.out { animation: fade-only 0.3s ease reverse both; }
  .tap-finger, .tonight-tag { animation: none; }
  .tap-ring { animation: none; opacity: 0.8; }
  .btn, .ctl-btn, .icon-btn, .street-row { transition: none; }
}
@keyframes fade-only { from { opacity: 0; } to { opacity: 1; } }
