/* Framed stats — paper-and-marquee look, light and dark, phone first. */
:root {
  --bg: #f5f1ea;
  --card: #fffdf8;
  --ink: #1e1b18;
  --muted: #736c63;
  --line: #e4ddd1;
  --soft: #efe9df;
  --accent: #b8432f;      /* cinema-seat red, for links and highlights */
  --gold: #c98a12;        /* marquee bulb, for "best" */
  --win: #2f8f57;
  --loss: #c4413b;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131210; --card: #1c1a17; --ink: #f2ede5; --muted: #a39b90; --line: #2e2a25;
    --soft: #24211d; --accent: #e9775f; --gold: #e2a93b; --win: #4fbf7d; --loss: #e66a63;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p { margin: .25rem 0 .75rem; }
small, .muted { color: var(--muted); }

/* ---- top bar ---- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top .inner { max-width: 1100px; margin: 0 auto; padding: .6rem 16px; display: flex; gap: .5rem 1rem; align-items: center; flex-wrap: wrap; }
.top .post { order: 3; margin-left: auto; padding: .4rem .85rem; border-radius: 999px; font-size: .92rem; }
.brand { font-family: var(--serif); font-size: 1.25rem; font-style: italic; color: var(--ink); white-space: nowrap; }
.brand b { font-style: normal; color: var(--accent); }
nav.links { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav.links::-webkit-scrollbar { display: none; }
nav.links a {
  color: var(--muted); padding: .35rem .65rem; border-radius: 999px; white-space: nowrap; font-size: .92rem;
}
nav.links a.on, nav.links a:hover { color: var(--ink); background: var(--soft); text-decoration: none; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head p { margin: 0; }

/* ---- cards & grid ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.card + .card, .stack > * + * { margin-top: 1rem; }
.grid > .card, .grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid.tight { gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.section { margin-top: 1.75rem; }

/* ---- stat tiles ---- */
.tiles { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; }
.tile .v { font-family: var(--serif); font-size: 1.6rem; line-height: 1.1; }
.tile .k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---- bragging rights ---- */
.brag { display: flex; flex-direction: column; gap: .15rem; position: relative; overflow: hidden; }
.brag::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--gold);
}
.brag .t { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.brag .h { font-family: var(--serif); font-size: 1.2rem; }
.brag .d { font-size: .85rem; color: var(--muted); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -1.1rem; padding: 0 1.1rem; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: .5rem .55rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
th:first-child, td:first-child, td.l, th.l { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--soft); }
td.name { font-weight: 600; text-align: left; }
th.name { text-align: left; }
td .sub { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }
.best { color: var(--gold); font-weight: 700; }
.best::after { content: " ★"; font-size: .8em; }
.rank { color: var(--muted); width: 1.5rem; }
.win { color: var(--win); } .loss { color: var(--loss); }
.wrap { white-space: normal; }

/* ---- distribution bars ---- */
.dist { display: flex; gap: 2px; align-items: flex-end; height: 26px; min-width: 112px; }
.dist span { flex: 1; background: var(--win); opacity: .75; border-radius: 2px 2px 0 0; min-height: 2px; }
.dist span.x { background: var(--loss); }
.distbig { display: grid; grid-template-columns: 1.5rem 1fr 2.5rem; gap: .35rem .6rem; align-items: center; }
.distbig .bar { height: 20px; background: var(--win); border-radius: 4px; min-width: 3px; }
.distbig .bar.x { background: var(--loss); }

/* ---- squares ---- */
.squares { letter-spacing: 1px; font-size: 1rem; white-space: nowrap; }

/* ---- pills, tabs, filters ---- */
.pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.pill {
  display: inline-block; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink); background: var(--card); font-size: .88rem;
}
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill:hover { text-decoration: none; border-color: var(--muted); }
.tag { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--soft); color: var(--muted); }
.tag.matched, .tag.manual { color: var(--win); }
.tag.fuzzy { color: var(--gold); }
.tag.ambiguous, .tag.unmatched { color: var(--loss); }

