:root {
  --bg: #f7f1e6;
  --surface: #fffaf2;
  --surface-2: #f0e6d4;
  --ink: #2a2118;
  --muted: #7a6a58;
  --line: #e2d4bd;
  --accent: #c2541b;      /* torch */
  --accent-ink: #ffffff;
  --sea: #1f6f78;
  --good: #2f7d43;
  --bad: #b23a2f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --surface: #211b15;
    --surface-2: #2c241c;
    --ink: #f3e9da;
    --muted: #a8977f;
    --line: #3a3026;
    --accent: #ec7a3b;
    --accent-ink: #1a120b;
    --sea: #5fb6bf;
    --good: #6cc282;
    --bad: #ee7c70;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; padding-bottom: 6px; }
.brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 0; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600;
  padding: 10px 12px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap;
}
.tabs button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { padding-top: 20px; padding-bottom: 40px; }
.foot { padding-bottom: 32px; color: var(--muted); font-size: .875rem; }
.foot button { font-size: .875rem; }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pill {
  display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted);
}
.pill.open { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pill.locked { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.scored { background: color-mix(in srgb, var(--sea) 18%, transparent); color: var(--sea); }
.banner {
  border: 1px dashed var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: .9rem;
}

/* forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 120px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--sea); outline-offset: 2px;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 140px; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; margin: 0; }
.choice input { margin: 0; }
button {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 8px; padding: 10px 16px; min-height: 44px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
button.link { background: none; border: 0; color: var(--sea); padding: 0; min-height: 0; font-weight: 600; text-decoration: underline; }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small { padding: 6px 10px; min-height: 36px; font-size: .875rem; }
button:disabled { opacity: .5; cursor: default; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hit { color: var(--good); font-weight: 700; }
.miss { color: var(--bad); }

/* standings */
.standing { border-bottom: 1px solid var(--line); }
.standing:last-child { border-bottom: 0; }
.standing summary {
  list-style: none; display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 10px; align-items: center;
  padding: 12px 0; cursor: pointer;
}
.standing summary::-webkit-details-marker { display: none; }
.rank { font-weight: 800; font-size: 1.1rem; color: var(--muted); text-align: center; }
.standing:first-child .rank { color: var(--accent); }
.total { font-weight: 800; font-size: 1.3rem; font-variant-numeric: tabular-nums; text-align: right; }
.sub { font-size: .8rem; color: var(--muted); }
.breakdown { padding: 0 0 12px 3.2rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); }
.chip.out { text-decoration: line-through; color: var(--muted); }

.grid-cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.cast .name { overflow-wrap: anywhere; line-height: 1.25; }
.cast { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg);
  display: flex; gap: 10px; align-items: center; }
.cast-info { min-width: 0; }
.cast.out { opacity: .55; }
.cast.out .avatar img { filter: grayscale(1); }

.avatar {
  position: relative; flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  display: inline-grid; place-items: center; background: var(--surface-2); color: var(--muted);
  font-weight: 800; font-size: .95rem; border: 2px solid var(--line);
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: .7rem; border-width: 1px; }
.name-cell { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.cast .name { font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); box-shadow: var(--shadow); font-weight: 600;
}
.toast.error { background: var(--bad); color: #fff; }
.lookup-msg { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.lookup-msg.ok { border-color: var(--good); color: var(--good); }
.custom-ep summary { cursor: pointer; color: var(--sea); font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
