@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@400;600;700;800&family=Righteous&display=swap');

:root {
  color-scheme: light;
  --primary: #0f7a62;
  --primary-light: #1a9a7c;
  --primary-hover: #0b5e4b;
  --bg-color: rgba(241, 248, 252, 0.92);
  --panel-bg: rgba(255, 255, 255, 0.94);
  --card-bg: rgba(255, 255, 255, 0.94);
  --input-bg: #fcfcfc;
  --text-main: #1a2a3a;
  --text-muted: #4a5d70;
  --border: rgba(90, 140, 180, 0.28);
  --success: #10b981;
  --danger: #ef4444;
  --halo: #eef6fb;
  --chip-bg: #e8f4ef;
  --chip-fg: #0f7a62;
  --lamp: #e8a04a;
}
body { font-family: 'Pretendard', sans-serif; background: transparent; color: var(--text-main); display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; height: auto; margin: 0; padding: 40px 0; overflow-y: auto; box-sizing: border-box; position: relative; isolation: isolate; }
#app-container { position: relative; z-index: 1; }
.panel { background: var(--panel-bg); padding: 30px; border-radius: 24px; box-shadow: 0 20px 50px rgba(20, 50, 80, 0.12), 0 0 0 1px rgba(255,255,255,0.55) inset; width: min(720px, 92vw); box-sizing: border-box; transition: box-shadow 0.3s ease, background 0.3s ease; }
#login-screen { width: 420px; text-align: center; background: transparent; box-shadow: none; }
/* 게임 화면만 조금 더 넓게. 양옆 광고 자리를 남기려고 88vw로 제한 */
#game-screen { width: min(900px, 88vw); }

.logo-area { margin-bottom: 30px; text-align: center; }
.logo-mark { width: 3.2rem; height: 3.2rem; display: block; margin: 0 auto 0.85rem; border-radius: 0.7rem; }
.logo-area h1 {
  margin: 0;
  font-size: 32px;
  color: var(--primary);
  font-family: 'Righteous', sans-serif;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 1px;
  text-shadow:
    0 0 10px var(--halo),
    0 0 4px var(--halo),
    1px 0 0 var(--halo),
    -1px 0 0 var(--halo),
    0 1px 0 var(--halo),
    0 -1px 0 var(--halo),
    1px 1px 0 var(--halo),
    -1px 1px 0 var(--halo);
}
.logo-area .logo-sub { font-size: 22px; margin-top: 5px; }
.logo-area p,
#login-screen p {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  text-shadow:
    0 0 8px var(--halo),
    1px 0 0 var(--halo),
    -1px 0 0 var(--halo),
    0 1px 0 var(--halo),
    0 -1px 0 var(--halo);
}

