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

:root {
  --bg:           #08080f;
  --bg-card:      #12121e;
  --bg-surface:   #1c1c2e;
  --accent:       #f5c842;
  --accent-light: #fde68a;
  --accent-glow:  rgba(245, 200, 66, 0.25);
  --accent-tint:  rgba(245, 200, 66, 0.08);
  --danger:       #e63946;
  --danger-glow:  rgba(230, 57, 70, 0.3);
  --danger-tint:  rgba(230, 57, 70, 0.08);
  --text:         #f2ede4;
  --text-muted:   #6e6e82;
  --border:       rgba(255, 255, 255, 0.07);
  --r:            14px;
  --r-sm:         8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ===== Screens ===== */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  padding: 24px 20px 40px;
  max-width: 480px;
  margin: 0 auto;
}
.screen.active                   { display: flex; }
#screen-begin                    { justify-content: center; }
#screen-reveal,
#screen-vote,
#screen-imposter-reveal          { justify-content: space-between; }
#screen-timer                    { justify-content: center; gap: 40px; }

/* ===== App Header ===== */
.app-header { text-align: center; padding: 16px 0 24px; }
.app-title  { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; }
.app-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }

/* ===== Shared: Gradient Text ===== */
.app-title,
.begin-starter-name,
.ir-word {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== Shared: Uppercase Label ===== */
.section-label,
.reveal-label,
.begin-starter-label,
.ir-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ===== Section Block ===== */
.section-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.section-toggle { width: 100%; background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; margin-bottom: 0; }
.toggle-chevron { font-size: 1.1rem; color: var(--text-muted); transition: transform 0.2s; display: inline-block; }
.section-toggle[aria-expanded="true"] .toggle-chevron { transform: rotate(180deg); }
.category-count { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; letter-spacing: 0; text-transform: none; }
.hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 8px; }

/* ===== Player List ===== */
.player-list { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.player-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
}
.player-item input[type="text"] { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 1rem; font-family: inherit; }
.player-item input[type="text"]::placeholder { color: var(--text-muted); }
.btn-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.btn-remove:hover, .btn-remove:active { background: var(--danger-tint); color: var(--danger); }

/* ===== Icon Button ===== */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #08080f;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 16px var(--accent-glow);
  transition: transform 0.15s;
}
.btn-icon:active { transform: scale(0.9); }

