/* 外框：舞台背景、狀態列、按鍵提示、過場幕、提示訊息 */

/* ---------- 背景：夜色極光＋所選遊戲主視覺 ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-3) 0%, var(--bg-2) 45%, var(--bg) 100%);
}
/* 慢慢飄移的紫／黃極光 */
.bg-aurora span {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
  animation: aurora 26s ease-in-out infinite alternate;
}
.bg-aurora span:nth-child(1) { width: 60vmax; height: 60vmax; left: -18vmax; top: -24vmax; background: #5b2fa3; }
.bg-aurora span:nth-child(2) { width: 46vmax; height: 46vmax; right: -16vmax; top: 10vmax; background: #3d1f78; animation-duration: 32s; animation-delay: -8s; }
.bg-aurora span:nth-child(3) { width: 38vmax; height: 38vmax; left: 30vw; bottom: -26vmax; background: #a8781c; opacity: .32; animation-duration: 38s; animation-delay: -16s; }

/* 主視覺：兩層交叉淡入＋緩慢推鏡 */
.stage-art { position: absolute; inset: 0; opacity: 0; transition: opacity .8s var(--ease); }
body[data-screen="lobby"] .stage-art { opacity: 1; }
.stage-art-layer {
  position: absolute; inset: -3%;
  background-size: cover; background-position: 70% 40%;
  opacity: 0; transition: opacity .7s ease;
  animation: kenburns 28s ease-in-out infinite alternate;
}
.stage-art-layer.is-front { opacity: 1; }
.stage-art::after {
  /* 讓文字清楚：左邊、底部、頂部漸暗 */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 7, 23, .94) 0%, rgba(13, 7, 23, .78) 28%, rgba(13, 7, 23, .2) 58%, rgba(13, 7, 23, 0) 75%),
    linear-gradient(0deg, rgba(13, 7, 23, .96) 0%, rgba(13, 7, 23, .55) 24%, rgba(13, 7, 23, 0) 48%),
    linear-gradient(180deg, rgba(13, 7, 23, .82) 0%, rgba(13, 7, 23, 0) 26%);
}
.stage-art.is-locked .stage-art-layer { filter: grayscale(.85) brightness(.75); }

.bg-wash {
  position: absolute; inset: -10%;
  color: var(--purple);
  background: radial-gradient(40% 50% at 70% 45%, currentColor, transparent 70%);
  opacity: .14; mix-blend-mode: screen;
  transition: color .7s var(--ease);
}
/* 細小光點 */
.bg-sparks {
  position: absolute; inset: 0; opacity: .5;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff, transparent),
    radial-gradient(1px 1px at 28% 68%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 46% 34%, #ffe8a3, transparent),
    radial-gradient(1px 1px at 63% 82%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 78% 18%, #fff, transparent),
    radial-gradient(1px 1px at 90% 56%, #ffe8a3, transparent);
  animation: twinkle 6s ease-in-out infinite alternate;
}
body[data-screen="lobby"] .bg-sparks { opacity: .18; }
.bg-vignette { position: absolute; inset: 0; background: radial-gradient(120% 100% at 50% 40%, transparent 55%, rgba(0, 0, 0, .55) 100%); }

/* ---------- 版面 ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: var(--status-h) minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
.stage { position: relative; min-height: 0; outline: none; }
.screen { min-height: 100%; min-width: 0; }
body[data-busy] .stage, body[data-busy] .statusbar { pointer-events: none; }
@media (min-width: 761px) and (min-height: 560px) {
  .app { height: 100vh; height: 100dvh; }
  .stage { overflow-y: auto; overflow-x: hidden; }
  .screen { height: 100%; }
}

/* ---------- 狀態列 ---------- */
.statusbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 var(--gutter); position: relative; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 42px; height: 46px; object-fit: contain; flex: none; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .5)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-school { font-size: 12px; color: var(--text-3); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-title { font-size: 20px; font-weight: 900; letter-spacing: .12em; }
.brand-title b { font-weight: 900; color: var(--yellow); }

.status-tray { display: flex; align-items: center; gap: 6px; }
.mode-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 900; padding: 6px 12px 6px 10px; border-radius: 999px;
  background: var(--yellow-100); color: #ffe7a1; white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(247, 208, 84, .35);
}
.mode-badge svg { width: 17px; height: 17px; }
.mode-badge[data-mode="production"] { background: var(--purple-100); color: #e6d9ff; box-shadow: inset 0 0 0 1px rgba(154, 114, 220, .45); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 3px 16px 3px 3px; border-radius: 999px;
  border: 0; background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--stroke-2);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background-color .2s, box-shadow .2s;
}
.user-chip:hover { background: rgba(255, 255, 255, .2); }
.user-chip:focus-visible { outline: none; box-shadow: var(--glow-focus); }
.user-chip-avatar { width: 40px; height: 40px; flex: none; }
.user-chip strong { font-size: 15px; font-weight: 900; max-width: 9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net-status { display: inline-grid; place-items: center; width: 34px; color: var(--ok); }
.net-status svg { width: 20px; height: 20px; }
.net-status[data-online="false"] { color: var(--danger); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--text);
  transition: background-color .2s, transform .2s var(--ease);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.9); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--glow-focus); }
