/* =====================================================================
   Punkto — styles
   1. Tokens & colours   2. Base   3. Components   4. Home
   5. Control view        6. Display view   7. Winner/podium   8. Misc
   ===================================================================== */

/* ---------------------------------------------------- 1. Tokens & colours */
:root {
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --gold: #F5C542; --silver: #C9CED6; --bronze: #D99058;
  --danger: #D64545; --ok: #2E9C5A;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 20px rgb(0 0 0 / .06);
  --tap: 44px;
  color-scheme: light;
}
/* Warm coral + teal on cream (day) / warm dark brown (night) */
:root {
  --bg: #FFF7EE; --surface: #FFFFFF; --surface-2: #FBEBDD; --text: #2B1D14; --muted: #7A6556; --border: #EEDAC8;
  --accent: #E8572A; --accent-ink: #FFFFFF; --accent-2: #2E9C8A; --accent-2-ink: #FFFFFF;
}
:root[data-scheme="dark"] {
  --bg: #1A1411; --surface: #241C17; --surface-2: #30251E; --text: #FBEFE4; --muted: #B49F8F; --border: #3D3028;
  --accent: #FF7A4D; --accent-ink: #1A1411; --accent-2: #4CC4AE; --accent-2-ink: #0E1A17;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
}
:root[data-scheme="dark"] { color-scheme: dark; }

/* ------------------------------------------------------------------ 2. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4.5vw, 44px); font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; justify-content: center; }
.hidden { visibility: hidden; }
.full { flex-basis: 100%; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.space { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }
.error-text { color: var(--danger); }
.danger-text { color: var(--danger) !important; }
.ico { width: 20px; height: 20px; flex: none; }
kbd {
  font: 600 12px/1 var(--font); padding: 4px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--muted);
}
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
.prose p { font-size: 17px; }
.back-link { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; margin-bottom: 16px; font-weight: 600; }

/* ----------------------------------------------------------- 3. Components */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .08s, border-color .15s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost.on { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 17px; }
.btn.block { display: flex; width: 100%; }
.icon-btn { width: var(--tap); padding: 0; background: transparent; border-color: transparent; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { background: var(--surface-2); color: var(--accent); }
.icon-btn.btn-sm { width: 32px; min-height: 32px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px;
}
.chip:hover { border-color: var(--accent); }
.chip .ico { width: 16px; height: 16px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 700; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }

.input {
  width: 100%; min-height: var(--tap); padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input.invalid, .input.invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.field-error { margin: 0; min-height: 0; color: var(--danger); font-size: 14px; font-weight: 600; }
.field-error:empty { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.steps-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.steps-field { display: flex; align-items: center; gap: 8px; }
.steps-sign { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 900; font-size: 20px; }
.steps-sign.plus { background: var(--accent); color: var(--accent-ink); }
.steps-sign.minus { background: var(--surface-2); color: var(--text); }
.input-sm { min-height: 36px; padding: 0 10px; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 700; font-size: 14px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--surface-2); }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer;
  min-height: 38px; padding: 0 14px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--muted);
}
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented .ico { width: 18px; height: 18px; }

.avatar {
  --size: 40px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; object-fit: cover;
  display: inline-grid; place-items: center; font-weight: 800; font-size: calc(var(--size) * .4); background: var(--surface-2);
}
.avatar.initials { background: hsl(var(--hue) 65% 88%); color: hsl(var(--hue) 45% 28%); }
:root[data-scheme="dark"] .avatar.initials { background: hsl(var(--hue) 35% 28%); color: hsl(var(--hue) 70% 86%); }
.avatar.sm { --size: 28px; }

