:root {
  --bg-top: #1a1040;
  --bg-btm: #2d1b6e;
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #a78bfa;
  --accent: #f59e0b;
  --accent-dark: #d97706;
  --green: #10b981;
  --red: #ef4444;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg-light: #f9fafb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

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

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-btm) 100%);
  min-height: 100vh;
  color: var(--text);
  padding: 12px;
}

/* ===== LAYOUT ===== */
.screen { display: none; max-width: 500px; margin: 0 auto; padding-bottom: 32px; }
.screen:not(.hidden) { display: block; }
.hidden { display: none !important; }

/* ===== CARD ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }

/* ===== TITLE ===== */
.title-area { text-align: center; padding: 40px 0 24px; }
.title-area-sm { text-align: center; padding: 24px 0 16px; }
.game-title {
  font-size: 3.2rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 48px rgba(167, 139, 250, 0.9), 0 2px 0 rgba(0,0,0,0.3);
  letter-spacing: 4px;
}
.game-subtitle { color: var(--primary-light); margin-top: 8px; font-size: 0.9rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  transition: transform 0.1s, opacity 0.15s;
  text-align: center;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: 8px; }
.btn-full { width: 100%; display: block; }
.button-group { display: flex; gap: 10px; }
.button-group .btn { flex: 1; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; font-size: 0.88rem; color: var(--text); margin-bottom: 8px; }
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  color: var(--text);
}
input[type="text"]:focus { border-color: var(--primary); }
input[type="text"]::placeholder { color: #adb5bd; }
input[type="text"]:disabled { background: #f3f4f6; color: var(--text-muted); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

/* ===== OPTION BUTTONS ===== */
.option-group { display: flex; gap: 8px; flex-wrap: wrap; }
.option-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.15s;
}
.option-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; }
.option-btn:hover:not(.selected) { border-color: var(--primary-light); }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.4);
}
.modal-content h2 { font-size: 1.3rem; margin-bottom: 20px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  white-space: nowrap;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== LOBBY ===== */
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.lobby-header h2 { color: #fff; font-size: 1.4rem; }
.room-code-display {
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 8px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}
.room-code-display:hover { background: rgba(255,255,255,0.25); }
.room-code-label { display: block; font-size: 0.65rem; color: rgba(255,255,255,0.7); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.room-code-value { font-size: 1.8rem; font-weight: 900; color: #fff; letter-spacing: 6px; }
.settings-display { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.setting-badge {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.82rem;
  font-weight: 700;
}
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}
.player-item.is-me { background: #ede9fe; }
.player-name { font-weight: 700; flex: 1; font-size: 0.95rem; }
.badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.badge-host { background: var(--accent); color: #fff; }
.badge-me { background: var(--primary); color: #fff; }
#lobby-actions { margin-top: 12px; }
.wait-msg { color: rgba(255,255,255,0.65); font-size: 0.88rem; text-align: center; padding: 10px 0; }

/* ===== GAME HEADER ===== */
.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 12px;
}
.round-info { color: #fff; font-weight: 900; font-size: 0.95rem; white-space: nowrap; }
.parent-badge {
  color: #fff;
  font-size: 0.8rem;
  background: rgba(245,158,11,0.3);
  border: 1px solid rgba(245,158,11,0.5);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== TIMER ===== */
.timer-display { flex: 1; min-width: 0; }
.timer-text {
  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 4px;
}
.timer-text.warn { color: #fca5a5; }
.timer-bar-wrap { width: 100%; height: 6px; background: rgba(255,255,255,0.2); border-radius: 3px; overflow: hidden; }
.timer-bar { height: 6px; background: var(--green); border-radius: 3px; transition: width 0.5s linear, background 0.3s; }
.timer-bar.warn { background: var(--red); }

/* ===== PHASES ===== */
.phase { animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Parent preview */
.odai-preview-card { text-align: center; }
.your-turn-label {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 20px;
}
.odai-section { background: linear-gradient(135deg, #fef3c7, #fde68a); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.odai-small-label { font-size: 0.72rem; font-weight: 700; color: #92400e; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 6px; }
.odai-big-text { font-size: 1.9rem; font-weight: 900; color: #78350f; line-height: 1.2; }
.keyword-pick-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 10px;
  text-align: center;
}
.keyword-choices { display: flex; flex-direction: column; gap: 10px; }
.keyword-choice-btn {
  background: #f3f4f6;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  text-align: left;
  transition: all 0.15s;
  line-height: 1.4;
}
.keyword-choice-btn:hover { border-color: var(--primary); background: #ede9fe; transform: translateX(4px); }
.keyword-choice-btn:active { transform: scale(0.97); }

/* Waiting */
.waiting-icon { font-size: 3rem; margin-bottom: 12px; }
.waiting-icon-sm { font-size: 2rem; margin-bottom: 8px; text-align: center; }

/* Champion */
.champion-display {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  text-align: center;
  border: 2px solid var(--accent);
}
.champion-label { font-size: 0.7rem; font-weight: 700; color: #92400e; text-transform: uppercase; letter-spacing: 2px; margin-bottom: 6px; }
.champion-word { font-size: 2.4rem; font-weight: 900; color: #78350f; line-height: 1.1; }
.champion-by { font-size: 0.82rem; color: #92400e; margin-top: 4px; }

/* Parent proposal view */
.odai-reminder {
  background: #fef3c7;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.odai-reminder-label { color: #92400e; font-size: 0.75rem; display: block; margin-bottom: 2px; }
.odai-reminder strong { font-size: 1.05rem; color: #78350f; }

.proposal-queue { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.proposal-item { background: var(--bg-light); border-radius: var(--radius-sm); padding: 12px; }
.proposal-word { font-size: 1.4rem; font-weight: 900; }
.proposal-by { font-size: 0.78rem; color: var(--text-muted); margin-left: 6px; }
.proposal-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Child view */
.pending-box {
  background: #ede9fe;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--primary);
}
.pending-label { color: var(--text-muted); font-size: 0.8rem; }

/* Proposal history */
.history-section { margin-top: 4px; }
.history-title { color: rgba(255,255,255,0.6); font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.history-list { display: flex; flex-direction: column; gap: 5px; max-height: 140px; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.85rem;
  animation: fadeIn 0.2s ease;
}
.history-item.won { background: rgba(16,185,129,0.2); }
.history-item.lost { background: rgba(107,114,128,0.15); }
.h-word { font-weight: 700; color: #fff; flex: 1; }
.h-by { color: rgba(255,255,255,0.55); font-size: 0.75rem; }
.h-status { font-size: 0.8rem; }
.empty-msg { color: var(--text-muted); text-align: center; padding: 16px; font-size: 0.88rem; }
.empty-msg-sm { color: rgba(255,255,255,0.4); font-size: 0.82rem; padding: 4px 0; }

/* Final input */
.phase-title { font-size: 1.3rem; font-weight: 900; margin-bottom: 6px; }
.phase-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 14px; }
.final-champ-mini {
  background: #fef3c7;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 16px;
}
.final-champ-mini strong { font-size: 1.1rem; font-weight: 900; }
.by-label { font-size: 0.78rem; color: #92400e; margin-left: 4px; }
.submitted-badge {
  background: #d1fae5;
  color: #065f46;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 12px;
}
.submitted-count { text-align: center; font-size: 0.82rem; color: var(--text-muted); margin-top: 10px; }

/* Final reveal */
.final-words-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.final-word-card {
  background: var(--bg-light);
  border-radius: 12px;
  padding: 14px 16px;
  border: 2px solid transparent;
  transition: all 0.15s;
  animation: fadeIn 0.3s ease;
}
.final-word-card.selectable { cursor: pointer; }
.final-word-card.selectable:hover { border-color: var(--primary); background: #ede9fe; }
.final-word-text { font-size: 1.6rem; font-weight: 900; }
.final-word-player { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.judge-prompt {
  background: #fef3c7;
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.88rem;
  color: #92400e;
  font-weight: 700;
  margin-top: 8px;
}

/* Round result */
.winner-card {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  margin: 12px 0;
  border: 2px solid var(--accent);
}
.winner-label { font-size: 0.72rem; font-weight: 700; color: #92400e; text-transform: uppercase; letter-spacing: 2px; }
.winner-word { font-size: 2rem; font-weight: 900; color: #78350f; margin: 6px 0; }
.winner-name { font-size: 0.88rem; color: #92400e; }
.no-winner { text-align: center; color: var(--text-muted); padding: 16px; }

/* 全員の最終ワード一覧 */
.all-proposals-section { margin-top: 12px; }
.all-proposals-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.all-proposals-list { display: flex; flex-direction: column; gap: 6px; }
.result-word-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-light);
  border-radius: 10px;
  padding: 10px 14px;
  border: 2px solid transparent;
  animation: fadeIn 0.3s ease;
}
.result-word-item.is-winner {
  background: #fef3c7;
  border-color: var(--accent);
}
.result-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.result-word-text { font-weight: 900; font-size: 1.05rem; flex: 1; }
.result-player-name { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.result-word-item.is-winner .result-word-text { color: #78350f; }
.result-word-item.is-winner .result-player-name { color: #92400e; }

.odai-reveal-box { background: #f3f4f6; border-radius: var(--radius-sm); padding: 12px 14px; margin: 12px 0; }
.odai-reveal-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.odai-reveal-text { font-size: 1.3rem; font-weight: 900; color: var(--text); }
.score-section { margin-top: 4px; }
.score-table-el { width: 100%; border-collapse: collapse; }
.score-table-el th { background: #f3f4f6; padding: 8px 10px; font-size: 0.78rem; color: var(--text-muted); font-weight: 700; text-align: left; }
.score-table-el td { padding: 9px 10px; font-size: 0.9rem; border-bottom: 1px solid #f3f4f6; }
.score-table-el .row-me td { background: #ede9fe; }
.score-table-el .row-top td:last-child { color: var(--accent-dark); font-weight: 900; }

/* Game over */
.final-score-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.final-score-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--bg-light);
  border-radius: 12px;
  transition: background 0.15s;
}
.final-score-item.rank-1 { background: #fef3c7; border: 2px solid var(--accent); }
.final-score-item.is-me { background: #ede9fe; }
.final-score-item.rank-1.is-me { background: #fef3c7; }
.fs-rank { font-size: 1.3rem; width: 32px; text-align: center; }
.fs-name { flex: 1; font-weight: 700; font-size: 0.95rem; }
.fs-score { font-weight: 900; color: var(--primary); font-size: 1rem; }
.gameover-wait { color: rgba(255,255,255,0.6); font-size: 0.88rem; text-align: center; padding: 10px 0; }
