/* Page basics the claude.ai viewer adds by itself; the public site needs them too */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
[hidden] { display: none !important; }

/* Layout: a dark Tyrian-purple gaming table; two marble cards face to face, the verdict between them. Single dark look by choice. */
:root {
  --table: #1c1219;
  --table-2: #2a1b26;
  --table-line: #3d2a37;
  --on-table: #efe6dc;
  --on-table-soft: #b9a7aa;
  --marble: #f4f0ea;
  --marble-vein: #e2dbd1;
  --ink: #24191f;
  --ink-soft: #6b5a60;
  --gold: #c9a54e;
  --tyrian: #7b2150;
  --win: #2f7a4a;
  --lose: #a3352d;
  --tie: #8a7432;
  --grp-A: #8a6a3b;
  --grp-B: #9b2f2a;
  --grp-C: #6a2a6e;
  --grp-D: #2f5f6e;
  --grp-E: #4f5a2c;
  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Alegreya Sans", "Gill Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--table); }
body {
  color: var(--on-table);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 48px;
  background:
    radial-gradient(ellipse at 50% 0%, var(--table-2), transparent 70%),
    var(--table);
  min-height: 100%;
}
.wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 20px; }

/* Header and score */
.top { display: grid; gap: 12px; }
.brand { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  letter-spacing: 0.08em;
  margin: 0;
  color: var(--gold);
}
.brand small { color: var(--on-table-soft); font-size: 0.9rem; letter-spacing: 0.04em; }
.score { display: grid; gap: 6px; }
.score-row { display: flex; justify-content: space-between; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.score-row b { font-weight: 700; }

/* Difficulty picker: a segmented control; changing it starts a new game */
.level-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.level-label {
  font-family: var(--display); font-size: 0.75rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--on-table-soft);
}
.levels { display: inline-flex; border: 1px solid var(--table-line); border-radius: 8px; overflow: hidden; }
.levels button {
  font-family: var(--display); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em;
  background: transparent; color: var(--on-table-soft); border: 0; padding: 6px 12px; cursor: pointer;
}
.levels button + button { border-left: 1px solid var(--table-line); }
.levels button[aria-checked="true"] { background: var(--gold); color: var(--ink); }
.levels button:hover:not([aria-checked="true"]) { color: var(--on-table); background: var(--table-2); }
.levels button:focus-visible { outline: 2px solid var(--on-table); outline-offset: -2px; }
.level-blurb { font-size: 0.88rem; color: var(--on-table-soft); flex: 1 1 200px; min-width: 0; }
.bar { height: 8px; border-radius: 4px; background: var(--tyrian); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); transition: width 0.4s ease; }

/* Table */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.seat { display: grid; gap: 8px; min-width: 0; }
.seat-label {
  font-family: var(--display);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-table-soft);
  display: flex; justify-content: space-between;
}
@media (max-width: 720px) { .board { grid-template-columns: 1fr; } }

/* Card */
.flip { perspective: 1200px; }
.flip-inner { display: grid; transition: transform 0.55s ease; transform-style: preserve-3d; }
.flip-inner > * { grid-area: 1 / 1; backface-visibility: hidden; }
.flip.down .flip-inner { transform: rotateY(180deg); }
.back { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) { .flip-inner, .bar span { transition: none; } }

