@charset "UTF-8";
/* ==========================================================
   Lobby E — Split Zone (with hover state from R6Pkm)
   Design canvas: 1920 x 1080
   Palette (matched 1:1 to .pen file):
     bg cream     : #F0E8DC → #E5DDD0 → #DDD4C6
     ink          : #2D3436
     accent yellow: #FFD54F  (#E6A800 stroke / #FFD54FCC glow)
     orange       : #FF8C42
     blue         : #0096C7
     pink         : #e349b0
     green        : #52B788
     status green : #4CAF50
   ========================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #2D3436;
  background: linear-gradient(180deg, #F0E8DC 0%, #E5DDD0 70%, #DDD4C6 100%);
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* Stage: 1920x1080 design canvas, scaled by JS to fit viewport without scrollbars */
.stage {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  overflow: hidden;
}

/* ============ TOP DECORATIVE ARCS ============ */
.top-arcs {
  position: absolute;
  left: 0; top: 40px;
  width: 1920px;
  height: 280px;
  pointer-events: none;
  z-index: 1;
}

/* ============ TOP BAR ============ */
.title-bar {
  position: absolute;
  left: 0; top: 0;
  width: 1920px;
  height: 100px;
  padding: 0 40px;
  background: #F0E8DC;
  border-bottom: 1px solid rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}
.logo-slot { width: 150px; height: 76px; display: flex; align-items: center; }
.logo-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }

.score-bar { display: flex; align-items: center; gap: 10px; transform: translateX(90px); }
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #4CAF50;
  box-shadow: 0 0 8px rgba(76,175,80,.6);
}
.status-text {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(45,52,54,.67);
}

/* 右側預留空間給 fixed 定位的音訊按鈕（.top-right），避免玩家資訊被覆蓋 */
.user { display: flex; align-items: center; gap: 8px; margin-right: 120px; }
@media (max-width: 899px) {
  .user { margin-right: 90px; }
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #FFD54F;
  border: 2px solid #E6A800;
}
.user-grp { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.user-name  { font-size: 16px; font-weight: 700; color: #2D3436; }
.user-email { font-size: 13px; color: rgba(45,52,54,.53); }

/* ============ CENTER FLOATING TITLE ============ */
.center-area {
  position: absolute;
  left: 50%;
  top: 180px;
  transform: translateX(-50%);
  width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 4;
}

.sub-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 3px;
  color: rgba(45,52,54,.67);
}

.main-title {
  font-family: 'Noto Sans TC', 'Inter', sans-serif;
  font-size: 56px;
  font-weight: 900;
  color: #2D3436;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0,0,0,.08);
  line-height: 1;
}

.score-panel {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 14px 36px;
  border-radius: 12px;
  background: rgba(45,52,54,.93);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.score-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-lbl { font-size: 12px; color: rgba(255,255,255,.53); }
.score-val { font-size: 28px; font-weight: 900; color: #fff; }
.score-val.rank { color: #FFD54F; }

.lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 32px;
  border-radius: 8px;
  background: #2D3436;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transition: transform .15s ease, box-shadow .2s ease, background .15s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.lb-btn:hover {
  transform: translateY(-2px);
  background: #1f2526;
  box-shadow: 0 8px 20px rgba(0,0,0,.28);
}
.lb-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4CAF50;
  box-shadow: 0 0 8px rgba(76,175,80,.7);
}

/* ============ ZONES ============ */
.zones {
  position: absolute;
  left: 20px;
  top: 103px;
  width: 1880px;
  height: 957px;
  display: flex;
  gap: 16px;
  z-index: 2;
}

.zone {
  position: relative;
  width: 462px;
  height: 957px;
  border-radius: 14px;
  overflow: hidden;
  background: #0D1B2E;
  cursor: pointer;
  transition:
    transform .35s ease,
    box-shadow .35s ease,
    filter .35s ease;
}

/* zone background image (full fill) */
.zone-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.zone-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .6s ease;
}
.zone:hover .zone-bg img { transform: scale(1.04); }

/* gradient overlay (top + bottom dim — #0D253F at 33%/13%/13%/33%) */
.zone-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(13,37,63,.33) 0%,
    rgba(13,37,63,.13) 25%,
    rgba(13,37,63,.13) 65%,
    rgba(13,37,63,.33) 100%);
  z-index: 1;
  transition: opacity .35s ease;
}

