/* ============================================================
   劇本殺平台 — 全域樣式（暗黑推理主題）
   圖片替換提示：搜尋 /* IMG: 開頭的註解，那裡可以換成 GPT/Gemini 生成的圖片
   ============================================================ */

:root {
  --bg:        #0d0d1a;
  --surface:   #16162a;
  --card:      #1e1e35;
  --border:    #2e2e50;
  --accent:    #c94040;
  --accent2:   #e8b84b;
  --text:      #e8e8f0;
  --text-muted:#8888aa;
  --green:     #3dba6f;
  --blue:      #4a90d9;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'Segoe UI', '微軟正黑體', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── 通用元件 ── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 22px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.18s; text-decoration: none;
}
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: #e05050; transform: translateY(-1px); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-gold    { background: var(--accent2); color: #111; }
.btn-gold:hover { background: #f5c860; }
.btn-green   { background: var(--green); color: #fff; }
.btn-green:hover { background: #4acc7d; }
.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.input {
  width: 100%; padding: 10px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; transition: border-color 0.18s;
}
.input:focus { outline: none; border-color: var(--accent2); }
.input::placeholder { color: var(--text-muted); }

.label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; display: block; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.badge-pending  { background: #4a2e00; color: #f5c860; }
.badge-approved { background: #003a1a; color: #4acc7d; }
.badge-rejected { background: #3a0000; color: #f07070; }
.badge-admin    { background: #1a0a3a; color: #a08af0; }
.badge-playing  { background: #003060; color: #70b0f0; }
.badge-waiting  { background: #1e1e35; color: var(--text-muted); }

.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 14px;
}
.alert-error  { background: #3a0000; border-left: 3px solid var(--accent); color: #f07070; }
.alert-success{ background: #003a1a; border-left: 3px solid var(--green); color: #4acc7d; }
.alert-info   { background: #001840; border-left: 3px solid var(--blue); color: #70b0f0; }
.alert-warn   { background: #3a2000; border-left: 3px solid var(--accent2); color: var(--accent2); }

.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 4px;
       font-size: 11px; font-weight: 600; background: var(--surface); color: var(--text-muted); }

/* ── 導覽列 ── */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.navbar-brand { font-size: 18px; font-weight: 700; color: var(--accent2); letter-spacing: .05em; text-decoration: none; }
.navbar-user  { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--border);
          display: flex; align-items: center; justify-content: center; font-size: 16px; }

/* ── 彈出視窗 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal { background: var(--card); border: 1px solid var(--border);
         border-radius: 14px; padding: 28px; max-width: 460px; width: 100%;
         box-shadow: var(--shadow); }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ── 登入/註冊頁 ── */
.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  /* IMG: 這裡可以換成 GPT/Gemini 生成的背景圖片，改成：background: url('img/bg.jpg') center/cover; */
  background: radial-gradient(ellipse at 30% 60%, #1a0a2e 0%, var(--bg) 60%);
  padding: 20px;
}
.auth-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 36px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-logo {
  text-align: center; font-size: 48px; margin-bottom: 8px;
  /* IMG: 換成你的 Logo 圖片 <img src="img/logo.png" style="width:80px"> */
}
.auth-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--accent2); margin-bottom: 4px; }
.auth-sub   { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.auth-tabs  { display: flex; margin-bottom: 20px; background: var(--surface); border-radius: var(--radius); padding: 4px; }
.auth-tab   { flex: 1; text-align: center; padding: 8px; border-radius: 7px; font-size: 13px;
              font-weight: 600; cursor: pointer; color: var(--text-muted); transition: all 0.18s; }
.auth-tab.active { background: var(--card); color: var(--text); }

/* ── 大廳 ── */
.lobby-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; padding: 20px; max-width: 1100px; margin: 0 auto; }
@media (max-width: 768px) { .lobby-grid { grid-template-columns: 1fr; } }

.script-list { display: flex; flex-direction: column; gap: 12px; }
.script-card {
  background: var(--card); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 16px; cursor: pointer; transition: all 0.18s;
  display: flex; gap: 14px; align-items: flex-start;
}
.script-card:hover { border-color: var(--accent2); transform: translateX(3px); }
.script-card.selected { border-color: var(--accent2); background: #1e1e2e; }
.script-cover { font-size: 40px; min-width: 52px; text-align: center;
                /* IMG: 換成 GPT/Gemini 生成的腳本封面圖 <img src="..." style="width:52px;border-radius:6px"> */ }
.script-info { flex: 1; }
.script-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.script-desc  { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.script-meta  { display: flex; gap: 8px; flex-wrap: wrap; }

.room-panel { display: flex; flex-direction: column; gap: 14px; }

/* ── 遊戲房間 ── */
.room-layout  { display: grid; grid-template-columns: 280px 1fr; grid-template-rows: auto 1fr; gap: 0; height: 100vh; }
.room-sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.room-main    { display: flex; flex-direction: column; overflow: hidden; }
.room-header  { padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--border);
                display: flex; align-items: center; gap: 12px; }

.chat-area  { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-input-row { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.message { max-width: 85%; }
.message-gm     { background: #1a0a00; border: 1px solid #4a2e00; border-radius: var(--radius);
                  padding: 10px 14px; color: var(--accent2); font-style: italic; max-width: 100%; }
.message-system { text-align: center; color: var(--text-muted); font-size: 12px; }
.message-player { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.message-player.own { background: #001830; border-color: var(--blue); align-self: flex-end; }
.message-name   { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.message-text   { font-size: 14px; }

.player-list { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.player-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
               border-radius: 8px; background: var(--card); border: 1px solid var(--border); }
.player-emoji { font-size: 22px; }
.player-name  { font-size: 13px; font-weight: 600; }
.player-role  { font-size: 11px; color: var(--text-muted); }
.player-active { border-color: var(--accent2); background: #1a1a00; }

/* ── 遊戲階段區塊 ── */
.phase-block  { padding: 20px; flex: 1; overflow-y: auto; }
.phase-title  { font-size: 20px; font-weight: 700; color: var(--accent2); margin-bottom: 4px; }
.phase-desc   { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

.role-card {
  background: linear-gradient(135deg, #1a0a2e, #2e1a0a);
  border: 2px solid var(--accent2); border-radius: 14px; padding: 24px; max-width: 500px;
  /* IMG: 可以加入角色圖片 */
}
.role-emoji { font-size: 56px; text-align: center; margin-bottom: 12px; }
.role-name  { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 16px; }

.location-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.location-card {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; cursor: pointer; transition: all 0.18s;
}
.location-card:hover:not(.disabled) { border-color: var(--accent2); transform: translateY(-2px); }
.location-card.disabled { opacity: 0.4; cursor: not-allowed; }
.location-card.visited  { border-color: var(--green); background: #001a0a; }
.location-emoji { font-size: 32px; margin-bottom: 8px; }
.location-name  { font-size: 13px; font-weight: 600; }

.clue-card {
  background: #1a1000; border: 1px solid #4a3000; border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.clue-name { font-size: 14px; font-weight: 700; color: var(--accent2); margin-bottom: 4px; }
.clue-desc { font-size: 13px; color: var(--text); }

.vote-option {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; cursor: pointer; transition: all 0.18s; display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.vote-option:hover:not(.voted) { border-color: var(--accent2); }
.vote-option.selected { border-color: var(--accent); background: #1a0000; }

.timer-bar { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 14px; overflow: hidden; }
.timer-fill { height: 100%; background: var(--accent2); border-radius: 3px; transition: width 1s linear; }
.timer-fill.urgent { background: var(--accent); }

/* ── 管理後台 ── */
.admin-tabs { display: flex; gap: 4px; padding: 14px 20px 0; }
.admin-tab  { padding: 8px 18px; border-radius: 8px 8px 0 0; font-size: 13px; font-weight: 600;
              cursor: pointer; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); }
.admin-tab.active { background: var(--card); color: var(--text); border-bottom-color: var(--card); }
.admin-content { background: var(--card); border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) var(--radius); margin: 0 20px 20px; padding: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--surface); padding: 10px 12px; text-align: left; color: var(--text-muted);
     font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.03); }

/* ── 讀取動畫 ── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border);
           border-top-color: var(--accent2); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(13,13,26,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 300; flex-direction: column; gap: 14px;
}

/* ── 捲軸美化 ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4e4e70; }

/* ── 響應式 ── */
@media (max-width: 640px) {
  .room-layout { grid-template-columns: 1fr; }
  .room-sidebar { display: none; }
  .location-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 動畫 ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,64,64,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(201,64,64,0); }
}
.pulse { animation: pulse-glow 2s infinite; }

/* ── Setup 頁 ── */
.setup-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.setup-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 36px; width: 100%; max-width: 480px; }
.setup-step { display: flex; gap: 12px; margin-bottom: 16px; padding: 14px; background: var(--surface); border-radius: var(--radius); }
.setup-num { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.setup-step-body { flex: 1; font-size: 13px; }
.setup-step-title { font-weight: 700; margin-bottom: 4px; }
.setup-step-desc { color: var(--text-muted); line-height: 1.6; }

/* ══════════════════════════════════════════════
   手機版響應式補強 (max-width: 600px)
   ══════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* 導覽列：縮小間距，隱藏長文字 */
  .navbar { padding: 10px 14px; }
  .navbar-brand { font-size: 15px; }
  .navbar-user  { gap: 8px; font-size: 12px; }
  .navbar-user span { display: none; }   /* 隱藏暱稱文字，只留頭像 */
  .btn-ghost.btn-sm { padding: 5px 10px; font-size: 12px; }

  /* 登入頁 */
  .auth-box { padding: 24px 18px; }
  .auth-logo { font-size: 36px; }
  .auth-title { font-size: 18px; }

  /* 大廳：讓腳本卡片排列更緊湊 */
  .lobby-grid { padding: 12px; gap: 12px; }
  .script-card { padding: 12px; gap: 10px; }
  .script-cover { font-size: 32px; min-width: 42px; }
  .script-title { font-size: 14px; }
  .room-panel .card { padding: 14px; }

  /* 管理後台：tabs 改小字，表格可橫捲 */
  .admin-tabs { padding: 10px 10px 0; gap: 2px; flex-wrap: wrap; }
  .admin-tab  { padding: 6px 12px; font-size: 12px; }
  .admin-content { margin: 0 10px 14px; padding: 14px; border-radius: var(--radius); }
  .admin-content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 遊戲房間：sidebar 隱藏已有，main 全寬 */
  .room-layout { height: auto; min-height: 100vh; }
  .room-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .phase-block { padding: 14px; }
  .role-card   { padding: 18px; }
  .role-emoji  { font-size: 44px; }

  /* Modal 在手機填滿螢幕 */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 14px 14px 0 0; padding: 22px 18px; max-width: 100%; }

  /* 按鈕行：讓操作區換行 */
  .flex-wrap-mobile { flex-wrap: wrap; }

  /* 個人資料頁 */
  .profile-grid { grid-template-columns: 1fr !important; }
  .profile-avatar-section { flex-direction: column; align-items: center; text-align: center; }
}

/* ══════════════════════════════════════════════
   審核有效期倒數提示條
   ══════════════════════════════════════════════ */
.expiry-banner {
  background: #3a2000; border-bottom: 2px solid var(--accent2);
  padding: 10px 20px; font-size: 13px; color: var(--accent2);
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.expiry-banner.urgent {
  background: #3a0000; border-color: var(--accent); color: #f07070;
}