.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.4s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.form-group { display: flex; flex-direction: column; gap: 12px; }
.form-group label { font-size: 14px; font-weight: 600; color: var(--text-main); text-align: left; }
input { padding: 14px; border: 2px solid var(--border); border-radius: 12px; font-size: 15px; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease; font-family: inherit; background: var(--input-bg); color: var(--text-main);}
input:focus { border-color: var(--primary-light); background: var(--card-bg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
#nickname-input { font-size: 16px; font-weight: 600; text-align: center; letter-spacing: 0.5px; padding: 16px; }
#nickname-input::placeholder { color: #94a3b8; font-weight: 400; letter-spacing: normal; }
#nickname-input:focus { color: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.12); border-color: var(--primary); }
button { padding: 14px 20px; border: none; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease; font-family: inherit;}
button:active { transform: translateY(2px) !important; }
.primary-btn { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fffef9; box-shadow: 0 4px 15px color-mix(in srgb, var(--primary) 32%, transparent); }
.primary-btn:hover { box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 42%, transparent); transform: translateY(-2px); }
.secondary-btn { background-color: var(--card-bg); border: 2px solid var(--border); color: var(--text-main); }
.secondary-btn:hover { background-color: var(--bg-color); }
.small-btn { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.header-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 2px solid var(--bg-color); padding-bottom: 15px;}
.header-info h2 { margin: 0; font-size: 20px; }
.user-badge { background: var(--bg-color); padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: 700; color: var(--primary); }
.room-status { font-size: 13px; font-weight: 800; color: var(--chip-fg); background: var(--chip-bg); padding: 4px 10px; border-radius: 12px;}
.round-chip { background: #fef08a; color: #854d0e; }

.split-layout { display: flex; gap: 20px; }
.main-area { flex: 1.5; display: flex; flex-direction: column; gap: 15px; }
.side-area { flex: 1; display: flex; flex-direction: column; gap: 15px; }

.user-list-box, .room-list-box { background: var(--bg-color); border-radius: 12px; padding: 15px; flex: 1; display: flex; flex-direction: column; }
.user-list-box h3, .room-header h3 { margin: 0 0 10px 0; font-size: 14px; color: var(--text-muted); }
.room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.room-header h3 { margin: 0; }
.resize-hint { color: var(--text-muted); font-size: 11px; font-weight: 600; user-select: none; }

/* 각 박스 아래 손잡이를 끌어 높이 조절 */
.lobby-room-panel { height: 340px; overflow: hidden; box-sizing: border-box; }
.lobby-room-panel .room-list { min-height: 60px; max-height: none !important; }
.lobby-chat-panel { height: 320px; overflow: hidden; box-sizing: border-box; display: flex; flex-direction: column; }
.lobby-chat-panel .chat-history { flex: 1; min-height: 70px; height: auto !important; }
.game-chat-panel { height: 430px; }

.panel-resize-handle { height: 16px; margin: 6px 0 14px; border-radius: 10px; background: var(--bg-color); border: 1px solid var(--border); cursor: ns-resize; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; transition: background 0.15s ease, border-color 0.15s ease; }
.panel-resize-handle:hover, .panel-resize-handle.is-dragging { background: var(--chip-bg); border-color: var(--primary-light); }
.panel-resize-handle::before { content: ""; width: 54px; height: 4px; border-radius: 2px; background: var(--text-muted); }
.panel-resize-handle:hover::before, .panel-resize-handle.is-dragging::before { background: var(--primary); }

#lobby-user-list { list-style: none; padding: 0; margin: 0; font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
#lobby-user-list li { background: var(--card-bg); padding: 8px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.04); color: var(--text-main); }

.room-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--bg-color);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.option-group-box {
  grid-column: span 2;
  background: var(--bg-color);
  padding: 15px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
}

.room-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; max-height: 400px; }
.room-list li { background: var(--card-bg); padding: 12px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); display: flex; justify-content: space-between; align-items: center; font-size: 14px; border: 2px solid var(--border); transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease; }
.room-list li:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,0.08); border-color: var(--primary-light); }
.room-info { display: flex; flex-direction: column; gap: 4px; }
.room-list li .room-name { font-weight: 700; color: var(--text-main); font-size: 15px;}
.room-list li .room-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 8px; align-items: center;}
.player-state { margin-left: 6px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.player-ready { color: #047857; background: #d1fae5; }
.player-waiting { color: #92400e; background: #fef3c7; }
.status-badge { padding: 3px 6px; border-radius: 4px; font-size: 11px; font-weight: 800; }
.status-playing { background: #fee2e2; color: #ef4444; }
.status-waiting { background: #d1fae5; color: #10b981; }

.room-code-tag { font-family: 'Righteous', monospace; font-size: 12px; font-weight: 700; letter-spacing: 0.6px; color: var(--chip-fg); background: var(--chip-bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; margin-left: 4px; vertical-align: middle; cursor: pointer; }
.room-code-tag:hover { filter: brightness(1.08); }
.room-code-chip { font-family: 'Righteous', monospace; font-size: 13px; font-weight: 700; letter-spacing: 0.8px; color: var(--chip-fg); background: var(--chip-bg); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.room-code-chip:hover { filter: brightness(1.08); }

.room-settings-preview { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.preview-badge { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--bg-color); color: var(--text-muted); border: 1px solid var(--border); font-weight: 700; }

.ready-btn { background-color: var(--bg-color); color: var(--text-muted); border: 2px solid var(--border); width: 100px; }
.ready-btn.is-ready { background-color: var(--success); color: white; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); }

.game-rules-display { display: flex; gap: 8px; margin-bottom: 15px; justify-content: center; flex-wrap: wrap; }
.rule-badge { background: var(--card-bg); color: var(--primary); padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 800; border: 1px solid var(--border); box-shadow: 0 2px 5px rgba(0,0,0,0.04);}
.opponent-badge { background: #fef08a; color: #854d0e; border-color: #fde047; }

.in-game-users-box { display: flex; gap: 8px; justify-content: center; margin-bottom: 15px; flex-wrap: wrap; background: var(--card-bg); padding: 12px; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 2px 5px rgba(0,0,0,0.04); }
.in-game-user-chip { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; background: var(--bg-color); padding: 6px 12px; border-radius: 20px; color: var(--text-muted); }
.in-game-user-chip.is-me { background: var(--chip-bg); color: var(--chip-fg); border: 1px solid var(--border); }

/* --- 단어 흔적 (Trace) 디자인 --- */
.word-trace-container { background: var(--bg-color); padding: 12px; border-radius: 12px; margin-bottom: 15px; overflow-x: auto; white-space: nowrap; border: 1px solid var(--border); }
.word-trace-container::-webkit-scrollbar { height: 6px; }
.word-trace-container::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 10px; }
.trace-scroll { display: inline-block; font-size: 15px; font-weight: 800; }
.trace-word { background: var(--card-bg); color: var(--primary); padding: 4px 12px; border-radius: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); margin: 0 2px; display: inline-block; border: 1px solid var(--border); }
.trace-arrow { color: var(--text-muted); font-size: 14px; margin: 0 6px; vertical-align: middle; }

.glass-select { padding: 8px 10px; border-radius: 8px; border: 2px solid var(--border); font-size: 13px; outline: none; background: var(--card-bg); color: var(--text-main); cursor: pointer; font-family: inherit;}
.glass-select:disabled { background-color: var(--bg-color); cursor: not-allowed; color: var(--text-muted); }
.type-select { width: 95px; border-color: var(--primary); color: var(--primary); font-weight: 600;}
.opponent-select { font-weight: 800; border-color: #f59e0b; color: #b45309; }

.timer-container { margin-bottom: 15px; background: var(--bg-color); padding: 10px; border-radius: 12px;}
.timer-text { font-size: 13px; font-weight: 600; margin-bottom: 5px; text-align: center; color: var(--danger);}
.timer-bar { height: 8px; background: #cbd5e1; border-radius: 4px; overflow: hidden; }
.timer-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, var(--danger)); width: 100%; transition: width 1s linear; }

.chat-history { background: var(--bg-color); border-radius: 12px; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; height: 320px; }
.game-history-tall { height: 430px; }
.chat-history::-webkit-scrollbar { width: 8px; }
.chat-history::-webkit-scrollbar-thumb { background-color: var(--border); border-radius: 10px; }

.msg-item { padding: 12px 16px; max-width: 80%; font-size: 14px; line-height: 1.4; word-break: break-all; animation: fadeIn 0.2s ease-out;}
.chat-msg { background-color: var(--card-bg); color: var(--text-main); align-self: flex-start; border-radius: 16px 16px 16px 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);}
.my-chat-msg { background-color: #fef08a; color: #854d0e; align-self: flex-end; border-radius: 16px 16px 4px 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);}
.game-msg { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fffef9; align-self: center; font-weight: 800; font-size: 15px; padding: 10px 24px; border-radius: 30px; box-shadow: 0 4px 15px color-mix(in srgb, var(--primary) 32%, transparent); }
.system-msg { background-color: color-mix(in srgb, var(--text-main) 6%, transparent); padding: 6px 12px; border-radius: 12px; color: var(--text-muted); font-size: 12px; align-self: center; text-align: center; font-weight: 700; }

.input-area { display: flex; gap: 8px; }
.input-area input { flex: 1; }
.turn-alert { text-align: center; padding: 12px; border-radius: 12px; margin-bottom: 15px; font-weight: 800; font-size: 14px; background: #fef3c7; color: #d97706; }
.my-turn { background: #d1fae5; color: #047857; }
.spectator-turn { background: #e2e8f0; color: #475569; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.55); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.modal-content { background: var(--panel-bg); color: var(--text-main); padding: 35px; border-radius: 24px; width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,0.28); animation: fadeIn 0.3s ease-out; max-height: 90vh; overflow-y: auto; }
.modal-content h2 { margin-top: 0; font-size: 20px; color: var(--primary); border-bottom: 2px solid var(--bg-color); padding-bottom: 15px; }
.modal-options { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 20px 0; }
.option-group { display: flex; flex-direction: column; gap: 5px; }
.option-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }

/* 테마(주제) 선택 디자인 */
.theme-list-box { border: 2px solid var(--border); border-radius: 8px; height: 110px; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--bg-color); }
.theme-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--text-main); }

/* 모음 퀴즈 힌트 디자인 */
.quiz-hint-group { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; margin: 0 4px; vertical-align: bottom; }
.quiz-hint-ox { font-size: 12px; font-weight: 900; margin-bottom: 3px; }
.quiz-hint-ox.ox-o { color: var(--success); }
.quiz-hint-ox.ox-x { color: var(--danger); }
/* 사이트 안내 푸터 (게임 화면 하단) */
body { flex-wrap: wrap; align-content: flex-start; }
.site-foot { flex: 0 0 100%; width: 100%; margin: 28px 0 0; padding: 0 20px 4px; box-sizing: border-box; text-align: center; }
.site-foot::before { content: ""; display: block; width: 100%; max-width: min(900px, 88vw); margin: 0 auto 18px; border-top: 1px solid var(--border); }
.site-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 0 auto 8px; max-width: min(900px, 88vw); }
.site-foot a { font-size: 12px; font-weight: 700; color: var(--text-muted); text-decoration: none; }
.site-foot a:hover { color: var(--primary); text-decoration: underline; }

.play-theme-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40;
  min-width: 48px;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  background: var(--panel-bg);
  color: var(--text-main);
  border: 2px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}
.play-theme-btn:hover { transform: translateY(-1px); }

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #e8a04a;
  --primary-light: #f0bc74;
  --primary-hover: #c9842c;
  --bg-color: rgba(28, 16, 20, 0.88);
  --panel-bg: rgba(18, 10, 14, 0.92);
  --card-bg: rgba(36, 22, 26, 0.92);
  --input-bg: rgba(14, 8, 12, 0.78);
  --text-main: #f6ead8;
  --text-muted: #c9b8a6;
  --border: rgba(232, 160, 74, 0.32);
  --success: #5ee0a8;
  --danger: #ff8a8a;
  --halo: #1a1014;
  --chip-bg: rgba(232, 160, 74, 0.18);
  --chip-fg: #f0bc74;
  --lamp: #e8a04a;
}

html[data-theme="dark"] .panel {
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(232, 160, 74, 0.18) inset, 0 0 40px rgba(232, 160, 74, 0.08);
}
html[data-theme="dark"] .room-list-box,
html[data-theme="dark"] .user-list-box,
html[data-theme="dark"] .chat-box,
html[data-theme="dark"] .chat-history {
  box-shadow: inset 0 0 0 1px rgba(232, 160, 74, 0.12);
}
html[data-theme="dark"] .room-list li {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(232, 160, 74, 0.12);
}
html[data-theme="dark"] .room-list li:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38), 0 0 18px rgba(232, 160, 74, 0.18);
}
html[data-theme="dark"] .timer-bar { background: rgba(255,255,255,0.12); }
html[data-theme="dark"] .player-ready { color: #bbf7d0; background: rgba(16, 185, 129, 0.22); }
html[data-theme="dark"] .player-waiting { color: #fde68a; background: rgba(245, 158, 11, 0.22); }
html[data-theme="dark"] .status-playing { background: rgba(239, 68, 68, 0.22); color: #fecaca; }
html[data-theme="dark"] .status-waiting { background: rgba(16, 185, 129, 0.22); color: #bbf7d0; }
html[data-theme="dark"] .opponent-badge,
html[data-theme="dark"] .round-chip,
html[data-theme="dark"] .my-chat-msg {
  background: rgba(232, 160, 74, 0.22);
  color: #fde68a;
  border-color: rgba(232, 160, 74, 0.45);
}
html[data-theme="dark"] .turn-alert { background: rgba(232, 160, 74, 0.18); color: #fde68a; }
html[data-theme="dark"] .my-turn { background: rgba(16, 185, 129, 0.22); color: #bbf7d0; }
html[data-theme="dark"] .spectator-turn { background: rgba(255,255,255,0.08); color: var(--text-muted); }
html[data-theme="dark"] .modal-overlay { background: rgba(8, 4, 8, 0.62); }
html[data-theme="dark"] .site-foot a {
  text-shadow: 0 0 8px #1a1014, 1px 0 0 #1a1014, -1px 0 0 #1a1014;
}