/* corner brackets — default per-zone color, 70x5 / 5x70 */
.corner {
  position: absolute;
  z-index: 3;
  background: var(--bracket);
  box-shadow: 0 0 8px 2px var(--bracket-glow);
  pointer-events: none;
  transition:
    width .3s ease, height .3s ease,
    background .3s ease, box-shadow .3s ease;
}
.tl-h, .tr-h, .bl-h, .br-h { width: 70px; height: 5px; border-radius: 2px; }
.tl-v, .tr-v, .bl-v, .br-v { width: 5px; height: 70px; border-radius: 2px; }
.tl-h { left: 0;   top: 0; }
.tl-v { left: 0;   top: 0; }
.tr-h { right: 0;  top: 0; }
.tr-v { right: 0;  top: 0; }
.bl-h { left: 0;   bottom: 0; }
.bl-v { left: 0;   bottom: 0; }
.br-h { right: 0;  bottom: 0; }
.br-v { right: 0;  bottom: 0; }

.zone--orange { --bracket: #FF8C42; --bracket-glow: rgba(255,140,66,.67); }
.zone--blue   { --bracket: #0096C7; --bracket-glow: rgba(0,150,199,.67); }
.zone--pink   { --bracket: #e349b0; --bracket-glow: rgba(227,73,176,.67); }
.zone--green  { --bracket: #52B788; --bracket-glow: rgba(82,183,136,.67); }

/* character — enlarged & centered, sits above bottom card */
.zone-char {
  position: absolute;
  left: 65%;
  bottom: 17px;
  height: 380px;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 16px 24px rgba(0,0,0,.42));
  transform: translateX(-50%);
}
.char-c1 {width: 230px;}
.char-c2 {width: 230px;}
.char-c3 { width: 230px; }
.char-c4 { width: 230px; }

.zone-char .char-static,
.zone-char .char-video,
.zone-char .char-anim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity .35s ease;
}
.zone-char .char-video,
.zone-char .char-anim { opacity: 0; }
/* 未啟用的 video 用 visibility:hidden 強制不渲染，避免 Android Chrome
   把 video 升級為硬體 overlay layer 繞過 z-index 蓋住 zone 背景圖 */
.zone-char video.char-anim { visibility: hidden; }
.zone:hover .zone-char video.char-anim,
.zone.is-active .zone-char video.char-anim { visibility: visible; }
.zone:hover .char-static,
.zone.is-active .char-static { opacity: 0; }
.zone:hover .char-video,
.zone:hover .char-anim,
.zone.is-active .char-video,
.zone.is-active .char-anim   { opacity: 1; }

/* hover play button — uses each zone's theme color, hidden until hover */
.zone-play {
  position: absolute;
  left: 50%;
  top: 380px;
  transform: translateX(-50%) scale(.85);
  width: 170px;
  height: 52px;
  border-radius: 26px;
  background: var(--bracket);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  z-index: 7;
  opacity: 0;
  pointer-events: none;
  box-shadow:
    0 4px 20px rgba(0,0,0,.33),
    0 0 0 2px var(--bracket-glow);
  transition: opacity .3s ease, transform .35s cubic-bezier(.34,1.56,.64,1), filter .15s ease;
}
.zone:hover .zone-play {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  pointer-events: auto;
}
.zone-play:hover {
  filter: brightness(1.12);
  transform: translateX(-50%) scale(1.05);
}

/* bottom info card */
.zone-card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 220px;
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  background:
    linear-gradient(180deg, var(--card-tint, rgba(255,140,66,.13)) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0) 100%),
    #0D1B2E;
  border-top: 3px solid var(--bracket);
  z-index: 2;
  transition: border-top-color .35s ease;
}
.zone--orange .zone-card { --card-tint: rgba(255,140,66,.13); }
.zone--blue   .zone-card { --card-tint: rgba(0,150,199,.13); }
.zone--pink   .zone-card { --card-tint: rgba(227,73,176,.13); }
.zone--green  .zone-card { --card-tint: rgba(82,183,136,.13); }