/* ===== Category List ===== */
.category-list {
  list-style: none;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  max-height: 2000px;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.25s ease;
}
.category-list.collapsed { max-height: 0; opacity: 0; margin-top: 0; }
.category-label {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.category-label:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.category-label input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.category-check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.category-label:has(input:checked) .category-check { background: var(--accent); border-color: var(--accent); }
.category-check::after {
  content: '';
  display: none;
  width: 5px;
  height: 9px;
  border: 2px solid #08080f;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.category-label:has(input:checked) .category-check::after { display: block; }

/* ===== Toggle Switch ===== */
.toggle-switch { position: relative; display: inline-block; cursor: pointer; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  display: block;
  width: 48px;
  height: 26px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-track              { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track::after       { transform: translateX(22px); background: #08080f; }

/* ===== Timer Config ===== */
.timer-config { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.preset-buttons { display: flex; gap: 8px; }
.btn-preset {
  flex: 1;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-preset.active { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.timer-custom { display: flex; align-items: center; gap: 8px; }
.number-input {
  width: 88px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  padding: 8px 12px;
  outline: none;
  text-align: center;
}
.input-unit { color: var(--text-muted); font-size: 0.9rem; }

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary,
.btn-ghost { width: 100%; border-radius: var(--r); font-family: inherit; cursor: pointer; margin-top: 8px; }

.btn-primary {
  padding: 16px;
  border: none;
  background: var(--accent);
  color: #08080f;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 0 24px var(--accent-glow);
  transition: transform 0.15s, box-shadow 0.2s;
}
.btn-primary:disabled                { opacity: 0.3; cursor: not-allowed; box-shadow: none; }
.btn-primary:not(:disabled):active   { transform: scale(0.98); }
.btn-primary.btn-muted               { background: var(--bg-surface); color: var(--text-muted); box-shadow: none; border: 1px solid var(--border); cursor: default; pointer-events: none; }

.btn-secondary { padding: 14px; border: 1px solid var(--border); background: var(--bg-surface); color: var(--text); font-size: 1rem; font-weight: 600; transition: background 0.2s; }
.btn-secondary:active { background: var(--bg-card); }

.btn-ghost { padding: 12px; border: none; background: none; color: var(--text-muted); font-size: 0.9rem; transition: color 0.2s; }
.btn-ghost:active { color: var(--text); }

/* ===== Reveal Screen ===== */
.reveal-header { text-align: center; padding: 16px 0 8px; }
.reveal-name { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.card-area { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px 0; overflow: hidden; }
.word-card { position: relative; width: 100%; max-width: 340px; aspect-ratio: 3/4; border-radius: 20px; user-select: none; touch-action: pan-y; }

.word-content,
.card-cover { position: absolute; inset: 0; border-radius: 20px; }

.word-content { background: var(--bg-surface); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }

.word-text { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.imposter-text { font-size: 1.8rem; font-weight: 800; text-align: center; color: var(--danger); line-height: 1.2; }
.imposter-text strong { font-size: 2.2rem; }
.imposter-hint { font-size: 0.85rem; color: var(--text-muted); text-align: center; line-height: 1.5; }

.card-cover {
  background: linear-gradient(160deg, #0e0e1a 0%, #181828 100%);
  border: 1px solid rgba(245, 200, 66, 0.15);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  will-change: transform;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 32px var(--accent-glow);
}
.card-cover:active           { cursor: grabbing; }
.card-cover.revealed         { transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.card-cover-pattern {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 50% 35%, rgba(245, 200, 66, 0.1) 0%, transparent 55%),
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 20px 20px;
}
.card-cover-pattern::before {
  content: '🎭';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  font-size: 5rem;
  opacity: 0.25;
  filter: drop-shadow(0 0 20px rgba(245, 200, 66, 0.3));
}
.card-cover-hint { position: absolute; bottom: 24px; font-size: 0.75rem; color: rgba(255, 255, 255, 0.3); letter-spacing: 0.06em; text-transform: uppercase; }

.reveal-footer { text-align: center; padding-top: 8px; }
.player-counter { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }

/* ===== Shared: Centered Screen Content ===== */
.begin-content,
.vote-content,
.imposter-reveal-content { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 16px 0; }

/* ===== Shared: Action Containers ===== */
.begin-actions,
.vote-actions,
.timer-actions { display: flex; flex-direction: column; width: 100%; }

/* ===== Begin Screen ===== */
.begin-icon { font-size: 5rem; margin-bottom: 24px; }
.begin-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.begin-hint { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; max-width: 300px; margin-bottom: 32px; }

/* Signature element: theatrical spotlight illuminates the starting player */
.begin-starter {
  background-color: var(--bg-surface);
  background-image: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(245, 200, 66, 0.16) 0%, transparent 70%);
  border: 1px solid rgba(245, 200, 66, 0.3);
  border-radius: var(--r);
  padding: 16px 32px;
  box-shadow: 0 0 40px rgba(245, 200, 66, 0.1), 0 0 0 1px rgba(245, 200, 66, 0.06);
}
.begin-starter-label { margin-bottom: 8px; }
.begin-starter-name { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; }

/* ===== Vote Screen ===== */
.vote-icon { font-size: 4rem; margin-bottom: 16px; }
.vote-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; }
.vote-hint { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
.vote-player-list { list-style: none; width: 100%; display: flex; flex-direction: column; gap: 8px; }
.vote-player-item { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 16px; font-size: 1rem; font-weight: 600; cursor: pointer; user-select: none; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.vote-player-item:active  { background: var(--bg-card); }
.vote-player-item.selected { border-color: var(--danger); background: var(--danger-tint); color: var(--danger); box-shadow: inset 3px 0 0 var(--danger); }

/* ===== Imposter Reveal ===== */
.ir-name { font-size: 3rem; font-weight: 800; letter-spacing: -0.02em; color: var(--danger); text-shadow: 0 0 40px var(--danger-glow); margin-bottom: 8px; }
.ir-name.ir-correct { color: #22c55e; text-shadow: 0 0 40px rgba(34, 197, 94, 0.3); }
.ir-divider { width: 48px; height: 2px; background: var(--border); margin: 16px 0; }
.ir-word { font-size: 2.2rem; font-weight: 800; }

/* ===== Timer Screen ===== */
.timer-display { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.timer-circle {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 48px var(--accent-glow), inset 0 0 48px var(--accent-tint);
  transition: border-color 0.5s, box-shadow 0.5s;
}
.timer-circle.danger { border-color: var(--danger); box-shadow: 0 0 48px var(--danger-glow), inset 0 0 48px var(--danger-tint); }
.timer-value  { font-size: 4rem; font-weight: 800; line-height: 1; }
.timer-unit   { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; letter-spacing: 0.06em; text-transform: uppercase; }
.timer-status { font-size: 1.1rem; color: var(--text-muted); min-height: 1.5em; text-align: center; }

/* ===== Utilities ===== */
.app-version { text-align: center; font-size: 0.7rem; color: rgba(110, 110, 130, 0.4); margin-top: 16px; letter-spacing: 0.04em; }
.hidden      { display: none; }
