:root {
  --bg: #080808;
  --bg-soft: #101010;
  --surface: #151515;
  --surface-2: #1d1d1d;
  --text: #f4f4f5;
  --muted: #9ca3af;
  --muted-soft: #6b7280;
  --border: rgba(255, 255, 255, 0.07);
  --accent: #ffffff;
  --radius-sm: 14px;
  --radius: 20px;
  --radius-lg: 28px;
  --font: "Inter", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --app-pad: max(20px, env(safe-area-inset-left));
  --bottom-safe: max(20px, env(safe-area-inset-bottom));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  background: var(--bg);
}

.app {
  width: min(100%, 440px);
  margin: 0 auto;
  min-height: 100dvh;
  padding:
    max(16px, env(safe-area-inset-top))
    var(--app-pad)
    var(--bottom-safe);
}

.screen {
  display: none;
  flex-direction: column;
  min-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - var(--bottom-safe));
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Typography ─── */

.eyebrow {
  margin: 0 0 var(--space-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

h2 {
  margin: 0 0 var(--space-xs);
  font-family: var(--serif);
  font-size: clamp(1.75rem, 6vw, 2.125rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* ─── Home ─── */

.screen--home {
  justify-content: center;
  gap: 0;
  padding-block: var(--space-xl);
}

.home-header {
  margin-bottom: var(--space-2xl);
}

.logo {
  margin: 0 0 var(--space-sm);
  font-family: var(--serif);
  font-size: clamp(2.75rem, 13vw, 3.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.03em;
}

.logo em {
  font-style: italic;
}

.tagline {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--muted);
}

.mode-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: var(--space-2xl);
  border-top: 1px solid var(--border);
}

.mode-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
  padding: 18px 2px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s;
}

.mode-option:hover {
  opacity: 0.72;
}

.mode-option:active {
  opacity: 0.5;
}

.mode-option-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.mode-option-title {
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.mode-option-meta {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--muted-soft);
}

.mode-option-arrow {
  flex-shrink: 0;
  font-size: 1rem;
  color: var(--muted-soft);
  transition: transform 0.2s, color 0.2s;
}

.mode-option:hover .mode-option-arrow {
  color: var(--muted);
  transform: translateX(3px);
}

.home-note {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.65;
  text-align: center;
  color: var(--muted-soft);
}


/* ─── Shared screen layout ─── */

.screen-top {
  margin-bottom: var(--space-lg);
}

.screen-intro {
  margin-top: var(--space-md);
}

.screen-scroll {
  flex: 1;
  overflow-y: auto;
  padding-bottom: var(--space-md);
  -webkit-overflow-scrolling: touch;
}

.screen-bottom {
  padding-top: var(--space-md);
  margin-top: auto;
}

.setup-sub {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--muted);
}

.back-btn {
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
}

.back-btn:hover {
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* ─── Setup ─── */

.player-list {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.player-row {
  display: flex;
  gap: var(--space-sm);
}

.player-row input {
  flex: 1;
  min-width: 0;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.player-row input::placeholder {
  color: var(--muted-soft);
}

.player-row input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.22);
}

.remove-player {
  flex-shrink: 0;
  width: 46px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
}

.setup-panel {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-title {
  margin: 0 0 var(--space-xs);
  font-size: 0.9375rem;
  font-weight: 600;
}

.panel-copy {
  margin: 0 0 var(--space-sm);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
}

.rule-list {
  margin: 0 0 var(--space-sm);
  padding-left: 1.1rem;
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--muted);
}

.rule-list strong {
  color: var(--text);
  font-weight: 600;
}

.disclaimer {
  margin: var(--space-sm) 0 0;
  font-size: 0.6875rem;
  line-height: 1.5;
  color: var(--muted-soft);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: var(--space-lg) 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
  cursor: pointer;
}

.toggle-row--compact {
  margin-top: var(--space-sm);
}

.toggle-row input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #fff;
}

/* ─── Buttons ─── */

.primary-btn,
.secondary-btn,
.ghost-btn {
  font: inherit;
  font-size: 1rem;
  border-radius: 999px;
  padding: 16px 22px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s, border-color 0.15s;
}

.primary-btn {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
}

.primary-btn:hover {
  opacity: 0.92;
}

.secondary-btn {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.ghost-btn {
  width: 100%;
  margin-top: var(--space-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
}

.ghost-btn:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.16);
}

/* ─── Game screen ─── */

.screen--game {
  gap: 0;
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.progress-wrap {
  text-align: right;
}

.level-dots {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.3s, transform 0.3s;
}

.dot.active {
  transform: scale(1.15);
}

.card-count {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.game-meta {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.turn-banner {
  min-height: 0;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  text-align: center;
  color: var(--muted);
}

.turn-banner--solo {
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.turn-banner--solo strong {
  color: var(--text);
  font-weight: 600;
}

.drink-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: #fcd34d;
}

.drink-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

/* ─── Prompt card ─── */

.card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--card-glow, transparent), transparent 72%);
  opacity: 0.4;
  pointer-events: none;
}

.card.wildcard {
  border-color: rgba(251, 191, 36, 0.28);
  --card-glow: rgba(251, 191, 36, 0.12);
}

.card--deep {
  border-color: rgba(148, 163, 184, 0.16);
}

.card-top {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: var(--space-lg) var(--space-lg) 0;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--level-color, var(--text));
}

.level-name {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted);
}

.card-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}

.card-text {
  margin: 0;
  max-width: 19em;
  font-family: var(--serif);
  font-size: clamp(1.375rem, 5.2vw, 1.75rem);
  line-height: 1.38;
  letter-spacing: -0.01em;
}

.card-foot {
  position: relative;
  z-index: 1;
  padding: 0 var(--space-lg) var(--space-lg);
}

.card-hint {
  margin: 0;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  line-height: 1.5;
  text-align: center;
  color: var(--muted-soft);
}

.game-footer {
  margin-top: auto;
  padding-top: var(--space-sm);
}

.game-actions {
  display: flex;
  gap: var(--space-sm);
}

.game-actions .primary-btn {
  flex: 1.6;
}

.finish-btn {
  margin-top: var(--space-sm);
}

/* ─── Finish ─── */

.screen--finish {
  justify-content: center;
}

.finish-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-lg) 0;
}

.finish-content h2 {
  margin-bottom: var(--space-sm);
}

.finish-msg {
  margin: 0 0 var(--space-xl);
  max-width: 22rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--muted);
}

.finish-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  width: 100%;
  margin-bottom: var(--space-xl);
}

.stat {
  padding: var(--space-md) var(--space-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-value {
  display: block;
  margin-bottom: 4px;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted-soft);
}

.finish-actions {
  width: 100%;
}

.finish-actions .ghost-btn {
  margin-top: var(--space-sm);
}

@media (max-height: 700px) {
  .screen--home {
    padding-block: var(--space-lg);
  }

  .home-header {
    margin-bottom: var(--space-xl);
  }

  .mode-list {
    margin-bottom: var(--space-xl);
  }

  .logo {
    font-size: clamp(2.25rem, 12vw, 3rem);
  }

  .card-body {
    padding: var(--space-lg) var(--space-md);
  }

  .card-text {
    font-size: clamp(1.25rem, 4.8vw, 1.5rem);
  }
}

@media (min-width: 440px) {
  .app {
    padding-left: 24px;
    padding-right: 24px;
  }
}
