:root {
  --bg: #111418;
  --fg: #f5f3ee;
  --muted: #a3acb6;
  --line: #3a4048;
  --green: #007a33;   /* white text: 5.5:1 */
  --red: #c8102e;     /* white text: 5.9:1 */
  --go: #1f9d55;
  --card-front: #f5f3ee;
  --card-ink: #111418;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  overflow-y: auto;
  gap: clamp(12px, 3.5vh, 28px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  text-align: center;
  touch-action: pan-y;
}

/* ---------- Start ---------- */

h1 {
  font-size: clamp(2rem, 9vmin, 3.4rem);
  font-weight: 900;
  letter-spacing: -0.01em;
}

.start-btn {
  font-size: clamp(1.8rem, 8.5vmin, 3.4rem);
  font-weight: 900;
  padding: 0.35em 1.3em;
  border: 0;
  border-radius: 999px;
  background: var(--go);
  color: #fff;
  box-shadow: 0 6px 0 #146b39;
  transition: transform 0.08s, box-shadow 0.08s;
}
.start-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #146b39; }
.start-btn:disabled { background: var(--line); color: #7d858e; box-shadow: none; cursor: default; }

.stepper {
  display: flex;
  align-items: center;
  gap: 18px;
}
.step-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--fg);
  background: transparent;
  color: var(--fg);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}
.step-btn:active:not(:disabled) { background: #2a3037; }
.step-btn:disabled { border-color: var(--line); color: var(--line); cursor: default; }
.step-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5ch;
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.step-value small { font-size: 0.95rem; font-weight: 700; color: var(--muted); margin-top: 4px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 780px;
}

.chip {
  font-size: clamp(0.95rem, 3.2vmin, 1.15rem);
  font-weight: 700;
  padding: 0.6em 1.1em;
  border-radius: 999px;
  border: 2px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip[aria-pressed="false"] {
  background: transparent;
  color: #6f7883;
  border-color: var(--line);
}

.rule { max-width: 32em; font-size: clamp(1rem, 3.4vmin, 1.2rem); color: var(--muted); font-weight: 600; line-height: 1.4; }
.status { color: #ff8a80; font-weight: 600; }
.status:empty { display: none; }

/* ---------- shared in-game bits ---------- */

.end-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  font-size: 1rem;
  font-weight: 700;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  border: 2px solid #5a626d;
  background: transparent;
  color: var(--fg);
}
.end-btn:active { background: #2a3037; }

.ghost-btn {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 0.6em 1.6em;
  border-radius: 999px;
  border: 2px solid #5a626d;
  background: transparent;
  color: var(--fg);
}
.ghost-btn:active { background: rgba(255, 255, 255, 0.12); }

/* ---------- Deal ---------- */

#deal { touch-action: none; padding-top: max(72px, calc(env(safe-area-inset-top) + 60px)); }

.progress {
  position: absolute;
  top: max(20px, calc(env(safe-area-inset-top) + 8px));
  right: max(18px, env(safe-area-inset-right));
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.deal-title {
  font-size: clamp(2rem, 7vh, 3.2rem);
  font-weight: 900;
}

.card {
  --w: min(76vw, calc(52dvh * 5 / 7), 340px);
  width: var(--w);
  aspect-ratio: 5 / 7;
  flex-shrink: 0;
  perspective: 1200px;
  cursor: pointer;
  touch-action: none;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.28s ease-out;
}
.card.revealed .card-inner { transform: rotateY(180deg); }
.card.no-anim .card-inner { transition: none; }

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.card-back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 14px, transparent 14px 28px),
    var(--green);
  border: 6px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  gap: 8px;
}
.card-back:active { filter: brightness(1.1); }
.card-mark { font-size: calc(var(--w) * 0.5); font-weight: 900; line-height: 1; }
.card-front {
  background: var(--card-front);
  color: var(--card-ink);
  transform: rotateY(180deg);
  padding: 0 7%;
}
.card-label {
  position: absolute;
  bottom: 7%;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.8;
}
.card-front .card-label { top: 7%; bottom: auto; color: #58616b; opacity: 1; }
.card-word {
  font-weight: 900;
  line-height: 1.05;
  white-space: nowrap;
}

.deal-hint {
  min-height: 2.8em;
  max-width: 24em;
  font-size: clamp(0.95rem, 2.4vh, 1.15rem);
  font-weight: 600;
  color: var(--muted);
  line-height: 1.4;
}

.next-btn {
  width: min(100%, 420px);
  flex-shrink: 0;
  font-size: clamp(1.4rem, 4.2vh, 2rem);
  font-weight: 900;
  padding: 0.55em 0.8em;
  border: 0;
  border-radius: 999px;
  background: var(--go);
  color: #fff;
  box-shadow: 0 6px 0 #146b39;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.next-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #146b39; }
.next-btn:disabled { background: var(--line); color: #7d858e; box-shadow: none; cursor: default; }

/* ---------- Talk ---------- */

.talk-kicker { font-size: clamp(1.1rem, 3.2vh, 1.5rem); font-weight: 700; color: var(--muted); }
.talk-starter { font-size: clamp(2.2rem, 9vmin, 3.8rem); font-weight: 900; line-height: 1.1; }
.talk-rule { max-width: 26em; font-size: clamp(1rem, 2.6vh, 1.25rem); font-weight: 600; color: var(--muted); line-height: 1.45; }

.reveal-btn {
  margin-top: 2vh;
  min-width: min(100%, 320px);
  font-size: clamp(1.4rem, 4.2vh, 2rem);
  font-weight: 900;
  padding: 0.55em 1.4em;
  border-radius: 999px;
  border: 3px solid var(--red);
  background: transparent;
  color: var(--fg);
  transition: background 0.15s;
}
.reveal-btn.armed { background: var(--red); color: #fff; white-space: nowrap; font-size: clamp(1.1rem, 3.2vh, 1.5rem); padding-block: 0.95em; }

/* ---------- Reveal ---------- */

#reveal { background: var(--red); }
#reveal .talk-kicker { color: rgba(255, 255, 255, 0.85); }
.reveal-who {
  font-size: clamp(3rem, 14vmin, 6rem);
  font-weight: 900;
  line-height: 1;
  color: #fff;
}
.reveal-words {
  display: grid;
  gap: 12px;
  width: min(100%, 420px);
}
.reveal-words > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px 20px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}
.reveal-words dt { font-size: 1rem; font-weight: 700; color: rgba(255, 255, 255, 0.8); }
.reveal-words dd { font-size: clamp(1.4rem, 5vmin, 2rem); font-weight: 900; color: #fff; overflow-wrap: anywhere; text-align: right; }
.reveal-actions { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 1vh; }
#reveal .ghost-btn { border-color: rgba(255, 255, 255, 0.7); }

@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
}
