
:root {
  color-scheme: dark;
  --bg: #1a0e09;
  --bg-deep: #100806;
  --surface: #2a1710;
  --surface-light: #3a2114;
  --surface-dark: #21110c;
  --line: #754723;
  --line-soft: #4d2b18;
  --text: #f6e8c9;
  --muted: #c5a77b;
  --amber: #e3a83c;
  --amber-light: #ffd978;
  --green: #84985a;
  --green-dark: #4f6539;
  --red: #9d3f35;
  --red-dark: #5f2928;
  --gold: #e4b95c;
  --shadow: 0 14px 28px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { background: var(--bg-deep); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(184, 104, 34, .22), transparent 42%),
    repeating-linear-gradient(8deg, rgba(255, 214, 132, .025) 0 2px, transparent 2px 7px),
    var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", system-ui, sans-serif;
  line-height: 1.5;
}
body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: .16;
  background-image: radial-gradient(rgba(255, 230, 170, .22) .7px, transparent .7px);
  background-size: 5px 5px;
  mix-blend-mode: soft-light;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, .brand, .champion-name, .score-value {
  font-family: Georgia, "Times New Roman", serif;
}
h1 { font-size: clamp(2rem, 5vw, 3.55rem); line-height: 1.05; margin: 0 0 .7rem; letter-spacing: -.035em; }
h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
p { margin-top: 0; }
.muted, small { color: var(--muted); }
.eyebrow {
  color: var(--amber-light);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.topbar {
  align-items: center;
  background: rgba(25, 12, 7, .96);
  border-bottom: 3px solid var(--line);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .3);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  padding: .85rem max(1rem, calc((100vw - 1180px) / 2));
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { color: var(--amber-light); font-size: 1.15rem; font-weight: 900; letter-spacing: -.03em; white-space: nowrap; }
.topbar nav { display: flex; gap: .25rem; overflow: auto; }
.topbar nav a {
  border: 1px solid transparent;
  border-radius: .45rem;
  color: var(--muted);
  font-size: .9rem;
  padding: .42rem .7rem;
  white-space: nowrap;
}
.topbar nav a:hover { background: var(--surface-light); border-color: var(--line); color: var(--amber-light); }
.page-shell { margin: 0 auto; max-width: 1180px; padding: 2rem 1rem 4rem; }
.footer { color: var(--muted); font-size: .78rem; padding: 1rem; text-align: center; }
.hero, .page-header, .game-header { align-items: center; display: flex; gap: 1.5rem; justify-content: space-between; margin-bottom: 2rem; }
.hero {
  background:
    linear-gradient(135deg, rgba(119, 62, 28, .92), rgba(54, 25, 14, .96)),
    repeating-linear-gradient(0deg, transparent 0 8px, rgba(255, 210, 120, .05) 8px 10px);
  border: 2px solid #925d2d;
  border-radius: .9rem;
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(27, 12, 6, .25);
  padding: clamp(1.5rem, 5vw, 3rem);
  position: relative;
}
.hero::after {
  position: absolute;
  right: 1.5rem;
  top: 1rem;
  content: "? ? ? ?";
  color: rgba(255, 220, 135, .18);
  font-family: Georgia, serif;
  font-size: 2.2rem;
  letter-spacing: .35rem;
}
.hero h1 { max-width: 680px; }
.hero .muted { max-width: 630px; }
.champion-card {
  background: linear-gradient(135deg, #4b2a15, #28150d);
  border: 2px solid #a06a2e;
  border-radius: .85rem;
  box-shadow: var(--shadow), inset 0 0 28px rgba(0, 0, 0, .18);
  margin-bottom: 1rem;
  padding: 1.5rem;
}
.champion-card .section-heading { color: var(--amber-light); }
.champion-name { color: #ffe3a0; display: block; font-size: clamp(2rem, 5vw, 3rem); font-weight: 900; margin: .5rem 0; text-shadow: 2px 2px #3a190d; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  background: linear-gradient(160deg, var(--surface-light), var(--surface));
  border: 1px solid var(--line);
  border-radius: .75rem;
  box-shadow: var(--shadow), inset 0 1px rgba(255, 221, 148, .08);
  padding: 1.25rem;
}
.section-heading { align-items: center; display: flex; gap: 1rem; justify-content: space-between; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; }
.badge { background: #492a18; border: 1px solid var(--line); border-radius: 999px; color: #f6dca4; display: inline-block; font-size: .73rem; padding: .18rem .55rem; }
.badge-gold { background: #624817; border-color: #c28d32; color: #ffe8a1; }
.badge-completed { background: #3d5a32; color: #e6f0bf; }
.badge-aborted { background: #622f2b; color: #ffd0c2; }
.badge-active { background: #6a491d; color: #ffe5a1; }
.stat-grid { display: grid; gap: .7rem; grid-template-columns: repeat(3, 1fr); margin: 1rem 0; }
.stat { background: var(--surface-dark); border: 1px solid var(--line-soft); border-radius: .55rem; padding: .75rem; }
.stat strong { color: var(--amber-light); display: block; font-family: Georgia, serif; font-size: 1.65rem; }
.stat span { color: var(--muted); font-size: .78rem; }
.stat-grid-large { grid-template-columns: repeat(6, 1fr); margin-bottom: 1.5rem; }
.stat-grid-large .stat { padding: 1rem; }
.text-link { color: var(--amber-light); font-weight: 800; }
.text-link:hover { color: white; text-decoration: underline; }
.compact-list, .admin-list, .final-score-list { display: grid; gap: .4rem; }
.list-row, .admin-row, .reign-row, .final-score-row { align-items: center; border-bottom: 1px solid var(--line-soft); display: flex; gap: .75rem; justify-content: space-between; padding: .75rem 0; }
.list-row:last-child, .admin-row:last-child { border-bottom: 0; }
.list-row small, .player-cell small, .sound-row small { display: block; font-size: .75rem; }
.list-row:hover { color: var(--amber-light); }
.list-result { color: var(--amber-light); font-weight: 900; }
.button { align-items: center; border: 1px solid transparent; border-radius: .5rem; display: inline-flex; font-weight: 900; gap: .45rem; justify-content: center; padding: .7rem 1rem; transition: transform .14s, filter .14s; }
.button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button-primary { background: linear-gradient(#f1c45f, #c98826); border-color: #8b5a1b; color: #321607; box-shadow: 0 3px 0 #704317; }
.button-secondary { background: var(--green-dark); border-color: #9aa96c; color: #f1f1ce; }
.button-danger { background: var(--red-dark); border-color: #bb5a4a; color: #ffd9cc; }
.button-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.button-large { font-size: 1.1rem; padding: 1rem 1.3rem; }
.button-small { font-size: .78rem; padding: .45rem .65rem; }
.alert { border: 1px solid; border-radius: .55rem; margin-bottom: 1rem; padding: .8rem 1rem; }
.alert-error { background: #4e211e; border-color: #a64c3d; color: #ffd8c7; }
.callout { background: #463118; border: 1px solid #9f7531; border-radius: .6rem; padding: 1rem; }
.callout p { margin: 0; }
.callout-gold { background: #5b4219; border-color: #d09d3d; }
.form-stack { display: grid; gap: 1rem; }
.form-stack h2 { margin-bottom: 0; }
label, legend { font-size: .9rem; font-weight: 800; }
label input, label select, label textarea, .inline-form input, .inline-form select { background: #1a0e09; border: 1px solid var(--line); border-radius: .45rem; color: var(--text); display: block; margin-top: .35rem; padding: .7rem; width: 100%; }
input:focus, select:focus { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(227, 168, 60, .2); outline: none; }
.optional { color: var(--muted); font-size: .75rem; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; }
.player-select-list { display: grid; gap: .45rem; grid-template-columns: repeat(2, 1fr); margin-top: .65rem; }
.player-select { align-items: center; background: #21110c; border: 1px solid var(--line-soft); border-radius: .5rem; display: flex; gap: .55rem; padding: .65rem; }
.player-select:has(input:checked) { background: #3d512d; border-color: #a6b56d; }
.player-select input { accent-color: var(--amber); margin: 0; width: auto; }
.inline-form { align-items: center; display: flex; gap: .5rem; }
.inline-form input, .inline-form select { margin: 0; }
.avatar { align-items: center; background: linear-gradient(135deg, #e8b64a, #a6522e); border: 2px solid #f2cd71; border-radius: 50%; color: #321607; display: inline-flex; font-weight: 900; height: 2rem; justify-content: center; min-width: 2rem; object-fit: cover; overflow: hidden; width: 2rem; }
.avatar-large { font-size: 1.25rem; height: 3.2rem; min-width: 3.2rem; }
.avatar-xl { font-size: 2rem; height: 5rem; min-width: 5rem; }
.player-cell { align-items: center; display: flex; gap: .65rem; }
.page-header { align-items: flex-start; }
.profile-heading, .score-card-top { align-items: center; display: flex; gap: .8rem; }
.game-tools { align-items: center; display: flex; gap: .75rem; }
.timer { color: var(--amber-light); font-family: Georgia, serif; font-variant-numeric: tabular-nums; font-weight: 900; }
.score-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 1.5rem; }
.score-card { background: linear-gradient(160deg, #4a2917, #2a160d); border: 2px solid #86552a; border-radius: .75rem; box-shadow: var(--shadow), inset 0 0 20px rgba(0, 0, 0, .2); padding: 1rem; }
.score-card.is-eliminated { background: linear-gradient(160deg, #35201b, #241311); border-color: #70433b; opacity: .72; }
.score-card h2 { color: #ffe1a0; margin: 0; }
.player-state { color: var(--muted); font-size: .78rem; }
.score-value { color: #fff0c2; font-size: clamp(4rem, 12vw, 7rem); font-weight: 900; line-height: 1; padding: 1.1rem 0; text-align: center; text-shadow: 2px 3px #542414; }
.score-actions { display: grid; gap: .6rem; grid-template-columns: 1fr 1fr; }
.score-button { border: 1px solid rgba(255, 236, 170, .25); border-radius: .55rem; color: white; font-size: 1.5rem; font-weight: 900; min-height: 4rem; }
.score-button.minus { background: linear-gradient(#a34e40, #702e2c); }
.score-button.plus { background: linear-gradient(#899c5e, #53683d); }
.score-button:disabled { cursor: not-allowed; filter: grayscale(1); opacity: .35; }
.toeter-zone { align-items: center; display: flex; flex-direction: column; gap: .6rem; margin: 1.5rem auto 0; text-align: center; }
.toeter-button { align-items: center; background: radial-gradient(circle at 35% 28%, #ffe5a2, #d6962f 62%, #8d531b); border: 6px solid #75431c; border-radius: 50%; box-shadow: 0 10px 0 #4e2815, 0 20px 30px rgba(0, 0, 0, .45); color: #351607; display: flex; flex-direction: column; height: 190px; justify-content: center; transition: transform .12s, filter .12s; width: 190px; }
.toeter-button:active, .toeter-button.is-playing { filter: brightness(1.18); transform: scale(.94) rotate(-3deg); }
.toeter-button span:nth-child(2) { font-size: 1.2rem; font-weight: 1000; }
.toeter-button small { color: #51250e; font-size: .75rem; }
.toeter-icon { font-size: 3rem; }
.final-score-row { border-radius: .5rem; padding: .65rem; }
.winner-row { background: #554017; }
.rank { color: var(--muted); width: 1.3rem; }
.final-score { color: var(--amber-light); font-family: Georgia, serif; font-size: 1.4rem; font-weight: 900; margin-left: auto; }
.filter-bar { align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: .6rem; display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; padding: 1rem; }
.filter-bar label { flex: 1; min-width: 140px; }
.filter-bar .button { height: fit-content; }
.table-panel { overflow: hidden; padding: 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 720px; width: 100%; }
th, td { border-bottom: 1px solid var(--line-soft); padding: .9rem 1rem; text-align: left; white-space: nowrap; }
th { color: var(--amber-light); font-size: .75rem; text-transform: uppercase; }
tr:hover td { background: rgba(218, 153, 55, .06); }
tr:last-child td { border-bottom: 0; }
.reign-row { align-items: flex-start; }
.sound-row { border-bottom: 1px solid var(--line-soft); padding: .75rem 0; }
.sound-row audio { display: block; height: 32px; margin-top: .45rem; max-width: 100%; }
.sound-actions { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: flex-end; }
.admin-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1.35fr; margin-bottom: 1rem; }
.export-panel { margin-top: 1rem; }
.auth-card { margin: 5vh auto; max-width: 440px; }
.empty-state { color: var(--muted); }
.offline-banner { background: #9a5e1d; color: #fff3d0; font-size: .8rem; padding: .45rem; text-align: center; }
.offline-banner[hidden] { display: none; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: .5rem; }
  .topbar nav { width: 100%; }
  .page-shell { padding-top: 1.25rem; }
  .hero, .page-header, .game-header { align-items: stretch; flex-direction: column; }
  .hero .button { width: 100%; }
  .grid-2, .admin-grid { grid-template-columns: 1fr; }
  .stat-grid-large { grid-template-columns: repeat(2, 1fr); }
  .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-card { padding: .75rem; }
  .score-card-top { align-items: flex-start; }
  .score-card h2 { font-size: 1rem; }
  .score-value { font-size: 4rem; padding: .8rem 0; }
  .score-button { font-size: 1.2rem; min-height: 3.3rem; }
  .toeter-button { height: 155px; width: 155px; }
  .game-tools { justify-content: space-between; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar label { width: 100%; }
  .filter-bar .button { width: 100%; }
  .sound-actions { justify-content: flex-start; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form .button { width: 100%; }
}
@media (max-width: 420px) {
  .score-grid { grid-template-columns: 1fr; }
  .player-select-list { grid-template-columns: 1fr; }
  .hero { padding: 1.25rem; }
}