/* Dialogs */
dialog.modal { padding: 0; border: 0; background: transparent; color: var(--text); max-width: min(520px, calc(100vw - 24px)); width: 100%; }
dialog.modal.wide { max-width: min(720px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgb(20 12 6 / .45); backdrop-filter: blur(2px); }
.modal-card { background: var(--surface); border-radius: 20px; box-shadow: 0 20px 60px rgb(0 0 0 / .3); display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px 22px; }
.modal-title { flex: 1; margin: 0; font-size: 20px; }
.modal-body { padding: 8px 22px 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: toast-in .2s ease-out; text-align: center; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Popover menu */
.menu { position: fixed; z-index: 900; min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / .18); animation: toast-in .12s ease-out; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 9px; cursor: pointer; text-align: left; font-weight: 600; font-size: 15px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item span { flex: 1; }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* App bar */
.appbar { display: flex; align-items: center; gap: 4px; padding: 10px 16px; max-width: 1120px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 22px; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.logo { width: 34px; height: 34px; }
.lang-select { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; min-height: var(--tap); border-radius: var(--radius-sm); color: var(--text); cursor: pointer; }
.lang-select:hover { background: var(--surface-2); }
.lang-select-input { border: 0; background: transparent; font-weight: 600; font-size: 15px; cursor: pointer; padding: 6px 0; max-width: 130px; }
.lang-select-input option { background: var(--surface); color: var(--text); }


/* Ad slots — always separated from interactive controls */
.ad-zone { margin-top: 72px; display: flex; justify-content: center; padding: 0 16px; }
.ad-slot { width: 100%; max-width: 970px; text-align: center; }
.ad-label { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); opacity: .7; margin-bottom: 4px; }
.ad-placeholder { border: 2px dashed var(--border); border-radius: 10px; color: var(--muted); display: grid; place-items: center; min-height: 90px; font-size: 13px; }
.ad-display { width: 320px; flex: none; }
.ad-display .ad-placeholder { min-height: 50px; height: 50px; }
.ad-display .ad-label { text-align: right; margin-bottom: 2px; }

/* Footer */
.site-footer { margin-top: auto; padding: 32px 16px 40px; border-top: 1px solid var(--border); text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; align-items: center; }
.footer-langs { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 14px; }
.footer-uses { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; align-items: center; font-size: 14px; }
.footer-uses a { color: var(--text); }
.footer-langs a { color: var(--muted); text-decoration: none; }
.footer-langs a:hover { color: var(--accent); }

/* ------------------------------------------------------------------- 4. Home */
.home { width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px 16px 40px; display: flex; flex-direction: column; gap: 40px; }
.hero { padding: 28px 0 0; max-width: 760px; }
.hero h1 { font-size: clamp(30px, 5.4vw, 52px); }
.hero .lead { font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); max-width: 640px; }
.hero.compact { padding-top: 8px; }
.hero.compact h1 { font-size: clamp(22px, 3vw, 28px); }
.hero.compact .lead { display: none; }
.privacy-note { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; padding: 14px 16px; border-radius: var(--radius); background: color-mix(in srgb, var(--accent-2) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent); max-width: 640px; }
.privacy-note .ico { color: var(--accent-2); margin-top: 2px; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; flex: 1; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.board-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.board-card::before { content: ""; height: 6px; background: linear-gradient(90deg, var(--accent) 0 60%, var(--accent-2) 60%); }
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.board-card-main { display: block; padding: 14px 16px 6px; color: inherit; text-decoration: none; flex: 1; }
.board-card-main h3 { font-size: 19px; margin: 8px 0 4px; overflow-wrap: anywhere; }
.card-top { display: flex; }
.mode-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mode-chip .ico { width: 16px; height: 16px; }
.card-leader { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-weight: 600; }
.card-leader .ico { color: var(--gold); width: 18px; height: 18px; }
.card-leader span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-leader.scoreline { font-variant-numeric: tabular-nums; white-space: pre; overflow: hidden; text-overflow: ellipsis; display: block; }
.card-actions { display: flex; justify-content: flex-end; padding: 0 6px 6px; }
.empty { text-align: center; padding: 36px 16px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.empty .row { margin-top: 12px; flex-wrap: wrap; }
.features h2, .faq h2 { margin-bottom: 14px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.feature > .ico { width: 28px; height: 28px; color: var(--accent); margin-bottom: 8px; }
.feature p { color: var(--muted); margin: 0; font-size: 15px; }
.faq details { border-bottom: 1px solid var(--border); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 700; font-size: 17px; }
.faq details p { margin: 8px 0 0; color: var(--muted); }

/* Create dialog */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 10px 12px 14px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; }
.mode-card.on { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.mode-card strong { font-size: 17px; }
.mode-art { width: 100%; height: auto; border-radius: 10px; margin-bottom: 6px; }
@media (max-width: 480px) { .mode-cards { grid-template-columns: 1fr; } .mode-art { max-height: 110px; } }

/* Premium dialog */
.benefits { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.benefits li { display: flex; gap: 10px; align-items: flex-start; }
.benefits .ico { color: var(--ok); margin-top: 2px; }
.premium-ok { display: flex; align-items: center; gap: 10px; font-size: 18px; color: var(--ok); }
.premium-ok .ico { width: 28px; height: 28px; }

/* ----------------------------------------------------------- 5. Control view */
.ctl-bar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.ctl-title { display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: none; cursor: pointer; padding: 6px 8px; border-radius: 10px; font-weight: 800; font-size: 19px; }
.ctl-title:hover { background: var(--surface-2); }
.ctl-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctl-title.static { cursor: default; }
.ctl-logo { height: 30px; width: auto; max-width: 60px; object-fit: contain; }
.adfree-chip { color: var(--muted); }
@media (max-width: 640px) {
  .display-btn span, .adfree-chip span { display: none; }
  .display-btn { width: var(--tap); padding: 0; }
  .ctl-title { font-size: 17px; }
}
.ctl-main { width: 100%; max-width: 980px; margin: 0 auto; padding: 14px 12px 0; }
.ctl-end { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 32px; text-align: center; }
.btn-end { border-width: 2px; }
.ctl-footer { text-align: center; padding: 16px 16px 28px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.round-ctl { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2px 4px; }
.round-label { font-weight: 800; padding: 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.round-ctl .icon-btn { width: 36px; min-height: 36px; }

/* Leaderboard rows */
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); cursor: default;
}
.lb-row.selected { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.lb-row .rank { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; font-weight: 800; font-size: 14px; color: var(--muted); background: var(--surface-2); }
.rank.medal-1 { background: var(--gold); color: #4a3300; }
.rank.medal-2 { background: var(--silver); color: #2c3036; }
.rank.medal-3 { background: var(--bronze); color: #3a1d00; }
.lb-row .name { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-pts { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.score-ctl { display: flex; align-items: center; gap: 6px; }
.score { min-width: 56px; text-align: center; font-weight: 900; font-size: 24px; font-variant-numeric: tabular-nums; }
/* Scores are buttons: click to type a new value. */
.score-btn { border: 1px dashed transparent; background: none; color: inherit; cursor: text; border-radius: 10px; padding: 2px 6px; }
.score-btn:hover { border-color: var(--border); background: var(--surface-2); }
.score-input { border: 2px solid var(--accent); border-radius: 10px; background: var(--surface); color: var(--text); text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.score-input::-webkit-inner-spin-button, .score-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.score-input.score { width: 80px; padding: 4px; font-size: 22px; }
.score-input.team-score { width: min(240px, 100%); padding: 0 8px; }
.step { min-width: var(--tap); padding: 0 10px; font-size: 17px; font-variant-numeric: tabular-nums; }
/* Colour shows direction: every add button is filled, every subtract button is outlined. */
.step.plus { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step.plus:hover { background: color-mix(in srgb, var(--accent) 85%, var(--text)); }
.step.minus { background: var(--surface); border-color: var(--border); color: var(--text); }
.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); color: var(--accent); } }
@media (max-width: 520px) {
  .lb-row { gap: 8px; padding: 6px; flex-wrap: wrap; }
  .lb-row .rank { width: 26px; height: 26px; }
  .lb-row .avatar { --size: 34px; }
  .score-ctl { gap: 4px; }
  .step { min-width: 40px; padding: 0 8px; }
  .score { min-width: 44px; font-size: 21px; }
  .lb-row .step:not(.first) { display: none; } /* only the first add/subtract button on very small screens */
}
.lb-row.editing { gap: 8px; }
.name-input { flex: 1; font-weight: 700; }
.avatar-btn { position: relative; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; flex: none; }
.avatar-edit { position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); border: 2px solid var(--surface); }
.avatar-edit .ico { width: 12px; height: 12px; }
.add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.add-row .input { flex: 1; min-width: 0; }

/* Rounds table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.rounds-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.rounds-table th, .rounds-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
.rounds-table .name-col { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 700; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.rounds-table th.current, .rounds-table td.current { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.rounds-table th.current .linklike { color: var(--accent); font-weight: 800; }
.rounds-table thead .linklike { text-decoration: none; color: var(--muted); font-weight: 700; }
.rounds-table .total-col { font-weight: 900; font-size: 18px; }
.cell { width: 64px; min-height: 38px; text-align: center; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); font-weight: 700; font-size: 16px; -moz-appearance: textfield; }
.cell::-webkit-inner-spin-button, .cell::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cell:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.table-foot { padding: 8px; }

/* Scoreboard control */
.sb-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.team-card { background: var(--surface); border: 1px solid var(--border); border-top: 6px solid var(--team); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.team-head { display: flex; align-items: center; gap: 10px; width: 100%; justify-content: center; min-width: 0; }
.team-name { margin: 0; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-logo { width: 44px; height: 44px; object-fit: contain; flex: none; }
.team-logo.placeholder { display: grid; place-items: center; border-radius: 50%; background: var(--team); color: var(--team-ink); font-weight: 900; font-size: 20px; }
.team-score { font-size: clamp(64px, 14vw, 120px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.team-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.team-buttons .step { min-height: 56px; min-width: 72px; font-size: 22px; }
.team-card .step.plus { background: var(--team); border-color: var(--team); color: var(--team-ink); }
.team-card .step.plus:hover { background: color-mix(in srgb, var(--team) 85%, var(--text)); }
.squad-chips { width: 100%; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 6px; }
.key-hint { margin: 0; opacity: .7; }
.team-card.editing { align-items: stretch; }
.team-name-input { font-weight: 800; }
.logo-btn .team-logo { width: 48px; height: 48px; }
.squad-edit { display: flex; flex-direction: column; gap: 8px; }
.squad-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.squad-list li { display: flex; gap: 4px; align-items: center; }
.squad-edit .row .input { flex: 1; min-width: 0; }
@media (max-width: 520px) {
  .sb-teams { gap: 8px; }
  .team-card { padding: 10px 6px; }
  .team-buttons .step { min-width: 56px; }
  .team-name { font-size: 17px; }
}
.clock-card { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.clock-time { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }
.timeline { margin-top: 16px; }
.timeline ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.event { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.event .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--team); flex: none; }
.event .minute { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 34px; }
.event .ev-team { font-weight: 700; }
.event .ev-player { flex: 1; color: var(--muted); }
.event .ev-pts { font-weight: 800; }
.timeline-empty { margin-top: 20px; }
.scorer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.scorer { justify-content: flex-start; min-height: 52px; white-space: normal; text-align: left; }

/* History */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 12px; padding: 4px 4px 4px 12px; }
.history-main { flex: 1; display: flex; flex-direction: column; color: inherit; text-decoration: none; padding: 4px 0; min-width: 0; }
.history-main strong { display: flex; gap: 6px; align-items: center; }
.history-main strong span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main .ico { color: var(--gold); width: 18px; height: 18px; }
.logo-preview { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.logo-preview.empty { display: grid; place-items: center; color: var(--muted); }
.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.shortcuts td:first-child { width: 40%; white-space: nowrap; }

/* ------------------------------------------------------------ 6. Display view */
body.is-display { overflow: hidden; }
.display {
  position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.8vh; padding: 2.6vh 3vw 1.6vh; background: var(--bg); color: var(--text); overflow: hidden;
}
.display:not(.awake) { cursor: none; }
.d-top { display: flex; align-items: center; justify-content: space-between; gap: 2vw; min-height: 6vh; padding-right: 9vw; }
.d-title { display: flex; align-items: center; gap: 1.4vw; min-width: 0; }
.d-title h1 { margin: 0; font-size: clamp(22px, 5.2vh, 76px); font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-logo { height: 7.5vh; max-width: 22vw; object-fit: contain; }
.d-round { display: inline-block; font-size: clamp(16px, 3.4vh, 48px); font-weight: 800; padding: .15em .8em; border-radius: 999px; background: var(--accent); color: var(--accent-ink); white-space: nowrap; }
.d-main { position: relative; min-height: 0; }
.d-empty { display: grid; place-items: center; height: 100%; margin: 0; font-size: clamp(20px, 4vh, 48px); color: var(--muted); text-align: center; }

.d-lb {
  list-style: none; margin: 0; padding: 0; height: 100%;
  display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--per-col, 1), var(--row-h, 80px)); grid-auto-flow: column;
  column-gap: 2.4vw; align-content: center;
}
.d-row {
  --s: var(--row-h, 80px);
  position: relative; display: flex; align-items: center; gap: calc(var(--s) * .22);
  height: calc(var(--s) * .86); align-self: center; padding: 0 calc(var(--s) * .3) 0 calc(var(--s) * .14);
  border-radius: calc(var(--s) * .24); background: var(--surface); box-shadow: var(--shadow);
  font-size: calc(var(--s) * .4); min-width: 0;
}
.d-row.medal-1 { background: color-mix(in srgb, var(--gold) 26%, var(--surface)); }
.d-row.medal-2 { background: color-mix(in srgb, var(--silver) 26%, var(--surface)); }
.d-row.medal-3 { background: color-mix(in srgb, var(--bronze) 22%, var(--surface)); }
.d-rank { width: calc(var(--s) * .56); height: calc(var(--s) * .56); flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-weight: 900; font-size: calc(var(--s) * .27); color: var(--muted); }
.medal-1 .d-rank { background: var(--gold); color: #4a3300; }
.medal-2 .d-rank { background: var(--silver); color: #2c3036; }
.medal-3 .d-rank { background: var(--bronze); color: #3a1d00; }
.d-avatar { --size: calc(var(--s) * .66); }
.d-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-roundpts { font-size: .55em; font-weight: 800; color: var(--accent-2); white-space: nowrap; }
.d-score { font-weight: 900; font-size: 1.32em; font-variant-numeric: tabular-nums; }
.d-row.flash { animation: flash 1s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 calc(var(--s) * .06) var(--accent); } 100% { box-shadow: var(--shadow); } }
.d-float { position: absolute; right: calc(var(--s) * .3); top: 0; font-weight: 900; color: var(--accent); pointer-events: none; animation: float 1.4s ease-out forwards; }
.d-float.neg { color: var(--muted); }
@keyframes float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-80%); } }

.d-rounds-wrap { height: 100%; display: grid; align-items: center; overflow: hidden; }
.d-rounds { --fs: 28px; width: 100%; border-collapse: separate; border-spacing: 0 calc(var(--fs) * .25); font-size: var(--fs); font-variant-numeric: tabular-nums; }
.d-rounds th { font-size: .62em; color: var(--muted); font-weight: 800; padding: 0 .4em; }
.d-rounds td { background: var(--surface); padding: .22em .45em; text-align: center; font-weight: 700; }
.d-rounds td:first-child { border-radius: .4em 0 0 .4em; }
.d-rounds td:last-child { border-radius: 0 .4em .4em 0; }
.d-rounds .rk { color: var(--muted); font-weight: 900; width: 1.6em; }
.d-rounds .nm { text-align: left; font-weight: 800; max-width: 30vw; }
.d-rounds .nm div { display: flex; align-items: center; gap: .4em; overflow: hidden; }
.d-rounds .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-rounds .nm .d-avatar { --size: 1.3em; }
.d-rounds .current { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.d-rounds th.current { background: none; color: var(--accent); }
.d-rounds td.total { font-weight: 900; font-size: 1.15em; }
.d-rounds th.total { color: var(--text); }
.d-rounds td.total { background: color-mix(in srgb, var(--accent-2) 14%, var(--surface)); }
.d-rounds tr.medal-1 .rk { color: #b58a00; }

.d-sb { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 3vw; }
.d-team { display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center; min-width: 0; }
.d-team-logo { width: 24vh; height: 24vh; object-fit: contain; }
.d-team-logo.placeholder { display: grid; place-items: center; border-radius: 50%; background: var(--team); color: var(--team-ink); font-weight: 900; font-size: 12vh; }
.d-team-name { margin: 0; font-size: clamp(24px, 6.4vh, 104px); font-weight: 900; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: .1em solid var(--team); padding-bottom: .08em; }
.d-scorers { list-style: none; margin: 0; padding: 0; font-size: clamp(14px, 2.9vh, 42px); color: var(--muted); font-weight: 600; line-height: 1.35; height: 22vh; overflow: hidden; }
.d-center { display: flex; flex-direction: column; align-items: center; gap: 2vh; }
.d-scoreline { display: flex; align-items: center; font-weight: 900; line-height: .9; font-variant-numeric: tabular-nums; }
.d-big { font-size: min(36vh, 17vw); }
.d-big.pop { animation: pop .6s ease-out; }
@keyframes pop { 30% { transform: scale(1.18); color: var(--accent); } }
.d-colon { font-size: min(24vh, 11vw); opacity: .4; margin: 0 .12em .12em; }
.d-clock { font-size: clamp(24px, 8vh, 128px); font-weight: 900; font-variant-numeric: tabular-nums; padding: .05em .45em; border-radius: .3em; background: var(--surface); }
.d-clock.running { color: var(--accent); }
@media (max-aspect-ratio: 1/1) {
  .d-sb { grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 2vh; align-content: center; }
  .d-team-logo { width: 12vh; height: 12vh; }
  .d-team-logo.placeholder { font-size: 6vh; }
  .d-big { font-size: 22vh; }
}

.d-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 2vw; min-height: 20px; }
.made-with { color: var(--muted); text-decoration: none; font-size: clamp(11px, 1.5vh, 18px); opacity: .75; }
.made-with:hover { opacity: 1; }
.d-controls { position: fixed; top: 1.6vh; right: 1.4vw; display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 20; }
.display.awake .d-controls { opacity: 1; pointer-events: auto; }
.d-overlay { position: absolute; inset: 0; background: var(--bg); display: none; z-index: 10; padding: 3vh 3vw; overflow: hidden; }
.d-overlay.on { display: grid; place-items: center; animation: toast-in .4s ease-out; }
.d-winner { --pod: min(62vh, 80vw); width: 100%; text-align: center; }
.d-winner .winner-title { font-size: clamp(28px, 7vh, 110px); }

/* ---------------------------------------------------------- 7. Winner/podium */
.winner-page { --pod: min(440px, 88vw); width: 100%; max-width: 900px; margin: 0 auto; padding: 24px 16px 48px; text-align: center; }
.winner-title { font-weight: 900; font-size: clamp(30px, 6vw, 56px); margin: 0 0 .5em; animation: rise .6s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(20px) scale(.96); } }
.winner-actions { margin-top: 32px; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: calc(var(--pod) * .03); font-size: calc(var(--pod) / 20); }
.pod-col { width: 6.6em; display: flex; flex-direction: column; align-items: center; animation: rise .7s ease-out both; }
.pod-col.pos-1 { animation-delay: .5s; }
.pod-col.pos-2 { animation-delay: .25s; }
.pod-col.empty { visibility: hidden; }
.pod-person { display: flex; flex-direction: column; align-items: center; gap: .2em; padding-bottom: .4em; max-width: 100%; }
.pod-avatar { --size: 3.2em; box-shadow: 0 0 0 .14em var(--surface); }
.pos-1 .pod-avatar { --size: 4em; box-shadow: 0 0 0 .16em var(--gold); }
.pod-name { font-weight: 800; font-size: .95em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { font-weight: 900; font-size: 1.15em; font-variant-numeric: tabular-nums; }
.crown { color: var(--gold); }
.crown .ico { width: 1.6em; height: 1.6em; }
.pod-block { width: 100%; display: grid; place-items: center; border-radius: .5em .5em .15em .15em; font-weight: 900; font-size: 1.6em; color: rgb(0 0 0 / .55); }
.pos-1 .pod-block { height: 3.6em; background: var(--gold); }
.pos-2 .pod-block { height: 2.6em; background: var(--silver); }
.pos-3 .pod-block { height: 1.9em; background: var(--bronze); }
.pod-rest { list-style: none; padding: 0; margin: 1.2em auto 0; max-width: calc(var(--pod) * 1.4); display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 6px; font-size: calc(var(--pod) / 26); }
.pod-rest li { display: flex; gap: .6em; align-items: center; padding: .35em .7em; background: var(--surface); border-radius: .5em; text-align: left; }
.pod-rest .rk { color: var(--muted); font-weight: 800; min-width: 1.4em; }
.pod-rest .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-rest .sc { font-weight: 900; font-variant-numeric: tabular-nums; }
.final { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: calc(var(--pod) * .06); font-size: calc(var(--pod) / 20); }
.final-team { display: flex; flex-direction: column; align-items: center; gap: .3em; opacity: .7; min-width: 0; }
.final-team.won { opacity: 1; }
.final-team .team-logo { width: 3.4em; height: 3.4em; font-size: 1em; }
.final-team .team-logo.placeholder { font-size: 1.6em; width: 2.2em; height: 2.2em; }
.final-name { font-weight: 900; font-size: 1.2em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: .12em solid var(--team); }
.final-scorers { list-style: none; padding: 0; margin: 0; color: var(--muted); font-size: .8em; }
.final-score { display: flex; align-items: center; font-weight: 900; font-size: 3.6em; line-height: 1; font-variant-numeric: tabular-nums; align-self: center; }
.final-score .sep { opacity: .4; margin: 0 .15em; }
.d-winner .final { font-size: calc(var(--pod) / 14); }

/* --------------------------------------------- Landing pages (SEO, static) */
.lp-main { width: 100%; max-width: 1040px; margin: 0 auto; padding: 8px 16px 48px; display: flex; flex-direction: column; gap: 48px; }
.lp-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: center; padding-top: 24px; }
.lp-hero h1 { font-size: clamp(30px, 5vw, 50px); }
.lp-hero .lead { font-size: clamp(17px, 2.1vw, 20px); color: var(--muted); }
.lp-hero .btn-lg { margin: 6px 0 10px; }
.lp-art .mode-art { width: 100%; max-width: 440px; display: block; margin: 0 auto; filter: drop-shadow(0 12px 30px rgb(0 0 0 / .12)); }
.lp-section h2, .lp-more h2 { margin-bottom: 16px; }
.lp-steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.lp-steps li { counter-increment: step; position: relative; padding: 18px 18px 18px 64px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.lp-steps li::before { content: counter(step); position: absolute; left: 16px; top: 16px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.lp-privacy { margin-top: 16px; }
.lp-cta { text-align: center; }
.lp-more ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.lp-more a { display: inline-block; padding: 10px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; }
.lp-more a:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 760px) { .lp-hero { grid-template-columns: 1fr; } .lp-art { order: -1; } .lp-art .mode-art { max-width: 320px; } }

/* ------------------------------------------------------------------ 8. Misc */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2000; }
.static-intro { max-width: 760px; margin: 0 auto; padding: 32px 16px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .ctl-bar, .ad-zone, .ctl-footer, .d-controls, .ad-slot { display: none !important; }
}
