/* ============================================================
   狼人殺 · 前端原型
   暗色主題 / 夜晚神秘氛圍（深藍・深紫）
   ============================================================ */

:root {
  color-scheme: dark;

  --bg-top: #101018;
  --bg-bottom: #1a1a2e;
  --panel: #1e1e33;
  --panel-2: #262642;
  --border: #34345a;
  --text: #e9e7f2;
  --text-dim: #9b98b8;
  --text-faint: #55527a;
  --accent: #8b7cf6;
  --accent-deep: #6c5ce7;
  --gold: #f0c674;
  --danger: #e05c6a;

  --font-body: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", "Heiti TC", system-ui, sans-serif;
  --font-display: "Noto Serif TC", "PMingLiU", "Songti TC", "STSong", serif;
  --font-mono: "Consolas", "SF Mono", "Cascadia Mono", monospace;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  /* v6 村莊夜景：深藍夜空漸層（上深下淺，地平線帶紫） */
  background: linear-gradient(180deg, #070b16 0%, #0e1330 38%, #1b2145 62%, #2a2350 74%, #0c1020 100%);
}

/* ---------- 背景裝飾層 ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* 地平線紫暈（v6） */
.sky::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  height: 220px;
  background: radial-gradient(ellipse 70% 100% at 50% 100%, rgba(150, 110, 200, 0.14) 0%, transparent 70%);
}

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

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.25;
  animation: twinkle var(--d, 3s) ease-in-out infinite;
}
.star-warm { background: #ffe9c4; }

@keyframes twinkle {
  0%, 100% { opacity: 0.12; }
  50%      { opacity: 0.9; }
}

/* 月亮（v6：暖金、右上、靜態光暈） */
.moon {
  position: absolute;
  top: 46px;
  right: 110px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fdf6e3 0%, #f5e6bd 45%, #d9c48f 75%, #c9b382 100%);
  box-shadow:
    0 0 50px 20px rgba(255, 250, 200, 0.3),
    0 0 100px 50px rgba(255, 250, 200, 0.12),
    0 0 160px 80px rgba(255, 250, 200, 0.06);
}

/* 村莊夜景 SVG（v6：底部錨定，寬 100%） */
.village-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  pointer-events: none;
}

/* 飄雲（v6） */
.cloud {
  position: absolute;
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(200, 205, 230, 0.14) 0%, transparent 70%);
  filter: blur(6px);
  animation: cloud-drift linear infinite;
}
.cloud-1 { top: 60px; width: 420px; height: 70px; animation-duration: 75s; }
.cloud-2 { top: 130px; width: 300px; height: 50px; animation-duration: 105s; animation-delay: -40s; }
@keyframes cloud-drift {
  0% { left: -450px; }
  100% { left: 100%; }
}

/* 蝙蝠（v6：村莊 SVG 內，緩慢飄動） */
.bat {
  animation: bat-fly 9s ease-in-out infinite;
}
@keyframes bat-fly {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(26px, -12px); }
  50% { transform: translate(52px, 4px); }
  75% { transform: translate(26px, 10px); }
}

/* ---------- 頁面切換 ---------- */
.page { display: none; position: relative; z-index: 1; }
.page.active { animation: pageIn 0.45s ease; }

@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   首頁
   ============================================================ */
#page-home.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  min-height: 100vh;
  padding: 3rem 1.25rem 4rem;
}

.home-header { text-align: center; }

.title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-indent: 0.15em;
  color: #f3f1ea;
  text-shadow: 0 0 32px rgba(139, 124, 246, 0.45), 0 2px 0 rgba(0, 0, 0, 0.4);
}

.subtitle {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin-top: 1.2rem;
}
.divider i {
  display: block;
  width: 90px;
  height: 1px;
}
.divider i:first-child {
  background: linear-gradient(90deg, transparent, var(--accent));
}
.divider i:last-child {
  background: linear-gradient(90deg, var(--accent), transparent);
}
.divider span { font-size: 0.9rem; opacity: 0.8; }