/* card text — colors copied 1:1 from .pen */
.card-cat {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(255,255,255,.47);   /* #FFFFFF77 */
  margin-bottom: 4px;
}
.card-name {
  font-family: 'Noto Sans TC', 'Inter', sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
}
.card-desc {
  font-size: 11px;
  color: rgba(255,255,255,.6);    /* #FFFFFF99 */
  letter-spacing: .5px;
}
.card-sr {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}
.card-rank { font-size: 12px; font-weight: 700; color: #FFD54F; }
.card-pts  { font-size: 12px; font-weight: 700; color: #fff; }

/* ============ HOVER STATE (matches R6Pkm) ============ */
.zone:hover {
  transform: translateY(-6px);
  box-shadow:
    0 20px 50px rgba(0,0,0,.15),
    0 8px 20px rgba(0,0,0,.09),
    0 0 16px 3px var(--bracket-glow);
}
.zone:hover .zone-overlay { opacity: .6; }

/* hovered brackets enlarge & glow stronger — keep the zone's own color */
.zone:hover .corner {
  box-shadow: 0 0 14px 4px var(--bracket-glow);
}
.zone:hover .tl-h,
.zone:hover .tr-h,
.zone:hover .bl-h,
.zone:hover .br-h            { width: 90px; height: 7px; }
.zone:hover .tl-v,
.zone:hover .tr-v,
.zone:hover .bl-v,
.zone:hover .br-v            { width: 7px; height: 90px; }

/* ============ MOBILE LANDSCAPE LOCK ============ */
.rotate-hint {
  position: fixed;
  inset: 0;
  background: #0d1320;
  color: #fff;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-size: 22px;
  text-align: center;
  padding: 30px;
  line-height: 1.7;
  font-family: 'Noto Sans TC', sans-serif;
}
.rotate-hint .ico {
  font-size: 90px;
  margin-bottom: 18px;
  animation: rotateAnim 1.6s ease-in-out infinite;
}
@keyframes rotateAnim {
  0%   { transform: rotate(-90deg); }
  50%  { transform: rotate(0deg); }
  100% { transform: rotate(-90deg); }
}
/* 改用 JS 判斷觸控 + 直向（CSS 媒體查詢在三星 S Pen 機型不可靠） */
.is-touch.is-portrait .rotate-hint { display: flex; }

/* === 音訊偏好對話框（index.html 載入時） === */
.audio-prompt {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  /* 強制置中：覆蓋 user-agent 預設，避免某些瀏覽器把 <dialog> 貼齊左上 */
  inset: 0;
  margin: auto;
  /* 避免 .audio-prompt-card 的圓角被 dialog 預設的 overflow 切掉視覺陰影 */
  overflow: visible;
}
.audio-prompt::backdrop {
  background: rgba(20, 25, 40, .55);
  backdrop-filter: blur(4px);
}
.audio-prompt-card {
  width: min(440px, calc(100vw - 32px));
  padding: 36px 24px;
  background: linear-gradient(140deg, #FFFFFF 0%, #F5EEDF 100%);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(20, 25, 40, .35), 0 0 0 3px rgba(255, 213, 79, .6);
  text-align: center;
  font-family: 'Noto Sans TC', system-ui, sans-serif;
  color: #2D3436;
  animation: audioPromptIn .35s cubic-bezier(.22, 1, .36, 1);
}
/* 行動裝置橫向 / 矮螢幕：整體壓縮，避免對話框佔滿可視範圍。
   用 class（由 head 中的 JS 即時判斷）+ media query 雙重保險，
   避免不同瀏覽器回報 layout viewport 高度差異造成 max-height 沒命中。 */
@media (max-height: 600px), (orientation: landscape) and (max-width: 1024px) {
  .audio-prompt-card {
    width: min(320px, 80vh, calc(100vw - 24px));
    padding: 10px 18px 10px;
    border-radius: 14px;
    box-shadow: 0 14px 36px rgba(20, 25, 40, .35), 0 0 0 2px rgba(255, 213, 79, .6);
  }
  .audio-prompt-badge {
    width: 36px;
    height: 36px;
    margin-bottom: 4px;
    box-shadow: 0 6px 12px rgba(255, 140, 66, .35), inset 0 -2px 0 rgba(0, 0, 0, .08);
  }
  .audio-prompt-badge svg { width: 18px; height: 18px; transform: translateX(2px); }
  .audio-prompt-title { font-size: 15px; margin-bottom: 4px; letter-spacing: .5px; }
  .audio-prompt-desc { font-size: 11px; line-height: 1.45; margin-bottom: 8px; }
  .audio-prompt-desc br { display: none; }
  .audio-prompt-icon-inline { width: 18px; height: 18px; border-width: 1.5px; }
  .audio-prompt-icon-inline svg { width: 10px; height: 10px; }
  .audio-prompt-actions { gap: 8px; }
  .audio-prompt-btn { padding: 7px 12px; font-size: 13px; max-width: 130px; letter-spacing: .5px; }
}
/* 雙保險：JS 偵測到橫向 + 觸控時也套用同一組壓縮樣式 */
.is-landscape.is-touch .audio-prompt-card {
  width: min(320px, 80vh, calc(100vw - 24px));
  padding: 10px 18px 10px;
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(20, 25, 40, .35), 0 0 0 2px rgba(255, 213, 79, .6);
}
.is-landscape.is-touch .audio-prompt-badge {
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
  box-shadow: 0 6px 12px rgba(255, 140, 66, .35), inset 0 -2px 0 rgba(0, 0, 0, .08);
}
.is-landscape.is-touch .audio-prompt-badge svg { width: 18px; height: 18px; transform: translateX(2px); }
.is-landscape.is-touch .audio-prompt-title { font-size: 15px; margin-bottom: 4px; letter-spacing: .5px; }
.is-landscape.is-touch .audio-prompt-desc { font-size: 11px; line-height: 1.45; margin-bottom: 8px; }
.is-landscape.is-touch .audio-prompt-desc br { display: none; }
.is-landscape.is-touch .audio-prompt-icon-inline { width: 18px; height: 18px; border-width: 1.5px; }
.is-landscape.is-touch .audio-prompt-icon-inline svg { width: 10px; height: 10px; }
.is-landscape.is-touch .audio-prompt-actions { gap: 8px; }
.is-landscape.is-touch .audio-prompt-btn { padding: 7px 12px; font-size: 13px; max-width: 130px; letter-spacing: .5px; }
@keyframes audioPromptIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* 標題上方圓形徽章：黃→橘漸層 + 白色 SVG 音符 */
.audio-prompt-badge {
  width: 78px;
  height: 78px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFD54F 0%, #FF8C42 100%);
  box-shadow: 0 10px 22px rgba(255, 140, 66, .45), inset 0 -3px 0 rgba(0, 0, 0, .08);
  display: grid;
  place-items: center;
  color: #2D3436;
  animation: audioPromptBadgePulse 2s ease-in-out infinite;
}
.audio-prompt-badge svg {
  width: 40px;
  height: 40px;
  display: block;
  /* 音符 path 在 24x24 viewBox 內偏左（x: 3~16），用 translateX 視覺上補回中心 */
  transform: translateX(3px);
  filter: drop-shadow(0 2px 3px rgba(255, 255, 255, .35));
}
@keyframes audioPromptBadgePulse {
  0%, 100% {
    transform: scale(1) rotate(-2deg);
    /* 三層陰影順序需與 50% 對齊；外暈以 blur 為主、spread 設 0，避免出現實心圓邊 */
    box-shadow:
      0 8px 18px rgba(255, 140, 66, .35),
      0 0 0 0 rgba(255, 213, 79, 0),
      inset 0 -3px 0 rgba(0, 0, 0, .08);
  }
  50% {
    transform: scale(1.18) rotate(2deg);
    box-shadow:
      0 16px 32px rgba(255, 140, 66, .6),
      0 0 28px 4px rgba(255, 213, 79, .35),
      inset 0 -3px 0 rgba(0, 0, 0, .08);
  }
}
.audio-prompt-title {
  margin: 0 0 18px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1.5px;
}
.audio-prompt-desc {
  margin: 0 0 36px;
  font-size: 15px;
  line-height: 2;
  letter-spacing: .5px;
  color: #4a4a4a;
}
/* 內文中嵌入的小圖示：完全模仿右上角實際按鈕外觀（圓形、深色邊框、白底） */
.audio-prompt-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0 2px;
  border: 2px solid rgba(27, 36, 51, .6);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #1B2433;
  vertical-align: middle;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12);
}
.audio-prompt-icon-inline svg {
  width: 14px;
  height: 14px;
  display: block;
}
.audio-prompt-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.audio-prompt-btn {
  flex: 1;
  max-width: 180px;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.audio-prompt-btn:hover { transform: translateY(-2px); }
.audio-prompt-btn:active { transform: translateY(0) scale(.97); }
.audio-prompt-btn-primary {
  background: linear-gradient(135deg, #FFD54F 0%, #FF8C42 100%);
  color: #2D3436;
  box-shadow: 0 6px 16px rgba(255, 140, 66, .45);
}
.audio-prompt-btn-secondary {
  background: #E5DDD0;
  color: #2D3436;
}
.audio-prompt-btn-secondary:hover {
  background: #DDD4C6;
}

/* 行動版字體放大：觸控裝置且短邊 < 600px（典型手機橫向） */
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .main-title { font-size: 72px; }
    html.is-touch .sub-title { font-size: 14px; }
    html.is-touch .user-name { font-size: 30px; }
    html.is-touch .user-email { font-size: 24px; }
    html.is-touch .status-text { font-size: 22px; }
    html.is-touch .score-lbl { font-size: 22px; }
    html.is-touch .score-val.rank { font-size: 48px; }
    html.is-touch .lb-btn { font-size: 30px; }
    html.is-touch .card-cat { font-size: 18px; }
    html.is-touch .card-name { font-size: 34px; }
    html.is-touch .card-desc { font-size: 18px; }
    html.is-touch .card-rank,
    html.is-touch .card-pts { font-size: 22px; }
}

/* ===== 總排行榜 modal ===== */
.total-board-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 33, 47, 0.78);
    backdrop-filter: blur(6px);
    padding: 24px;
}
.total-board-overlay.hidden { display: none; }
.total-board-card {
    width: min(560px, 92vw);
    max-height: 88vh;
    max-height: 88dvh;
    background: #fff;
    border-radius: 24px;
    padding: 32px 28px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.total-board-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #1c2a3f;
    font: 700 28px/1 system-ui, sans-serif;
    cursor: pointer;
}
.total-board-close:hover { background: #f1f4f8; }
.total-board-title {
    font: 800 24px "Noto Sans TC", system-ui, sans-serif;
    color: #1c2a3f;
    margin: 0 0 16px;
    text-align: center;
}
.total-board-header {
    display: grid;
    grid-template-columns: 56px 1fr 100px 106px;
    font: 700 13px "Noto Sans TC", system-ui, sans-serif;
    color: #8593a3;
    /* 右側 22px = 資料列的 padding-right 12px + 捲軸溝槽 10px（scrollbar-width: thin）。
       標題列不在捲動容器內，不補這段就會比資料列寬，靠右的欄位跟著錯開。 */
    padding: 8px 22px 8px 12px;
    border-bottom: 1px solid #e6eaf0;
    text-align: left;
}
/* 總分與達成時間兩欄都靠右，與下方資料列的 .score / .achieved 對齊。
   原本只寫 span:last-child，加入達成時間欄之後那條會落在第 4 欄，
   總分反而變回靠左，所以改用明確的欄位序號。 */
.total-board-header span:nth-child(3),
.total-board-header span:nth-child(4) { text-align: right; }
.total-board-list {
    list-style: none;
    padding: 0;
    margin: 0;
    /* flex 1 + min-height 0：在 card 的 max-height 內取剩餘空間，min-height: 0 解開
       flex 子元素的 implicit min-content 限制，讓 overflow-y: auto 可以實際縮小並滾動 */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* iOS Safari：明確宣告允許垂直 pan 手勢（auto 在某些情況會被 transform/iframe 父層覆蓋而失效），
       並用 transform 強制 GPU 層避免動畫期間吃掉手勢 */
    touch-action: pan-y;
    transform: translateZ(0);
    /* 行動版預設會隱藏捲軸，強制顯示以告知使用者可以滾動 */
    scrollbar-width: thin;
    scrollbar-color: rgba(28, 42, 63, 0.4) transparent;
    /* 捲軸溝槽永遠保留，資料量跨過「要不要捲動」的門檻時版面才不會左右跳動。
       標題列在捲動容器外面，靠 .total-board-header 的 padding-right 補上同寬的
       溝槽才對得齊（見該規則）。 */
    scrollbar-gutter: stable;
}
.total-board-list::-webkit-scrollbar {
    width: 6px;
}
.total-board-list::-webkit-scrollbar-thumb {
    background: rgba(28, 42, 63, 0.35);
    border-radius: 3px;
}
.total-board-list::-webkit-scrollbar-thumb:hover {
    background: rgba(28, 42, 63, 0.55);
}
.total-board-list::-webkit-scrollbar-track {
    background: transparent;
}
.total-board-list li {
    display: grid;
    grid-template-columns: 56px 1fr 100px 106px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f3f7;
    font: 500 15px "Noto Sans TC", system-ui, sans-serif;
    color: #1c2a3f;
}
.total-board-list li .rank { font-weight: 800; color: #8593a3; }
.total-board-list li .score { text-align: right; font-weight: 700; color: #0096C7; }
/* 達成時刻：字級刻意小一級，讓名稱欄保有較多寬度。
   色票用 #6b7787 而非名次欄的 #8593a3——後者對白底只有 3.5:1，不到 WCAG AA 的 4.5:1。 */
.total-board-list li .achieved { text-align: right; font-size: 12px; color: #6b7787; white-space: nowrap; }
.total-board-list li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.total-board-list li.is-me {
    background: linear-gradient(90deg, #FFF7E0 0%, #FFFBED 100%);
    border-radius: 10px;
    border-bottom-color: transparent;
}
.total-board-list li.is-me .rank,
.total-board-list li.is-me .score { color: #E6A800; }
/* 權重需高於 .total-board-list li，否則 display / padding / color 都會被它蓋掉。
   display: block 用來解除 grid，避免純文字被當成匿名 grid item 擠進 56px 的名次欄而折行。 */
.total-board-list li.total-board-empty {
    display: block;
    text-align: center;
    color: #8593a3;
    padding: 32px 0;
    font: 500 15px "Noto Sans TC", system-ui, sans-serif;
    border-bottom: 0;
}
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .total-board-title { font-size: 28px; }
    html.is-touch .total-board-header { font-size: 16px; }
    html.is-touch .total-board-list li { font-size: 18px; }
}
@media (max-height: 560px) {
    .total-board-card { max-height: 94vh; padding: 18px 18px 14px; }
    .total-board-title { font-size: 18px; margin-bottom: 10px; }
    .total-board-header { padding: 6px 12px; font-size: 12px; }
    .total-board-list li { padding: 7px 12px; font-size: 14px; }
    .total-board-close { width: 32px; height: 32px; font-size: 24px; }
}

/* ===== 登出按鈕（右上角玩家資訊旁） ===== */
.user-logout {
    width: 36px;
    height: 36px;
    margin-left: 12px;
    border: 0;
    border-radius: 50%;
    background: rgba(45, 52, 54, 0.08);
    color: rgba(45, 52, 54, 0.7);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.user-logout:hover {
    background: rgba(227, 73, 73, 0.15);
    color: #c03030;
}
.user-logout:active {
    transform: scale(.92);
}
.user-logout svg {
    width: 20px;
    height: 20px;
}
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .user-logout { width: 44px; height: 44px; }
    html.is-touch .user-logout svg { width: 24px; height: 24px; }
}

/* ===== 客製確認 modal（登出等） ===== */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 33, 47, 0.78);
    backdrop-filter: blur(6px);
    padding: 24px;
}
.confirm-overlay.hidden { display: none; }
.confirm-card {
    width: min(420px, 92vw);
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.confirm-title {
    font: 800 22px "Noto Sans TC", system-ui, sans-serif;
    color: #1c2a3f;
    margin: 0 0 12px;
}
.confirm-desc {
    font: 500 15px "Noto Sans TC", system-ui, sans-serif;
    color: #5a6878;
    margin: 0 0 24px;
    line-height: 1.6;
}
.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.confirm-btn {
    flex: 1;
    padding: 12px 20px;
    border: 0;
    border-radius: 999px;
    font: 700 16px "Noto Sans TC", system-ui, sans-serif;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}
.confirm-btn:active { transform: scale(.96); }
.confirm-btn-cancel {
    background: #eef1f5;
    color: #1c2a3f;
}
.confirm-btn-cancel:hover { background: #e2e6ec; }
.confirm-btn-danger {
    background: #d8434a;
    color: #fff;
    box-shadow: 0 4px 14px rgba(216, 67, 74, 0.35);
}
.confirm-btn-danger:hover {
    background: #c03030;
    box-shadow: 0 6px 18px rgba(216, 67, 74, 0.45);
}
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .confirm-title { font-size: 26px; }
    html.is-touch .confirm-desc { font-size: 18px; }
    html.is-touch .confirm-btn { font-size: 18px; padding: 14px 20px; }
}

/* ===== Lobby 載入中蓋屏 ===== */
.lobby-loading {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(13, 27, 46, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.lobby-loading.hidden { display: none; }
.lobby-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}
.lobby-loading-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #FFD54F;
    border-radius: 50%;
    animation: lobby-loading-spin 0.9s linear infinite;
}
.lobby-loading-text {
    color: #fff;
    font: 700 18px "Noto Sans TC", system-ui, sans-serif;
    letter-spacing: 2px;
    margin: 0;
}
@keyframes lobby-loading-spin { to { transform: rotate(360deg); } }
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .lobby-loading-text { font-size: 22px; }
}

/* ===== 訪客代碼小連結（lobby 右上） ===== */
.user-code-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    color: #c97700;
    font: 600 12px "Noto Sans TC", system-ui, sans-serif;
    cursor: pointer;
    transition: color .15s ease;
}
.user-code-link:hover { color: #a85e00; text-decoration: underline; }
.user-code-link[hidden] { display: none; }
.user-code-link svg { width: 12px; height: 12px; flex: 0 0 auto; }
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .user-code-link { font-size: 15px; padding: 4px 6px; }
    html.is-touch .user-code-link svg { width: 16px; height: 16px; }
}

/* ===== 訪客代碼 modal ===== */
.guest-code-overlay {
    position: fixed;
    inset: 0;
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(7, 33, 47, 0.78);
    backdrop-filter: blur(6px);
    padding: 24px;
}
.guest-code-overlay.hidden { display: none; }
.guest-code-card {
    width: min(460px, 92vw);
    background: #fff;
    border-radius: 20px;
    padding: 36px 32px 28px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    position: relative;
}
.guest-code-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #1c2a3f;
    font: 700 28px/1 system-ui, sans-serif;
    cursor: pointer;
}
.guest-code-close:hover { background: #f1f4f8; }
.guest-code-title {
    font: 800 22px "Noto Sans TC", system-ui, sans-serif;
    color: #1c2a3f;
    margin: 0 0 8px;
}
.guest-code-desc {
    font: 500 14px "Noto Sans TC", system-ui, sans-serif;
    color: #5a6878;
    margin: 0 0 22px;
    line-height: 1.6;
}
.guest-code-display {
    font: 900 36px "Inter", "Consolas", monospace;
    /* 與登入頁的 .login-issued-code 同色：同一組玩家代碼在兩處顯示，不該有兩種橘。
       原本的 #c97700 對米黃底只有 2.9:1，未達 WCAG 大字 3:1。 */
    color: #a85f00;
    background: linear-gradient(135deg, #FFF7E0 0%, #FFE9A8 100%);
    border: 2px dashed #E6A800;
    border-radius: 14px;
    padding: 22px 18px;
    margin-bottom: 18px;
    letter-spacing: 4px;
    user-select: all;
    word-break: break-all;
}
.guest-code-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    border: 0;
    border-radius: 999px;
    background: #FFD54F;
    color: #1c2a3f;
    font: 800 16px "Noto Sans TC", system-ui, sans-serif;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
    box-shadow: 0 4px 14px rgba(255, 213, 79, 0.4);
}
.guest-code-copy-btn:hover { background: #ffc926; }
.guest-code-copy-btn:active { transform: scale(.97); }
.guest-code-copy-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.guest-code-copy-btn.is-copied {
    background: #2d7a55;
    color: #fff;
    box-shadow: 0 4px 14px rgba(45, 122, 85, 0.4);
}
.guest-code-hint {
    margin: 16px 0 0;
    font: 500 12px "Noto Sans TC", system-ui, sans-serif;
    color: #98a4b3;
}
/* 行動版直向：適度放大 */
@media (max-width: 599px) and (orientation: portrait) {
    html.is-touch .guest-code-title { font-size: 22px; }
    html.is-touch .guest-code-desc { font-size: 15px; }
    html.is-touch .guest-code-display { font-size: 36px; padding: 22px 16px; letter-spacing: 4px; }
    html.is-touch .guest-code-copy-btn { font-size: 17px; padding: 14px 20px; }
    html.is-touch .guest-code-hint { font-size: 13px; }
}
/* 行動版橫向（短高度）：整體壓縮確保整個 modal 塞進畫面 */
@media (max-height: 560px) {
    .guest-code-overlay { padding: 12px; }
    .guest-code-card { padding: 18px 20px 14px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
    .guest-code-close { width: 32px; height: 32px; font-size: 22px; top: 6px; right: 8px; }
    .guest-code-title { font-size: 16px; margin-bottom: 4px; }
    .guest-code-desc { font-size: 12px; margin-bottom: 12px; line-height: 1.4; }
    .guest-code-display { font-size: 22px; padding: 12px 10px; margin-bottom: 12px; letter-spacing: 2px; border-radius: 10px; }
    .guest-code-copy-btn { font-size: 14px; padding: 10px 18px; }
    .guest-code-copy-btn svg { width: 16px; height: 16px; }
    .guest-code-hint { font-size: 11px; margin-top: 10px; }
}

/* ===== 關卡卡片的「查看本關排行榜」按鈕 ===== */
.card-board-btn {
    display: inline-flex;
    align-self: flex-start;
    width: auto;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 10px;
    padding: 6px 14px;
    border: 0;
    border-radius: 999px;
    background: rgba(45, 52, 54, 0.85);
    color: #fff;
    font: 700 12px "Noto Sans TC", system-ui, sans-serif;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease;
}
.card-board-btn:hover {
    background: #1c2a3f;
}
.card-board-btn:active {
    transform: scale(.95);
}
.card-board-btn::before {
    content: '🏆';
    font-size: 13px;
}
@media (max-width: 599px), (max-height: 599px) {
    html.is-touch .card-board-btn { font-size: 16px; padding: 8px 16px; }
    html.is-touch .card-board-btn::before { font-size: 17px; }
}
