/* ============================================================
   Undercover VN — luxury dark theme + playful motion
   Mobile-first, single-page, no framework
   ============================================================ */

:root {
  /* Palette */
  --bg-0: #07070a;
  --bg-1: #111116;
  --bg-2: #1a1a22;
  --bg-3: #25252f;
  --border: rgba(212, 165, 116, 0.18);
  --border-strong: rgba(212, 165, 116, 0.35);

  --text-1: #f5f1ea;
  --text-2: #b8b3a8;
  --text-3: #6f6a60;
  --text-mute: #4a4640;

  --gold: #d4a574;
  --gold-bright: #e6be8a;
  --gold-dim: #8a6d4a;

  --red: #e85a5a;
  --green: #5dd39e;
  --blue: #6ba4ff;
  --purple: #b48eff;

  /* Spacing */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(212, 165, 116, 0.06), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(180, 142, 239, 0.04), transparent 60%),
    var(--bg-0);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  position: relative;
}

/* ===== Brand ===== */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--bg-0);
  font-size: 18px;
  box-shadow: 0 6px 24px -8px rgba(212, 165, 116, 0.5);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-1);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-top: 1px;
}

/* ===== Typography ===== */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.5px;
}

h1 {
  font-size: 38px;
  line-height: 1.15;
  margin-bottom: 14px;
}

h2 {
  font-size: 26px;
  line-height: 1.2;
  margin-bottom: 10px;
}

h3 {
  font-size: 19px;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-2);
  font-size: 15px;
  margin-bottom: 28px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 22px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--bg-0);
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  border: 1px solid var(--gold-bright);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s;
  -webkit-appearance: none;
  letter-spacing: 0.2px;
  box-shadow: 0 8px 24px -10px rgba(212, 165, 116, 0.6);
  user-select: none;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(212, 165, 116, 0.06);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.04);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.btn-row .btn { flex: 1; }

/* ===== Cards ===== */
.card {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 14px;
}

.card-glow {
  position: relative;
}

.card-glow::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(212, 165, 116, 0.4), transparent 50%);
  z-index: -1;
  opacity: 0.5;
}

/* ===== Form controls ===== */
.field {
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
}

.field-row > * {
  flex: 1;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-1);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.15s var(--ease);
}

.field-row > *.active {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  color: var(--bg-0);
  font-weight: 600;
}

.field-row > *:not(.active):hover {
  background: rgba(212, 165, 116, 0.08);
  color: var(--text-1);
}

/* Toggle switch */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
}

.toggle-label {
  font-size: 15px;
  font-weight: 500;
}

.toggle-track {
  width: 44px;
  height: 26px;
  background: var(--bg-3);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s var(--ease);
  border: 1px solid var(--border);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: var(--text-2);
  border-radius: 50%;
  transition: transform 0.2s var(--ease), background 0.2s;
}

.toggle.on .toggle-track {
  background: var(--gold);
  border-color: var(--gold-bright);
}

.toggle.on .toggle-track::after {
  transform: translateX(18px);
  background: var(--bg-0);
}

/* ===== Word reveal ===== */
.word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 220px;
  padding: 40px 28px;
  background:
    radial-gradient(ellipse at center, rgba(212, 165, 116, 0.08), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  margin: 22px 0;
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.word-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(212, 165, 116, 0.04));
  pointer-events: none;
}

.word-hint {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 18px;
}

.word-text {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: -1px;
  text-shadow: 0 4px 24px rgba(212, 165, 116, 0.3);
  animation: wordReveal 0.4s var(--ease) backwards;
}

.word-text.mrwhite {
  color: var(--purple);
  text-shadow: 0 4px 24px rgba(180, 142, 239, 0.3);
  font-size: 32px;
  line-height: 1.3;
}

@keyframes wordReveal {
  from { opacity: 0; transform: scale(0.85); filter: blur(8px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

.word-tap {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 20px;
}

/* ===== Player turn indicator ===== */
.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(212, 165, 116, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 14px;
}

.turn-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--gold-bright);
  border-radius: 50%;
  animation: pulse 1.4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.instruction {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.instruction-strong {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.2;
  margin-bottom: 18px;
}

/* ===== Vote list ===== */
.vote-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 20px 0;
}

.vote-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
}

.vote-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

.vote-item:active {
  transform: scale(0.98);
}

.vote-item.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.vote-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-2);
}

.vote-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.vote-count {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}

.vote-count.highlight {
  color: var(--red);
  font-weight: 700;
  font-size: 15px;
}