.icon-btn[aria-pressed="true"] { color: var(--danger); }
.clock { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; letter-spacing: .02em; padding: 0 4px 0 10px; }

/* 頭像：圓形插畫 */
.avatar { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: var(--surface-solid-2); box-shadow: 0 12px 26px -12px rgba(0, 0, 0, .7); }
.avatar svg { width: 100%; height: 100%; }
.avatar-animal { background: var(--avatar-bg, var(--purple-100)); }
.avatar-animal img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.avatar-initial { color: var(--on-yellow); font-weight: 900; font-size: 40px; font-size: 44cqw; background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .7), transparent 46%), linear-gradient(150deg, color-mix(in srgb, var(--avatar-bg, var(--yellow)) 70%, #fff), var(--avatar-bg, var(--yellow))); }
.user-chip-avatar .avatar-initial { font-size: 17px; }
.login-avatar .avatar-initial { font-size: 46px; }

/* ---------- 底部按鍵提示（手掣／鍵盤圖示） ---------- */
.hintbar {
  height: var(--hint-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--gutter);
  font-size: 13px; color: var(--text-2);
  background: linear-gradient(0deg, rgba(13, 7, 23, .7), transparent);
}
.hint-keys, .hint-note { display: flex; align-items: center; gap: 26px; }
.hint { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.hint > svg { width: 20px; height: 20px; color: var(--text); }
.hint-note .hint svg { width: 17px; height: 17px; }

/* ---------- 過場幕 ---------- */
.curtain { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg); color: var(--text); visibility: hidden; opacity: 0; pointer-events: none; }
.curtain::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 50% at 50% 50%, rgba(154, 114, 220, .25), transparent 70%); }
.curtain.is-on { visibility: visible; opacity: 1; pointer-events: auto; }
.curtain.is-leaving { pointer-events: none; }
.curtain.use-disc { background: transparent; }
.curtain.use-disc::before { display: none; }
/* 開機：光由電源鍵擴散 */
.curtain-disc { position: fixed; left: 50%; top: 50%; width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle, #fffbe9 0%, #ffe9a6 35%, var(--yellow) 70%, #e2a92c 100%); display: none; transform: translate(-50%, -50%) scale(0); }
.curtain.use-disc .curtain-disc { display: block; transform: translate(-50%, -50%) scale(var(--disc-scale, 80)); }
.curtain.use-disc .curtain-content { color: var(--on-yellow); }
.curtain-content { position: relative; text-align: center; padding: 24px; }
.curtain-loader { display: flex; justify-content: center; gap: 12px; height: 40px; align-items: flex-end; }
.curtain-loader span { width: 14px; height: 14px; border-radius: 50%; background: var(--yellow); animation: bounce-dot 1s ease-in-out infinite; box-shadow: 0 0 16px rgba(247, 208, 84, .6); }
.curtain-loader span:nth-child(2) { background: #c7a8ff; box-shadow: 0 0 16px rgba(199, 168, 255, .6); animation-delay: .12s; }
.curtain-loader span:nth-child(3) { background: #fff; box-shadow: 0 0 16px rgba(255, 255, 255, .6); animation-delay: .24s; }
.curtain.use-disc .curtain-loader span { background: var(--purple-800); box-shadow: none; }
.curtain-text { margin-top: 16px; font-size: 22px; font-weight: 900; letter-spacing: .24em; }

/* ---------- 提示訊息 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--hint-h) + 18px); z-index: 70;
  max-width: min(90vw, 560px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; border-radius: 999px;
  background: rgba(30, 20, 50, .92); color: var(--text); border: 0;
  box-shadow: inset 0 0 0 1px var(--stroke-2), var(--shadow-soft);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  font-size: 15px; font-weight: 900; text-align: center;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.toast svg { width: 20px; height: 20px; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="warn"] { box-shadow: inset 0 0 0 1px rgba(255, 138, 160, .6), var(--shadow-soft); }
.toast[data-tone="warn"] svg { color: var(--danger); }
.toast[data-tone="ok"] { background: var(--yellow); color: var(--on-yellow); box-shadow: 0 14px 34px -12px rgba(247, 208, 84, .6); }

@media (max-width: 1100px) { .clock { display: none; } }
@media (max-width: 760px) {
  .brand-logo { width: 34px; height: 38px; }
  .brand-school { font-size: 11px; max-width: 48vw; white-space: normal; line-height: 1.3; }
  .brand-title { font-size: 17px; }
  .mode-badge span, .user-chip strong { display: none; }
  .mode-badge { padding: 6px; }
  .user-chip { padding: 2px; height: 40px; }
  .user-chip-avatar { width: 34px; height: 34px; }
  .status-tray { gap: 0; }
  .icon-btn { width: 36px; height: 36px; }
  .net-status { width: 30px; }
  .hintbar { display: none; }
  .toast { bottom: 100px; }
  .stage-art-layer { background-position: 62% 30%; }
  .stage-art::after { background: linear-gradient(0deg, rgba(13, 7, 23, .97) 35%, rgba(13, 7, 23, .78) 60%, rgba(13, 7, 23, .55) 100%); }
}
