:root {
  --bg: #0f0c08;
  --bg-grain: #1a1510;
  --paper: #faf7f2;
  --paper-shadow: rgba(0,0,0,0.5);
  --ink: #0a0a0a;
  --ink-muted: #4a4a4a;
  --hot: #ff2961;
  --hot-glow: rgba(255, 41, 97, 0.35);
  --not: #2a2623;
  --cream: #e8e1d3;
  --accent-warm: #f4a261;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--cream);
  font-family: 'Inter', system-ui, sans-serif;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6 0 0 0 0 0.5 0 0 0 0 0.4 0 0 0 0.25 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 1;
}

/* Vignette */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
  z-index: 1;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 2;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ========== START SCREEN ========== */
.start-content {
  text-align: center;
  max-width: 720px;
}

.masthead {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 900;
  font-size: clamp(3.5rem, 12vw, 9rem);
  line-height: 0.85;
  color: var(--paper);
  letter-spacing: -0.04em;
  margin-bottom: 0.5rem;
}

.masthead .or {
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 300;
  color: var(--hot);
  font-size: 0.7em;
  display: inline-block;
  transform: translateY(-0.08em);
  margin: 0 0.05em;
}

.masthead .fonts {
  display: block;
  color: var(--hot);
  font-variation-settings: "opsz" 144, "wght" 900;
  text-shadow: 0 0 40px var(--hot-glow);
}

.tagline {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--cream);
  opacity: 0.75;
  margin: 2rem auto 3rem;
  max-width: 28em;
  line-height: 1.4;
}

.rules {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.rule {
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.6;
}

.rule-num {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 300;
  font-style: italic;
  font-size: 2.5rem;
  display: block;
  color: var(--hot);
  opacity: 1;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.btn-start {
  background: var(--hot);
  color: var(--paper);
  border: none;
  padding: 1.25rem 3rem;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 100px;
  box-shadow: 0 10px 40px var(--hot-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 50px var(--hot-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-start:active { transform: translateY(0); }

/* Decorative corner marks */
.corner-mark {
  position: absolute;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cream);
  opacity: 0.4;
}
.corner-mark.tl { top: 1.5rem; left: 1.5rem; }
.corner-mark.tr { top: 1.5rem; right: 1.5rem; }
.corner-mark.bl { bottom: 1.5rem; left: 1.5rem; }
.corner-mark.br { bottom: 1.5rem; right: 1.5rem; }

/* ========== GAME SCREEN ========== */
.game-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}

.progress-track {
  flex: 1;
  height: 2px;
  background: rgba(232, 225, 211, 0.15);
  margin: 0 1.5rem;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--hot);
  width: 0%;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 10px var(--hot-glow);
}

.counter {
  font-family: 'Fraunces', serif;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.6;
  min-width: 3rem;
}

.counter.right { text-align: right; }

.card-stack {
  position: relative;
  width: min(92vw, 440px);
  height: min(72vh, 640px);
  perspective: 1200px;
}

.card {
  position: absolute;
  inset: 0;
  background: var(--paper);
  border-radius: 20px;
  color: var(--ink);
  padding: 2rem 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.2),
    0 20px 60px rgba(0,0,0,0.5),
    inset 0 0 0 1px rgba(0,0,0,0.08);
  cursor: grab;
  user-select: none;
  transform-origin: center bottom;
  will-change: transform, opacity;
  overflow: hidden;
}

.card:active { cursor: grabbing; }

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.7 0 0 0 0 0.6 0 0 0 0 0.5 0 0 0 0.15 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
  opacity: 0.6;
  mix-blend-mode: multiply;
  pointer-events: none;
  border-radius: inherit;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
  z-index: 2;
}

.card-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}

.card-index {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 300;
  font-size: 1.5rem;
  color: var(--ink-muted);
  line-height: 1;
}

.card-name {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 400;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink);
  margin-top: 0.3rem;
  position: relative;
  z-index: 2;
  text-align: left;
  opacity: 0.7;
  letter-spacing: 0.02em;
}

.card-divider {
  height: 1px;
  background: var(--ink);
  opacity: 0.15;
  margin: 1rem 0;
  position: relative;
  z-index: 2;
}

/* The font showcase area */
.font-showcase {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
  overflow: hidden;
  text-align: center;
}

.sample-main {
  font-size: clamp(3rem, 14vw, 6.5rem);
  line-height: 0.95;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  word-break: break-word;
}

.sample-sub {
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--ink);
  opacity: 0.85;
  margin-bottom: 0.85rem;
  padding: 0 0.5rem;
}

.sample-nums {
  font-size: 0.95rem;
  color: var(--ink);
  opacity: 0.55;
  letter-spacing: 0.05em;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  position: relative;
  z-index: 2;
  padding-top: 1rem;
  border-top: 1px solid rgba(0,0,0,0.1);
}

.card-byline {
  font-family: 'Inter', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  opacity: 0.6;
}

/* Swipe stamps */
.stamp {
  position: absolute;
  top: 2rem;
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 900;
  font-size: 3.5rem;
  letter-spacing: -0.04em;
  padding: 0.5rem 1.25rem;
  border: 4px solid currentColor;
  border-radius: 12px;
  opacity: 0;
  z-index: 3;
  pointer-events: none;
  transition: opacity 0.1s linear;
  text-transform: uppercase;
}