.card {
  background:
    radial-gradient(ellipse 60% 30% at 20% 15%, var(--marble-vein), transparent 70%),
    radial-gradient(ellipse 50% 25% at 85% 70%, var(--marble-vein), transparent 70%),
    var(--marble);
  color: var(--ink);
  border-radius: 14px;
  border: 3px solid var(--gold);
  overflow: hidden;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  display: grid;
  container-type: inline-size;
}
.card-head {
  background: var(--grp);
  color: var(--marble);
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  font-family: var(--display);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  gap: 8px;
}
.card-head .cid { font-weight: 700; font-size: 1rem; letter-spacing: 0.04em; }
.card-head .era { text-align: right; }
.ident { display: flex; gap: 12px; align-items: center; padding: 12px 12px 8px; }
.coin {
  flex: none;
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #e8cf8a, var(--gold) 55%, #8f7232);
  color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 1.3rem;
  border: 2px solid #8f7232;
  box-shadow: inset 0 0 0 3px rgb(255 255 255 / 0.25);
  overflow: hidden;
}
.coin img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ident h2 {
  font-family: var(--display); font-weight: 700;
  /* Shrinks on narrow cards so every name stays on one line */
  font-size: clamp(0.85rem, 5.6cqi, 1.2rem); line-height: 1.15; margin: 0;
  white-space: nowrap;
}
/* Card names link to Wikipedia: quiet until hovered */
.ident h2 a { color: inherit; text-decoration: none; }
.ident h2 a:hover { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 3px; }
.ident h2 a:focus-visible { outline: 2px solid var(--tyrian); outline-offset: 2px; border-radius: 2px; }
.dates { margin: 2px 0 0; font-size: 0.85rem; color: var(--ink-soft); }
.legend {
  display: inline-block; margin-left: 6px;
  font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--ink-soft); border-radius: 4px; padding: 0 5px;
  vertical-align: 1px;
}
.stats { list-style: none; margin: 0; padding: 4px 8px 10px; display: grid; gap: 3px; }
.stat {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  font: inherit; color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  text-align: left;
}
.stat .val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.stat .meter { flex: 1; height: 4px; margin: 0 10px; background: var(--marble-vein); border-radius: 2px; overflow: hidden; }
.stat .meter i { display: block; height: 100%; background: var(--grp); opacity: 0.7; }
.lbl { min-width: 7.6em; }
button.stat { cursor: pointer; border-color: var(--marble-vein); background: rgb(255 255 255 / 0.5); }
button.stat:hover { border-color: var(--gold); background: #fff; }
button.stat:focus-visible { outline: 3px solid var(--tyrian); outline-offset: 1px; }
.stat.chosen { border-color: var(--ink); background: #fff; }
.stat.win { border-color: var(--win); background: color-mix(in srgb, var(--win) 14%, #fff); }
.stat.lose { border-color: var(--lose); background: color-mix(in srgb, var(--lose) 12%, #fff); }
.stat.tie { border-color: var(--tie); background: color-mix(in srgb, var(--tie) 14%, #fff); }
/* Fixed two-line slot so every card is the same height before and after a reveal */
.note {
  margin: 0 12px 12px;
  padding-top: 8px;
  border-top: 1px solid var(--marble-vein);
  font-size: 0.88rem; font-style: italic; color: var(--ink-soft);
  line-height: 1.35;
  height: calc(2 * 1.35em + 8px);
  overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.stats { padding-bottom: 8px; }

.back {
  background: var(--tyrian);
  border-radius: 14px;
  border: 3px solid var(--gold);
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  min-height: 100%;
}
.back-inner {
  border: 1px solid var(--gold);
  border-radius: 8px;
  inset: 12px;
  position: absolute;
  display: grid; place-items: center;
}
.back span {
  font-family: var(--display); font-weight: 700;
  color: var(--gold); font-size: 2.2rem; letter-spacing: 0.18em;
}
.back { position: relative; }
.back-inner > div { display: grid; justify-items: center; gap: 6px; }
.back em {
  font-family: var(--display); font-style: normal;
  color: var(--gold); font-size: 0.8rem; letter-spacing: 0.22em; text-transform: uppercase;
}

/* Verdict */
.verdict {
  background: var(--table-2);
  border: 1px solid var(--table-line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.verdict p { margin: 0; min-width: 0; flex: 1 1 260px; }
.verdict .tag {
  display: inline-block; font-family: var(--display); font-size: 0.75rem; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 4px; margin-right: 6px;
  background: var(--table-line); color: var(--on-table);
}
.verdict .tag.win { background: var(--win); }
.verdict .tag.lose { background: var(--lose); }
.verdict .tag.tie { background: var(--tie); }
.go {
  font-family: var(--display); font-weight: 700; letter-spacing: 0.08em;
  font-size: 0.95rem;
  background: var(--gold); color: var(--ink);
  border: 0; border-radius: 8px; padding: 10px 18px; cursor: pointer;
}
.go:hover { filter: brightness(1.08); }
.go:focus-visible { outline: 3px solid var(--on-table); outline-offset: 2px; }

/* Deck reference */
details.deck { border-top: 1px solid var(--table-line); padding-top: 12px; }
details.deck summary {
  cursor: pointer; font-family: var(--display); letter-spacing: 0.1em; color: var(--gold);
  font-size: 0.95rem;
}
.deck-hint { color: var(--on-table-soft); font-size: 0.9rem; margin: 8px 0; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--table-line); text-align: right; white-space: nowrap; }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
th button {
  font: inherit; color: var(--on-table-soft); background: none; border: 0; cursor: pointer; padding: 0;
  letter-spacing: 0.04em;
}
th button[aria-sort] { color: var(--gold); }
td.top { color: var(--gold); font-weight: 700; }
.credits { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.88rem; color: var(--on-table-soft); }
.credits b { color: var(--on-table); font-weight: 500; }
.credits a { color: var(--gold); }