/* ===== Result banner ===== */
.result-banner {
  text-align: center;
  padding: 28px 22px;
  background:
    radial-gradient(ellipse at center, rgba(232, 90, 90, 0.08), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border: 1px solid rgba(232, 90, 90, 0.3);
  border-radius: var(--r-lg);
  margin: 16px 0;
}

.result-banner.civilian {
  border-color: rgba(93, 211, 158, 0.3);
  background:
    radial-gradient(ellipse at center, rgba(93, 211, 158, 0.08), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
}

.result-banner.undercover {
  border-color: rgba(180, 142, 239, 0.3);
  background:
    radial-gradient(ellipse at center, rgba(180, 142, 239, 0.08), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
}

.result-banner.mrwhite {
  border-color: rgba(180, 142, 239, 0.4);
  background:
    radial-gradient(ellipse at center, rgba(180, 142, 239, 0.12), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
}

.result-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.result-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-banner .result-name {
  color: var(--red);
}

.result-banner.civilian .result-name {
  color: var(--green);
}

.result-banner.undercover .result-name,
.result-banner.mrwhite .result-name {
  color: var(--purple);
}

.result-role {
  font-size: 14px;
  color: var(--text-2);
}

.result-role .word {
  color: var(--gold-bright);
  font-weight: 600;
}

/* ===== Game over ===== */
.gameover {
  text-align: center;
  padding: 32px 20px;
}

.gameover-emoji {
  font-size: 64px;
  margin-bottom: 14px;
  display: block;
}

.gameover h1 {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}

.gameover-text {
  color: var(--text-2);
  margin-bottom: 28px;
}

/* ===== Player list (alive state) ===== */
.players-strip {
  display: flex;
  gap: 6px;
  margin: 18px 0 22px;
  flex-wrap: wrap;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.player-chip.alive {
  color: var(--text-1);
}

.player-chip.eliminated {
  opacity: 0.4;
  text-decoration: line-through;
}

.player-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.player-chip.eliminated .player-chip-dot {
  background: var(--red);
}

/* ===== Word bank reveal at game over ===== */
.reveal-table {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 8px 14px;
  margin: 18px 0;
  font-size: 14px;
}

.reveal-table .h {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.reveal-table .num {
  color: var(--text-3);
  font-weight: 600;
}

.reveal-table .role {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.reveal-table .role.civilian { color: var(--green); }
.reveal-table .role.undercover { color: var(--purple); }
.reveal-table .role.mrwhite { color: var(--purple); }

.reveal-table .word {
  color: var(--gold-bright);
  font-weight: 600;
}

.reveal-table .word.none {
  color: var(--text-3);
  font-style: italic;
  font-weight: 400;
}

/* ===== Utility ===== */
.center { text-align: center; }
.mt-auto { margin-top: auto; }
.spacer-sm { height: 16px; }
.spacer-md { height: 28px; }
.spacer-lg { height: 40px; }

.text-mute { color: var(--text-3); }
.text-small { font-size: 13px; }

.hidden { display: none !important; }

/* ===== Animations ===== */
.screen-enter {
  animation: screenIn 0.35s var(--ease);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Footer ===== */
.footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.5px;
}

.footer a {
  color: var(--text-3);
  text-decoration: none;
  border-bottom: 1px dotted var(--text-mute);
}

.footer a:hover {
  color: var(--gold);
}

/* ===== Mr.White guess ===== */
.guess-input {
  width: 100%;
  padding: 18px 20px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.5px;
  margin: 16px 0;
  outline: none;
  transition: border-color 0.2s;
}

.guess-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
}

.guess-input::placeholder {
  color: var(--text-mute);
}

/* ===== Category picker grid ===== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.cat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 8px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  font-family: inherit;
  color: var(--text-1);
  text-align: center;
}

.cat-cell:hover {
  border-color: var(--border-strong);
  background: var(--bg-2);
}

.cat-cell:active {
  transform: scale(0.97);
}

.cat-cell.active {
  background: linear-gradient(180deg, rgba(212, 165, 116, 0.16), rgba(212, 165, 116, 0.08));
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold-bright) inset, 0 6px 20px -8px rgba(212, 165, 116, 0.4);
}

.cat-emoji {
  font-size: 26px;
  line-height: 1;
  margin-bottom: 2px;
}

.cat-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.cat-count {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}

.cat-cell.active .cat-count {
  color: var(--gold-bright);
}

/* ===== Describe phase: word reminder + Mr.White ===== */
.word-reminder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(212, 165, 116, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 13px;
  margin: 6px auto 14px;
  width: fit-content;
  max-width: 100%;
}

.word-reminder-label {
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
}

.word-reminder-text {
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.rule-card {
  background: linear-gradient(180deg, rgba(232, 90, 90, 0.06), transparent);
  border: 1px solid rgba(232, 90, 90, 0.25);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 14px 0;
}

.rule-card .rule-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--red);
  margin-bottom: 6px;
}

.rule-card .rule-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}

.tip-card {
  background: linear-gradient(180deg, rgba(93, 211, 158, 0.06), transparent);
  border: 1px solid rgba(93, 211, 158, 0.22);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 10px 0 14px;
}

.tip-card .tip-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--green);
  margin-bottom: 6px;
}

.tip-card .tip-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}

.mrwhite-alert {
  text-align: center;
  padding: 28px 18px;
  background: radial-gradient(ellipse at center, rgba(180, 142, 239, 0.12), transparent 70%), linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid rgba(180, 142, 239, 0.4);
  border-radius: var(--r-lg);
  margin: 16px 0;
}

.mrwhite-alert .emoji {
  font-size: 44px;
  display: block;
  margin-bottom: 8px;
}

.mrwhite-alert h3 {
  color: var(--purple);
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 6px;
}

.mrwhite-alert p {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}

/* ===== Reduce motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Larger phones / tablets ===== */
@media (min-width: 540px) {
  #app { max-width: 540px; padding: 40px 28px; }
  h1 { font-size: 44px; }
  .word-text { font-size: 56px; }
}