:root {
  --felt: #1d6a48;       /* card-table felt */
  --felt-lt: #2a8a5f;
  --felt-dk: #0e3d2a;
  --felt-dp: #061c14;
  --on: #eafaf1;         /* text on felt */
  --dim: #a9ceba;
  --cream: #f7f6ee;      /* card face (warm ivory) */
  --ink: #17251d;        /* card ink (reads as 'black' suit) */
  --ink-dim: #5c7768;
  --suit-red: #e5325a;
  --red: #ff5a60;        /* urgency / emergency */
  --amber: #ffb454;
  --green: #45e0a0;
  --glass: rgba(255,255,255,.07);
  --glass-bd: rgba(255,255,255,.16);
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--on); font: 17px/1.6 var(--sans);
  background:
    radial-gradient(1100px 640px at 50% 4%, rgba(74,206,140,.30), transparent 62%),
    radial-gradient(1400px 1000px at 50% 128%, rgba(4,20,14,.85), transparent 60%),
    linear-gradient(160deg, var(--felt-lt) 0%, var(--felt) 46%, var(--felt-dk) 100%);
  background-attachment: fixed; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 0 22px 100px; }

/* nav */
.nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 26px; position: sticky; top: 0; z-index: 20;
  background: rgba(8,32,22,.6); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand { font-weight: 800; font-size: 15px; letter-spacing: .04em; line-height: 1.05; text-decoration: none; color: #fff; }
.brand::first-line { color: var(--on); }
.nav nav a { margin-left: 20px; text-decoration: none; color: var(--dim); font-size: 14.5px; font-weight: 500; transition: color .15s; }
.nav nav a:hover { color: #fff; }

/* hero */
.hero { text-align: center; padding: 70px 0 34px; }
.hero h1 { font-size: clamp(34px, 6vw, 56px); margin: 0 0 14px; letter-spacing: -.02em; font-weight: 800; }
.kicker { font-size: 20px; color: var(--dim); max-width: 760px; margin: 0 auto 10px; }
.kicker2 { color: var(--dim); }
.kicker2 strong { color: #fff; }
.zero { color: var(--red); font-size: 1.3em; font-weight: 800; }
.bigcount {
  font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: clamp(38px, 8vw, 86px); letter-spacing: .01em; margin: 22px 0 12px;
  color: #fff; text-shadow: 0 0 40px rgba(255,90,96,.45);
}
.bigcount.small { font-size: clamp(24px, 5vw, 40px); text-shadow: none; color: #fff; margin: 6px 0; }

/* controls */
.controls { display: flex; gap: 10px; margin: 8px 0 24px; justify-content: center; flex-wrap: wrap; }
.controls button {
  background: var(--glass); color: var(--on); border: 1px solid var(--glass-bd);
  border-radius: 999px; padding: 9px 18px; font-size: 14px; cursor: pointer; transition: all .15s;
  backdrop-filter: blur(6px);
}
.controls button:hover { background: rgba(255,255,255,.14); }
.controls button.on { background: #fff; color: var(--felt-dk); border-color: #fff; font-weight: 600; }

/* ===== the deck ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 20px; }

.pcard {
  position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 8px; padding: 38px 14px; aspect-ratio: 5 / 7; border-radius: 16px;
  background: linear-gradient(150deg, #ffffff, var(--cream));
  color: var(--ink); text-decoration: none; overflow: hidden;
  box-shadow: 0 10px 26px rgba(6,26,18,.42), inset 0 0 0 1px rgba(20,50,36,.06);
  cursor: pointer; transition: transform .18s ease, box-shadow .18s ease;
}
.pcard:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 0 20px 44px rgba(6,26,18,.5); }
.pcard .corner {
  position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center;
  font-weight: 700; line-height: .9; font-variant-numeric: tabular-nums;
}
.pcard .corner em { font-style: normal; font-size: 16px; }
.pcard .corner i { font-style: normal; font-size: 14px; }
.pcard .corner.tl { top: 11px; left: 12px; }
.pcard .corner.br { bottom: 11px; right: 12px; transform: rotate(180deg); }
.pcard .pip {
  position: absolute; inset: 0; z-index: 0; display: grid; place-items: center;
  font-size: 78px; opacity: .07; pointer-events: none;
}
.pcard .pc-name {
  position: relative; z-index: 1; text-align: center; max-width: 100%;
  font-weight: 700; font-size: 14px; line-height: 1.24; letter-spacing: -.01em;
  overflow-wrap: anywhere; hyphens: auto;
}
.pcard .pc-sub {
  position: relative; z-index: 1; text-align: center;
  font-size: 11px; color: var(--ink-dim); font-family: var(--mono);
}
/* enlarged card front inside the modal reads bigger */
.deck-modal .pc-name { font-size: 21px; }
.deck-modal .pc-sub { font-size: 13px; }
.deck-modal .pip { font-size: 150px; }
.deck-modal .corner em { font-size: 24px; }
.deck-modal .corner i { font-size: 20px; }
.pcard .pc-flag { position: absolute; top: 11px; right: 12px; width: 9px; height: 9px; border-radius: 50%; }
/* suit colors */
.suit-heart .corner, .suit-heart .pip, .suit-diamond .corner, .suit-diamond .pip { color: var(--suit-red); }
.suit-spade .corner, .suit-spade .pip, .suit-club .corner, .suit-club .pip { color: var(--ink); }
/* status flag */
.st-active .pc-flag { background: var(--green); box-shadow: 0 0 10px var(--green); }
.st-contested .pc-flag { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.st-lapse { outline: 2px solid var(--red); outline-offset: -2px; }
.st-lapse .pc-flag { background: var(--red); box-shadow: 0 0 12px var(--red); animation: pulse 1.4s infinite; }
.st-contested { background: linear-gradient(150deg, #fff, #fff4e6); }
@keyframes pulse { 50% { opacity: .35; } }

/* ===== flip-to-center modal ===== */
.deck-stage { position: fixed; inset: 0; z-index: 60; display: none; perspective: 1800px; }
.deck-stage.show { display: flex; align-items: center; justify-content: center; }
.deck-overlay {
  position: absolute; inset: 0; background: rgba(4,20,13,.66); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .4s ease;
}
.deck-stage.show .deck-overlay { opacity: 1; }
/* flex centers the modal; the FLIP animation is free to target transform:none without
   fighting a centering translate. width is bounded by height so tall cards fit the viewport. */
.deck-modal {
  position: relative; margin: 0; width: min(400px, 92vw, 62vh); max-height: 92vh;
  transform-style: preserve-3d;
}
.pcard-flip { position: relative; transform-style: preserve-3d; will-change: transform; }
.pcard-flip > .front,
.pcard-flip > .back { border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
/* explicit transform: Safari only backface-culls faces that are 3D-positioned themselves */
.pcard-flip > .front { aspect-ratio: 5 / 7; transform: rotateY(0deg); }
.pcard-flip > .back {
  position: absolute; inset: 0; transform: rotateY(180deg);
  background: linear-gradient(155deg, #ffffff, var(--cream)); color: var(--ink);
  padding: 26px 26px 22px; overflow-y: auto; box-shadow: 0 30px 80px rgba(8,4,36,.6);
  display: flex; flex-direction: column; gap: 10px;
}
.deck-modal .pcard { box-shadow: 0 30px 80px rgba(8,4,36,.6); cursor: default; }
.deck-modal .pcard:hover { transform: none; }
.back h3 { margin: 4px 0 2px; font-size: 22px; letter-spacing: -.02em; }
.back .bigcount.small { color: var(--suit-red); text-align: left; }
.back .blurb { font-size: 15.5px; color: #26372c; margin: 4px 0; }
.back .mono { color: var(--ink-dim); }
.back table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.back table.mini td { padding: 5px 4px; border-bottom: 1px solid rgba(28,22,96,.12); }
.back table.mini a { color: var(--felt); text-decoration: none; }
.deck-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 26px; line-height: 1; color: var(--ink-dim); cursor: pointer;
}
.deck-more { margin-top: auto; font-weight: 600; color: var(--felt); text-decoration: none; font-size: 14px; }

/* badges */
.badge { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; padding: 4px 9px; border-radius: 6px; white-space: nowrap; display: inline-block; }
.badge.active { background: #16351f; color: #7ff0b8; }
.badge.contested { background: #3a2a0e; color: var(--amber); }
.badge.lapse { background: #3a1114; color: #ff8a8f; animation: pulse 1.6s infinite; }
.badge.plain { background: rgba(28,22,96,.09); color: var(--ink-dim); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

/* generic glass panels for the other pages */
.case, .trace, .g-panel, .review-row {
  background: var(--glass); border: 1px solid var(--glass-bd); border-radius: 20px;
  backdrop-filter: blur(12px); box-shadow: 0 12px 40px rgba(10,6,40,.28);
}
.case { padding: 30px 34px; margin: 24px auto; max-width: 800px; }
.case h2 { margin-top: 0; }
.case-year { font-family: var(--mono); color: var(--red); font-size: 34px; font-weight: 800; }
.lock { color: var(--amber); font-weight: 600; }
.case.final { border-color: rgba(255,90,96,.5); background: rgba(255,90,96,.08); }
.case.clicked { animation: clunk .4s; }
@keyframes clunk { 0%{transform:translateX(0)} 30%{transform:translateX(7px)} 100%{transform:translateX(0)} }
.ratchet-counter { font-family: var(--mono); color: var(--amber); font-size: 20px; margin-top: 14px; }

/* horizontal ratchet timeline */
.rk-wrap { position: relative; margin: 10px 0 40px; }
.rk-track {
  display: flex; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 34px 0 24px; cursor: grab; -webkit-overflow-scrolling: touch;
}
.rk-track.drag { cursor: grabbing; scroll-snap-type: none; }
.rk-track::-webkit-scrollbar { height: 9px; }
.rk-track::-webkit-scrollbar-track { background: rgba(0,0,0,.18); border-radius: 9px; }
.rk-track::-webkit-scrollbar-thumb { background: rgba(255,255,255,.24); border-radius: 9px; }

.rk-stop {
  position: relative; flex: 0 0 300px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; padding: 0 14px;
}
/* the toothed spine running through the nodes */
.rk-stop::before {
  content: ""; position: absolute; top: 19px; left: 0; right: 0; height: 3px; z-index: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.34) 0 10px, transparent 10px 20px);
}
.rk-stop:first-child::before { left: 50%; }
.rk-stop.rk-final::before { right: 50%; }
.rk-node {
  position: relative; z-index: 1; min-width: 78px; height: 40px; padding: 0 14px;
  display: grid; place-items: center; border-radius: 999px;
  background: var(--felt-dk); border: 2px solid var(--amber);
  box-shadow: 0 0 0 7px var(--felt), 0 6px 16px rgba(0,0,0,.4);
  transition: transform .2s ease;
}
.rk-year { font-family: var(--mono); font-weight: 700; font-size: 14px; color: #fff; white-space: nowrap; }
.rk-card {
  margin-top: 26px; width: 100%; background: var(--glass); border: 1px solid var(--glass-bd);
  border-radius: 16px; padding: 18px 20px; backdrop-filter: blur(10px); min-height: 250px;
  box-shadow: 0 12px 34px rgba(6,26,18,.28);
}
.rk-card h2 { margin: 0 0 8px; font-size: 19px; letter-spacing: -.01em; }
.rk-card p { font-size: 14.5px; line-height: 1.5; margin: 6px 0; }
.rk-card .lock { color: var(--amber); font-weight: 600; margin-top: 12px; }
.rk-final .rk-node { border-color: var(--red); box-shadow: 0 0 0 7px var(--felt), 0 0 18px rgba(255,90,96,.5); }
.rk-final .rk-card { border-color: rgba(255,90,96,.5); background: rgba(255,90,96,.09); }
.rk-stop.clicked .rk-node { animation: nodepop .45s ease; }
@keyframes nodepop { 40% { transform: scale(1.16); } 100% { transform: scale(1); } }
.rk-hint { text-align: right; color: var(--dim); font-family: var(--mono); font-size: 12px; letter-spacing: .08em; padding: 6px 6px 0; }

/* tracer */
.trace { max-width: 880px; margin: 26px auto; padding: 24px 28px; }
.claim { font-size: 22px; font-weight: 700; margin-bottom: 14px; color: #fff; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.split h3 { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; margin: 0 0 8px; }
.kernel { background: rgba(69,224,160,.1); border: 1px solid rgba(69,224,160,.3); border-radius: 14px; padding: 16px 18px; }
.kernel h3 { color: var(--green); }
.graft { background: rgba(255,90,96,.1); border: 1px solid rgba(255,90,96,.3); border-radius: 14px; padding: 16px 18px; }
.graft h3 { color: var(--red); }
@media (max-width: 700px) { .split { grid-template-columns: 1fr; } }

/* detail pages */
.detail h1 { margin-bottom: 8px; font-size: clamp(28px,5vw,40px); letter-spacing: -.02em; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.crumb a { color: var(--dim); text-decoration: none; font-size: 14px; }
.blurb { font-size: 19px; max-width: 780px; color: var(--on); }
.mono { font-family: var(--mono); font-size: 13px; color: var(--dim); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
th { color: var(--dim); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; }
td a { color: #fff; }

/* review */
.progress { height: 12px; background: rgba(255,255,255,.12); border-radius: 999px; max-width: 500px; margin: 16px auto 6px; overflow: hidden; }
#prog-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), #7ff0b8); transition: width .4s; }
.verdict { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.verdict button { background: rgba(28,22,96,.08); color: var(--ink); border: 1px solid rgba(28,22,96,.18); border-radius: 999px; padding: 7px 15px; cursor: pointer; font-size: 14px; }
.back .verdict button { }
.review-row .verdict button { background: var(--glass); color: var(--on); border-color: var(--glass-bd); }
.verdict button.on { border-color: var(--red); color: var(--red); font-weight: 600; }
.verdict-state { font-family: var(--mono); font-size: 13px; color: var(--dim); }
.review-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 14px 18px; margin: 10px auto; max-width: 880px; flex-wrap: wrap; }
.review-row .name { font-weight: 600; }
.review-row .name a { text-decoration: none; }
.review-row .sub { color: var(--dim); font-size: 13px; }

/* game */
#game { max-width: 800px; margin: 0 auto; }
.g-panel { padding: 24px 28px; margin: 16px 0; }
.g-crisis { border-color: rgba(255,180,84,.5); background: rgba(255,180,84,.08); }
.g-stat { font-family: var(--mono); font-size: 14px; color: var(--dim); display: flex; gap: 20px; flex-wrap: wrap; }
.g-stat b { color: #fff; }
.g-panel button { background: #fff; color: var(--felt-dk); border: none; border-radius: 999px; padding: 9px 18px; font-weight: 600; cursor: pointer; margin: 3px 4px 0 0; }
.g-panel button:hover { background: var(--cream); }
.power { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.12); }
.power .p-meta { color: var(--dim); font-size: 13px; }
.g-log { font-family: var(--mono); font-size: 13px; color: var(--dim); max-height: 190px; overflow-y: auto; }
.g-log .warn { color: var(--amber); }
.g-log .bad { color: var(--red); }
.g-end { border-color: rgba(255,90,96,.5); background: rgba(255,90,96,.08); text-align: center; }
.g-end .bigcount { font-size: 42px; }

.facts li { margin: 11px 0; }
pre { background: rgba(0,0,0,.28); padding: 14px 18px; border-radius: 12px; overflow-x: auto; font-size: 13px; border: 1px solid rgba(255,255,255,.1); }
footer { border-top: 1px solid rgba(255,255,255,.12); color: var(--dim); font-size: 13px; padding: 24px 26px; max-width: 1120px; margin: 50px auto 0; }
footer a { color: var(--dim); }

@media (prefers-reduced-motion: reduce) {
  *, .pcard-flip, .deck-modal { transition: none !important; animation: none !important; }
}