.stamp.hot {
  right: 1.5rem;
  color: var(--hot);
  transform: rotate(18deg);
}

.stamp.not {
  left: 1.5rem;
  color: var(--ink);
  transform: rotate(-18deg);
}

/* Action buttons */
.actions {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.5rem;
  z-index: 5;
}

.action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--cream);
  background: transparent;
  color: var(--cream);
  font-size: 1.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.action-btn::after {
  content: attr(data-key);
  position: absolute;
  top: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  opacity: 0.5;
  white-space: nowrap;
}

.action-btn:hover {
  transform: scale(1.08);
}

.action-btn.not:hover {
  border-color: var(--paper);
  color: var(--paper);
}

.action-btn.hot {
  border-color: var(--hot);
  color: var(--hot);
}

.action-btn.hot:hover {
  background: var(--hot);
  color: var(--paper);
  box-shadow: 0 0 30px var(--hot-glow);
}

.action-btn:active { transform: scale(0.95); }

.hint {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 0.7rem;
  color: var(--cream);
  opacity: 0.4;
  text-align: center;
  letter-spacing: 0.05em;
  z-index: 3;
  white-space: nowrap;
}

/* ========== RESULTS SCREEN ========== */
.results-content {
  max-width: 640px;
  width: 100%;
  text-align: center;
  overflow-y: auto;
  max-height: 100vh;
  padding: 3rem 1rem;
  -webkit-overflow-scrolling: touch;
}

.results-content::-webkit-scrollbar { display: none; }

.reveal-kicker {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 300;
  font-size: clamp(1rem, 3vw, 1.3rem);
  color: var(--cream);
  opacity: 0.7;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.reveal-title {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 900;
  font-size: clamp(3rem, 10vw, 6rem);
  line-height: 0.9;
  letter-spacing: -0.035em;
  color: var(--hot);
  text-shadow: 0 0 40px var(--hot-glow);
  margin-bottom: 0.5rem;
}

.reveal-deck {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 400;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  line-height: 1.5;
  color: var(--paper);
  margin: 1.5rem auto 2.5rem;
  max-width: 32em;
  opacity: 0.92;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.55;
}

.section-header::before, .section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--cream);
  opacity: 0.2;
}

.compatibility {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0 auto;
  max-width: 420px;
  text-align: left;
}

.compat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
}

.compat-label {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 400;
  font-size: 0.95rem;
  color: var(--paper);
  opacity: 0.85;
}

.compat-pct {
  font-family: 'Fraunces', serif;
  font-variation-settings: "opsz" 144, "wght" 700;
  font-size: 0.95rem;
  color: var(--hot);
  font-variant-numeric: tabular-nums;
}

.compat-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: rgba(232, 225, 211, 0.1);
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}

.compat-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: var(--hot);
  width: 0;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: 0.3s;
}

.compat-row.dominant .compat-bar-fill {
  box-shadow: 0 0 10px var(--hot-glow);
}

.fav-fonts {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 440px;
  margin: 0 auto;
}

.fav-font {
  background: var(--paper);
  color: var(--ink);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  text-align: left;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}

.fav-font::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='q'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.7 0 0 0 0 0.6 0 0 0 0 0.5 0 0 0 0.15 0'/></filter><rect width='100%25' height='100%25' filter='url(%23q)'/></svg>");
  opacity: 0.6;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.fav-sample {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  position: relative;
  z-index: 2;
}

.fav-name {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-muted);
  position: relative;
  z-index: 2;
}

.rejected {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.rej-tag {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid rgba(232, 225, 211, 0.2);
  border-radius: 100px;
  font-size: 0.85rem;
  color: var(--cream);
  opacity: 0.7;
  text-decoration: line-through;
  text-decoration-color: var(--hot);
  text-decoration-thickness: 2px;
}

.btn-restart {
  margin-top: 3rem;
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--cream);
  padding: 1rem 2.5rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 100px;
  transition: all 0.2s ease;
}

.btn-restart:hover {
  background: var(--hot);
  border-color: var(--hot);
  color: var(--paper);
}

.end-flourish {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-variation-settings: "opsz" 144, "wght" 300;
  color: var(--hot);
  font-size: 1.5rem;
  opacity: 0.5;
  margin-top: 2rem;
}

@media (max-width: 480px) {
  .card { padding: 1.5rem 1.25rem 1rem; border-radius: 16px; }
  .sample-main { font-size: clamp(2.5rem, 13vw, 5rem); }
  .sample-sub { font-size: 0.95rem; }
  .actions { bottom: 1.25rem; gap: 1.25rem; }
  .action-btn { width: 64px; height: 64px; font-size: 1.5rem; }
  .hint { display: none; }
  .rules { gap: 1rem; }
  .rule-num { font-size: 2rem; }
}

@media (max-height: 700px) {
  .card-stack { height: min(68vh, 560px); }
  .sample-main { font-size: clamp(2.5rem, 11vw, 5rem); margin-bottom: 0.8rem; }
}