/* --- 進入房間卡片（單欄置中） --- */
.home-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: 420px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.75rem 1.5rem;
  background: linear-gradient(180deg, rgba(38, 38, 66, 0.92), rgba(30, 30, 51, 0.92));
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 124, 246, 0.5);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(139, 124, 246, 0.15);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.card h2::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
}

/* --- 表單欄位 --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.field label {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.field input {
  padding: 0.8rem 0.9rem;
  background: #15152a;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input::placeholder { color: #5c5a7a; }
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.2);
}

.code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
}

.demo-hint {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-faint);
}
.demo-hint code {
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* 版本標籤：置於右下角，低調不搶版面
   用 fixed 相對視窗定位——absolute 會受 #page-home 的 flex 靜態置中影響而跑回中間 */
.home-footer {
  position: fixed;
  bottom: 1.25rem;
  right: 1.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  color: var(--text-faint);
}

/* ============================================================
   按鈕
   ============================================================ */
.btn {
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease,
              background 0.18s ease, border-color 0.18s ease,
              color 0.18s ease, filter 0.18s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #8b7cf6, #6c5ce7);
  box-shadow: 0 6px 18px rgba(108, 92, 231, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 10px 26px rgba(108, 92, 231, 0.5);
}

/* 建立／加入按鈕列：代碼輸入框與「建立房間」共用同一個 grid 格，
   隱藏建立按鈕、顯示代碼輸入框時版面不位移 */
.entry-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
#btn-create { grid-column: 1; grid-row: 1; }
#btn-join { grid-column: 1; grid-row: 2; }
.join-code-slot { grid-column: 1; grid-row: 1; }
.join-code-slot input {
  width: 100%;
  padding: 0.85rem 0.9rem; /* 與按鈕同高，取代時無縫 */
  background: #15152a;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.join-code-slot input::placeholder { color: #5c5a7a; }
.join-code-slot input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.2);
}

/* 取消加入：代碼框右緣的小 ✕（absolute 定位，出現／消失不佔版面、零位移） */
.join-code-slot { position: relative; }
#btn-cancel-join {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(139, 124, 246, 0.08);
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
#btn-cancel-join:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(139, 124, 246, 0.18);
}

/* 代碼輸入框出現／建立按鈕回來：輕微滑入過渡 */
@keyframes slotIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: none; }
}
.join-code-slot:not([hidden]) { animation: slotIn 0.25s ease; }
#btn-create:not([hidden]) { animation: slotIn 0.25s ease; }

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(139, 124, 246, 0.08);
}

.btn-leave {
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
}

/* 開始遊戲：醒目金色大按鈕 */
.btn-start {
  width: 100%;
  padding: 1.1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0c674, #e09b3d);
  color: #241a08;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-indent: 0.25em;
  box-shadow: 0 8px 24px rgba(224, 155, 61, 0.3);
  animation: startPulse 2.6s ease-in-out infinite;
}
.btn-start:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 12px 32px rgba(224, 155, 61, 0.5);
}

@keyframes startPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(224, 155, 61, 0.3); }
  50%      { box-shadow: 0 8px 34px rgba(224, 155, 61, 0.55); }
}

/* ============================================================
   房間 / Lobby
   ============================================================ */
#page-room.active {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- 頂欄 --- */
.room-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: rgba(18, 18, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.room-code { display: flex; flex-direction: column; }
.room-code .label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}
.room-code .code {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(240, 198, 116, 0.35);
}

.room-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* 身分切換：參戰／觀戰（分段按鈕，高亮目前身分） */
.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--panel-2);
}
.mode-btn {
  padding: 0.35rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.player-count {
  padding: 0.4rem 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.player-count b {
  color: var(--accent);
  font-weight: 700;
}

/* --- 三欄主體 --- */
.room-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: 1rem;
  padding: 1rem 1.25rem 1.25rem;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: rgba(30, 30, 51, 0.92);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.panel > h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

/* --- 玩家列表（分組） --- */
.player-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.player-section-label {
  padding: 0.4rem 1.1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  opacity: 0.7;
  border-bottom: 1px solid var(--border);
}
.player-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem;
  list-style: none;
  overflow-y: auto;
}

.player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.player:hover { border-color: rgba(139, 124, 246, 0.4); }
.player.you {
  border-color: rgba(139, 124, 246, 0.55);
  background: linear-gradient(90deg, rgba(139, 124, 246, 0.14), var(--panel-2));
}

.avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.05rem;
}

