:root {
  --ink: #140b1f;          /* page */
  --slab: #21143a;         /* panel top */
  --slab-2: #2a1a48;       /* raised inside a panel */
  --edge: #0b0613;         /* extruded panel side */
  --line: #3a2a5a;
  --grape: #8b5cf6;
  --grape-hi: #c9b0ff;
  --grape-deep: #53309e;
  --gold: #ffc83d;
  --gold-hi: #ffe28a;
  --gold-deep: #a67600;
  --text: #f3ecff;
  --muted: #a99cc4;
  --danger: #ff7a95;
  --ok: #7ee2b0;
  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 8px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html {
  background-color: var(--ink);
  /* faint isometric grid */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='32.33'%3E%3Cpath d='M0 16.17 28 0 56 16.17 28 32.33z' fill='none' stroke='%23241638' stroke-width='1'/%3E%3C/svg%3E");
  min-height: 100%;
}
body { margin: 0; color: var(--text); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--grape-hi); }
a:hover { color: var(--gold); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
.icon { width: 28px; height: 28px; flex: none; }
.icon.lg { width: 44px; height: 44px; }
.icon.xl { width: 64px; height: 64px; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1120px; margin: 0 auto; padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand span { font: 800 1.05rem var(--display); letter-spacing: -.02em; }
.brand-icon { width: 46px; height: 40px; }
#topnav { display: flex; align-items: center; gap: 14px; font-size: .95rem; }
#topnav a { color: var(--muted); text-decoration: none; }
#topnav a:hover, #topnav a.on { color: var(--text); }

main { max-width: 1120px; margin: 0 auto; padding: 8px 20px 80px; outline: none; }

/* ---------- slabs (panels with an extruded edge) ---------- */
.slab {
  background: var(--slab); border-radius: var(--r);
  box-shadow: 0 6px 0 var(--edge), inset 0 1px 0 rgba(255,255,255,.05);
  padding: 20px; margin-bottom: 26px;
}
.slab.tight { padding: 14px 16px; }
.slab > h2:first-child, .slab > .row:first-child h2 { margin-bottom: 14px; }
.inset { background: var(--slab-2); border-radius: 6px; padding: 12px 14px; }

/* ---------- buttons ---------- */
.btn {
  --b: var(--gold); --e: var(--gold-deep); --c: #1d1030;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 700 .95rem var(--body); color: var(--c); background: var(--b);
  border: 0; border-radius: 6px; padding: 10px 16px; cursor: pointer; text-decoration: none;
  box-shadow: 0 4px 0 var(--e); transform: translateY(0); transition: transform .06s, box-shadow .06s;
  white-space: nowrap;
}
.btn:hover { color: var(--c); filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--e); }
.btn.purple { --b: var(--grape); --e: var(--grape-deep); --c: #fff; }
.btn.ghost { --b: var(--slab-2); --e: var(--edge); --c: var(--text); }
.btn.danger { --b: #3a1830; --e: #1a0812; --c: var(--danger); }
.btn.small { padding: 6px 11px; font-size: .85rem; box-shadow: 0 3px 0 var(--e); }
.btn .icon { width: 22px; height: 22px; margin: -4px 0; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--grape-hi); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.linkbtn:hover { color: var(--gold); }
.linkbtn.danger { color: var(--danger); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #120a1f; border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 11px; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--grape); outline: none; box-shadow: 0 0 0 3px rgba(139, 92, 246, .3); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 120px; resize: vertical; }
textarea.code { font: 13px/1.5 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; min-height: 460px; tab-size: 2; }
select { appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23a99cc4' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
.error { color: var(--danger); font-size: .9rem; margin: 8px 0; }
.error ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 26px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.spacer { flex: 1; }
@media (max-width: 820px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: 1fr 1.1fr; gap: 30px; align-items: center; margin: 10px 0 40px; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); line-height: .98; letter-spacing: -.035em; margin-bottom: 18px; }
.hero h1 .l2 { display: block; color: var(--gold); }
.hero .lead { font-size: 1.1rem; color: var(--muted); max-width: 30em; }
.hero-scene { width: 100%; aspect-ratio: 144 / 96; }
.auth { max-width: 420px; }
.tabs-mini { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs-mini button { flex: 1; font: 700 .95rem var(--body); background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid var(--line); padding: 8px; cursor: pointer; }
.tabs-mini button.on { color: var(--text); border-color: var(--gold); }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 10px; }
.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature .icon { width: 56px; height: 56px; }
.feature h3 { margin-bottom: 4px; }
.feature p { color: var(--muted); font-size: .95rem; margin: 0; }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero-scene { order: -1; max-width: 520px; }
  .features { grid-template-columns: 1fr; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 10px 0 18px; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.subnav { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.subnav a { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.subnav a .icon { width: 24px; height: 24px; }
.subnav a.on { color: var(--text); border-color: var(--gold); }
.subnav a:hover { color: var(--text); }

/* ---------- group tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px; margin-bottom: 30px; }
.tile { display: block; text-decoration: none; color: var(--text); background: var(--slab); border-radius: var(--r);
  box-shadow: 0 6px 0 var(--edge); padding: 18px; transition: transform .1s, box-shadow .1s; }
.tile:hover { color: var(--text); transform: translateY(-3px); box-shadow: 0 9px 0 var(--edge); }
.tile h3 { font-size: 1.05rem; margin: 10px 0 6px; }
.tile .meta { color: var(--muted); font-size: .9rem; }
.tile.add { display: flex; flex-direction: column; justify-content: center; background: transparent; box-shadow: none; border: 2px dashed var(--line); }

/* ---------- game cards ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 22px; }
.game-card { display: flex; flex-direction: column; text-decoration: none; color: var(--text); background: var(--slab); border-radius: var(--r); box-shadow: 0 6px 0 var(--edge); overflow: hidden; transition: transform .1s, box-shadow .1s; }
.game-card:hover { color: var(--text); transform: translateY(-3px); box-shadow: 0 9px 0 var(--edge); }
.game-card .art { aspect-ratio: 4 / 3; background: var(--slab-2); display: grid; place-items: center; overflow: hidden; }
.game-card .art img { width: 100%; height: 100%; object-fit: cover; }
.game-card .art .icon { width: 72px; height: 72px; opacity: .9; }
.game-card .body { padding: 12px 14px 14px; }
.game-card h3 { font-size: .95rem; margin: 0 0 4px; }
.game-card.archived { opacity: .55; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--text); }
th.sorted { color: var(--gold); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--slab-2); color: var(--muted); vertical-align: middle; }
.pill.gold { background: rgba(255, 200, 61, .16); color: var(--gold); }
.pill.grape { background: rgba(139, 92, 246, .2); color: var(--grape-hi); }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font: 700 .8rem var(--display); background: var(--slab-2); color: var(--muted); }
.rank.p1 { background: var(--gold); color: #2a1a00; box-shadow: 0 3px 0 var(--gold-deep); }
.rank.p2 { background: var(--grape-hi); color: #24104a; box-shadow: 0 3px 0 var(--grape); }
.rank.p3 { background: var(--grape); color: #fff; box-shadow: 0 3px 0 var(--grape-deep); }

/* ---------- podium ---------- */
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; max-width: 560px; margin: 4px auto 6px; }
.podium .spot { text-align: center; }
.podium .who { font: 700 1rem var(--display); margin-bottom: 4px; overflow-wrap: anywhere; }
.podium .stat { color: var(--muted); font-size: .85rem; margin-bottom: 10px; }
.podium .block { position: relative; border-radius: 6px 6px 0 0; display: grid; place-items: center; font: 800 1.6rem var(--display); }
.podium .p1 .block { height: 120px; background: var(--gold); color: #3b2600; box-shadow: 0 8px 0 var(--gold-deep); }
.podium .p2 .block { height: 84px; background: var(--grape-hi); color: #2a1458; box-shadow: 0 8px 0 var(--grape); }
.podium .p3 .block { height: 60px; background: var(--grape); color: #fff; box-shadow: 0 8px 0 var(--grape-deep); }
.podium .empty .block { opacity: .25; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--slab); border-radius: var(--r); box-shadow: 0 6px 0 var(--edge); padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.kpi b { display: block; font: 700 1.35rem var(--display); }
.kpi span { color: var(--muted); font-size: .85rem; }
@media (max-width: 820px) { .kpis { grid-template-columns: 1fr 1fr; } }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; align-items: center; gap: 10px; font-size: .92rem; }
.bar .track { height: 14px; background: var(--slab-2); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--grape); box-shadow: inset 0 -4px 0 var(--grape-deep); border-radius: 3px; }
.bar .fill.gold { background: var(--gold); box-shadow: inset 0 -4px 0 var(--gold-deep); }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- plays list ---------- */
.plays { display: grid; gap: 12px; }
.play { background: var(--slab-2); border-radius: 6px; padding: 12px 14px; }
.play-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.play-head a { font-weight: 700; color: var(--text); text-decoration: none; }
.play-head a:hover { color: var(--gold); }
.play-results { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .92rem; }
.play-results .res { display: flex; align-items: center; gap: 7px; }
.play-results .rank { width: 22px; height: 22px; font-size: .7rem; }
.play-extra { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.play details { margin-top: 8px; font-size: .9rem; }
.play summary { cursor: pointer; color: var(--grape-hi); }

/* ---------- game page ---------- */
.game-hero { display: grid; grid-template-columns: 240px 1fr; gap: 26px; align-items: start; }
.game-hero .art { aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--slab-2); display: grid; place-items: center; box-shadow: 0 6px 0 var(--edge); }
.game-hero .art img { width: 100%; height: 100%; object-fit: cover; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: .92rem; margin-bottom: 12px; }
.facts b { color: var(--text); font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.links a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; background: var(--slab-2); padding: 6px 12px 6px 8px; border-radius: 6px; font-weight: 600; font-size: .9rem; color: var(--text); }
.links a:hover { color: var(--gold); }
.links .icon { width: 24px; height: 24px; }
@media (max-width: 700px) { .game-hero { grid-template-columns: 1fr; } .game-hero .art { max-width: 220px; } }

/* ---------- log form ---------- */
.entry { background: var(--slab-2); border-radius: 6px; padding: 12px; margin-bottom: 12px; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.entry-grid .field { margin: 0; }
.entry-top { display: flex; gap: 10px; align-items: end; margin-bottom: 10px; flex-wrap: wrap; }
.entry-top .field { margin: 0; flex: 1 1 180px; }
.entry .pos { width: 90px; flex: none; }
.entry .total { font: 700 1rem var(--display); color: var(--gold); padding: 9px 0; }
.member-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; padding: 10px 0; border-top: 1px dashed var(--line); }
.member-row .field { margin: 0; flex: 1 1 150px; }
.x { background: none; border: 0; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 8px; }
.x:hover { color: var(--danger); }

/* ---------- format editor ---------- */
.preview dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.preview dt { color: var(--muted); }
.preview dd { margin: 0; }
.changes { margin: 0; padding-left: 18px; font-size: .9rem; }
pre.code { background: #0f0819; border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; color: #e5dcff; }
code { font: .88em ui-monospace, Menlo, Consolas, monospace; background: #0f0819; padding: 1px 5px; border-radius: 4px; color: #e5dcff; }
.doc h2 { margin-top: 28px; }
.doc table td { white-space: normal; vertical-align: top; }
.doc table td:first-child { white-space: nowrap; }

/* ---------- invite ---------- */
.invite { display: flex; gap: 8px; }
.invite input { font-size: .9rem; }
.join-card { max-width: 480px; margin: 40px auto; text-align: center; }
.join-card .icon { width: 96px; height: 96px; }

fieldset.who-pick { border: 0; padding: 0; margin: 18px 0 20px; text-align: left; }
fieldset.who-pick legend { font: 700 1rem var(--display); margin-bottom: 4px; }
.who-list { display: grid; gap: 8px; }
.who-opt { display: flex; align-items: center; gap: 10px; background: var(--slab-2); padding: 10px 12px; border-radius: 6px; cursor: pointer; margin: 0; font-weight: 600; }
.who-opt input { width: 18px; height: 18px; accent-color: var(--gold); }
.who-opt:has(input:checked) { box-shadow: inset 0 0 0 2px var(--gold); }

/* ---------- empty states ---------- */
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .icon { width: 72px; height: 72px; margin-bottom: 8px; }
.empty h3 { color: var(--text); }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 10px); background: var(--gold); color: #1d1030; font-weight: 700; padding: 10px 18px; border-radius: 6px; box-shadow: 0 4px 0 var(--gold-deep); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); box-shadow: 0 4px 0 #8a2a40; }
#toast.action { display: flex; align-items: center; gap: 16px; background: var(--slab-2); color: var(--text); box-shadow: 0 6px 0 var(--edge), 0 0 0 2px var(--gold) inset; padding: 12px 12px 12px 18px; }
#toast.action.show { pointer-events: auto; }
#toast .toast-body { display: grid; gap: 2px; font-weight: 500; }
#toast .toast-body b { font: 700 1rem var(--display); color: var(--gold); }
#toast .toast-actions { display: flex; align-items: center; gap: 4px; }
@media (max-width: 560px) { #toast.action { flex-direction: column; align-items: stretch; width: calc(100% - 32px); } #toast .toast-actions { justify-content: space-between; } }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { color: var(--gold); }
.play-hero { grid-template-columns: 140px 1fr; }
.play-hero h1 { margin-top: 2px; }
.winner { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin: 6px 0 12px; }
.winner .icon { width: 34px; height: 34px; }
@media (max-width: 700px) { .play-hero { grid-template-columns: 1fr; } .play-hero .art { max-width: 120px; } }

@media (max-width: 560px) {
  .top { padding: 14px 16px; }
  main { padding: 4px 16px 60px; }
  .brand span { font-size: .92rem; }
  .slab { padding: 16px; }
  #topnav { gap: 10px; font-size: .9rem; }
  #topnav .hide-sm { display: none; }
  .subnav a { padding: 10px; }
  .subnav a .icon { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.play-head a.small { font-weight: 500; color: var(--muted); }
.play-head a.small:hover { color: var(--gold); }
.cta { display: flex; gap: 20px; align-items: center; margin-top: 30px; box-shadow: 0 6px 0 var(--edge), inset 0 0 0 2px var(--grape); }
.cta .icon { width: 88px; height: 78px; }
.cta p { margin: 0 0 12px; }
@media (max-width: 560px) { .cta { flex-direction: column; align-items: flex-start; } }