form.filters { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
form.filters input[type=date] { width: auto; padding: .3rem .45rem; font-size: .85rem; }

/* ---- forms ---- */
label { display: block; font-size: .85rem; color: var(--muted); margin: .6rem 0 .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem;
}
textarea { min-height: 8.5rem; font-size: 1.05rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
button, .btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: .6rem 1rem;
}
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.small { padding: .3rem .6rem; font-size: .82rem; }
button:hover, .btn:hover { filter: brightness(1.06); text-decoration: none; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 120px; }
.row > .shrink { flex: 0 0 auto; }

.flash {
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: .6rem .9rem; margin-bottom: 1rem;
}
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* autocomplete */
.ac { position: relative; }
.ac ul {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; list-style: none; margin: .25rem 0 0; padding: .25rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; max-height: 300px; overflow: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.ac li { padding: .45rem .55rem; border-radius: 8px; cursor: pointer; }
.ac li:hover, .ac li.on { background: var(--soft); }

.chart-box { position: relative; height: 320px; }
.chart-box.small { height: 220px; }

/* puzzle page */
.movie-hero { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: start; }
.movie-hero .title { font-family: var(--serif); font-size: clamp(1.5rem, 5vw, 2.3rem); line-height: 1.1; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pager { display: flex; justify-content: space-between; margin-top: 1rem; }

@media (max-width: 600px) {
  main { padding-top: 1rem; }
  .brand { font-size: 1.05rem; }
  nav.links { order: 4; flex-basis: 100%; margin: 0 -16px; padding: 0 16px; }
  .grid.tight { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .brag { padding: .7rem .8rem; }
  .brag .h { font-size: 1.02rem; }
  .brag .t { font-size: .7rem; }
  .hide-sm { display: none; }
  .card { padding: .9rem; }
  .table-wrap { margin: 0 -.9rem; padding: 0 .9rem; }
}
code { overflow-wrap: anywhere; font-size: .9em; }

/* ---- players tab + personal page ---- */
.playercard { display: block; color: var(--ink); text-decoration: none; }
.playercard:hover { border-color: var(--accent); text-decoration: none; }
.pc-top { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .6rem; }
.pc-rank { color: var(--gold); font-weight: 700; }
.pc-name { font-family: var(--serif); font-size: 1.4rem; }
.pc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.pc-stats .v { font-family: var(--serif); font-size: 1.2rem; }
.pc-stats .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

.heat-wrap { overflow-x: auto; padding-bottom: .25rem; }
.heat { display: flex; gap: 3px; width: max-content; }
.heat .wk { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; }
.heat .cell { width: 12px; height: 12px; border-radius: 2px; background: var(--soft); }
.heat .cell.none { background: transparent; }
.heat .s1 { background: var(--win); } .heat .s2 { background: color-mix(in srgb, var(--win) 80%, var(--card)); }
.heat .s3 { background: color-mix(in srgb, var(--win) 55%, var(--card)); }
.heat .s4 { background: color-mix(in srgb, var(--gold) 70%, var(--card)); }
.heat .s5 { background: var(--gold); }
.heat .s6 { background: color-mix(in srgb, var(--loss) 60%, var(--card)); }
.heat .s7 { background: var(--loss); }
.heat-legend { display: flex; gap: .35rem; align-items: center; margin-top: .5rem; color: var(--muted); font-size: .75rem; }
.heat-legend .cell { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.heat-legend .s1 { background: var(--win); } .heat-legend .s3 { background: color-mix(in srgb, var(--win) 55%, var(--card)); }
.heat-legend .s5 { background: var(--gold); } .heat-legend .s7 { background: var(--loss); }
.heat-legend .none { background: var(--soft); }
.trophy { font-size: 1.05rem; margin: .1rem 0 .6rem; }