.player .name {
  flex: 1;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crown { font-size: 1rem; }

.kick {
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.18s, background 0.18s, border-color 0.18s, color 0.18s;
}
.player:hover .kick { opacity: 1; }
.kick:hover {
  color: #fff;
  background: rgba(224, 92, 106, 0.25);
  border-color: var(--danger);
}

/* --- 聊天 --- */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
  overflow-y: auto;
}

.msg { max-width: 85%; }
.msg-you { align-self: flex-end; text-align: right; }

.msg-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.msg-you .msg-head { flex-direction: row-reverse; }

.msg-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #6b6890;
}
.msg-nick {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.msg-you .msg-nick { color: var(--gold); }

.msg-text {
  display: inline-block;
  text-align: left;
  padding: 0.55rem 0.8rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-you .msg-text {
  background: rgba(139, 124, 246, 0.16);
  border-color: rgba(139, 124, 246, 0.35);
  border-radius: 12px 4px 12px 12px;
}

.chat-input {
  display: flex;
  gap: 0.6rem;
  padding: 0.8rem;
  border-top: 1px solid var(--border);
}
.chat-input input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  background: #15152a;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input input::placeholder { color: #5c5a7a; }
.chat-input input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 124, 246, 0.18);
}

/* --- 房間設定 --- */
.settings-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.1rem;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.setting label {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.setting-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 75%), #34345a var(--fill, 75%));
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 0 10px rgba(139, 124, 246, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 0 10px rgba(139, 124, 246, 0.5);
  cursor: pointer;
}

.range-value {
  min-width: 2.4rem;
  padding: 0.3rem 0.4rem;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}

.hint {
  font-size: 0.8rem;
  line-height: 1.5;
  color: #6b6890;
}

/* 隨機人數 toggle（開啟→滑桿禁用、值視為上限；實際人數開局才擲出） */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #34345a;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch input:checked + .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}
.switch-text {
  font-size: 0.9rem;
  color: var(--text-dim);
}
.random-hint {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-faint);
}
/* 滑桿停用（隨機開啟時） */
input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
input[type="range"]:disabled::-webkit-slider-thumb { cursor: not-allowed; }
input[type="range"]:disabled::-moz-range-thumb { cursor: not-allowed; }

/* 空狀態（不塞假資料，只顯示中性提示） */
.chat-empty {
  padding: 0.5rem 0.25rem;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.player-empty {
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* 停用狀態（觀戰中的聊天輸入） */
.chat-input input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn:disabled:hover {
  transform: none;
  filter: none;
}

.note-box {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ============================================================
   過渡畫面（Loading / 房間已滿）
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 8, 16, 0.72);
  backdrop-filter: blur(6px);
}

.overlay-box {
  width: 380px;
  max-width: 92vw;
  padding: 2.25rem 2.5rem;
  text-align: center;
  background: linear-gradient(180deg, #262642, #1e1e33);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  animation: boxIn 0.3s ease;
}

@keyframes boxIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

.overlay-box p {
  color: var(--text-dim);
  line-height: 1.6;
}

.overlay-title {
  margin-bottom: 0.4rem;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 1.1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   捲軸
   ============================================================ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #3a3a5e;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #4a4a72; }

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 1080px) {
  .room-grid {
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .panel-settings { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .home-cards {
    grid-template-columns: 1fr;
    max-width: 400px;
  }

  .room-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
  }
  .panel-settings { grid-column: auto; }
  .panel-players { max-height: 240px; }
  .panel-chat {
    height: 55vh;
    min-height: 340px;
  }

  .room-topbar { flex-wrap: wrap; gap: 0.6rem; }
  .room-code .code { font-size: 1.3rem; }

  .moon {
    width: 70px;
    height: 70px;
    top: 5%;
    right: 6%;
  }
}

/* 減少動態偏好：停用所有動畫 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
