:root {
  --bg: #0b1411;
  --bg2: #101c17;
  --card: #15241e;
  --card2: #1b2e26;
  --line: #24392f;
  --text: #eef4ef;
  --muted: #8fa69a;
  --orange: #ff7a1a;
  --orange2: #ff9a4d;
  --ball: #d7f34a;
  --red: #ff6b5e;
  --green: #4fd18b;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, -apple-system, sans-serif;
  --r: 16px;
  --tabs-h: 70px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .01em; margin: 0; line-height: 1.1; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(11, 20, 17, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .mark { width: 36px; height: 36px; }
.brand .word { display: flex; flex-direction: column; line-height: 1; }
.brand b { font: 800 24px/1 var(--display); letter-spacing: .06em; }
.brand i { font: italic 500 12.5px/1.2 var(--display); color: var(--muted); letter-spacing: .03em; margin-top: 2px; }
.who { font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); text-decoration: none; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.who .role { color: var(--orange2); }

.view { max-width: 720px; margin: 0 auto; padding: 16px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.pagehead p { margin: 4px 0 0; }

/* Bottom tabs */
.tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: flex-end; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom); background: rgba(13, 24, 20, .97); border-top: 1px solid var(--line); backdrop-filter: blur(10px); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 9px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--text); }
.tabs a.on:not(.main-btn) svg { stroke: var(--orange); }
.tabs .main-btn { position: relative; }
.tabs .main-btn .ball { display: grid; place-items: center; width: 62px; height: 62px; margin-top: -30px; border-radius: 50%; background: var(--orange); box-shadow: 0 8px 22px rgba(255, 122, 26, .45), 0 0 0 5px var(--bg); }
.tabs .main-btn .ball svg { width: 30px; height: 30px; stroke: #1b0d02; stroke-width: 2; }
.tabs .main-btn.on .ball { background: var(--orange2); }

/* Cards and lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.card + .card, .stack > * + * { margin-top: 12px; }
.section { margin-top: 22px; }
.section > h3 { margin-bottom: 10px; color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: .08em; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--card2); color: var(--muted); white-space: nowrap; }
.pill.orange { background: rgba(255, 122, 26, .16); color: var(--orange2); }
.pill.ball { background: rgba(215, 243, 74, .14); color: var(--ball); }
.pill.red { background: rgba(255, 107, 94, .15); color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ball); box-shadow: 0 0 0 0 rgba(215, 243, 74, .7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(215, 243, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(215, 243, 74, 0); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

/* Tier chips: 5 levels from cool to hot */
.tier { display: inline-block; padding: 2px 8px; border-radius: 6px; font: 600 12px/1.5 var(--body); white-space: nowrap; }
.tier.newbie { background: #22343b; color: #9fc3d1; }
.tier.beginner { background: #203a2c; color: #8fe0a9; }
.tier.upper_beginner { background: #32391c; color: #d7f34a; }
.tier.intermediate { background: #3d2c17; color: #ffb36b; }
.tier.advanced { background: #42201d; color: #ff8a7c; }

/* Buttons and forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1b0d02; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 12px; }
label.f > input, label.f > select, label.f > textarea, label.f > .selwrap { margin-top: 6px; }
input, select, textarea { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); outline: none; font-size: 16px; }
textarea { padding: 12px 14px; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 122, 26, .22); }
.selwrap { position: relative; }
.selwrap select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer; }
.selwrap::after { content: ''; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.err { color: var(--red); font-size: 14px; min-height: 0; margin: 10px 0 0; }
.err:empty { display: none; }
.seg { display: flex; padding: 4px; gap: 4px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); margin-top: 6px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--orange); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chips button { min-width: 48px; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); font-weight: 700; cursor: pointer; }
.chips button.on { border-color: var(--orange); background: rgba(255, 122, 26, .14); color: var(--orange2); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); margin-top: 6px; }
.stepper button { width: 46px; height: 44px; border: 0; background: none; font-size: 22px; font-weight: 700; cursor: pointer; color: var(--orange2); }
.stepper output { min-width: 40px; text-align: center; font: 700 20px var(--display); }

/* Live: court cards */
.event-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.event-head .meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.courts { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 620px) { .courts { grid-template-columns: 1fr 1fr; } }
.court { position: relative; border-radius: 14px; background: linear-gradient(180deg, #17342a, #12271f); border: 1px solid #2a4a3c; padding: 12px 14px; overflow: hidden; }
.court::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--ball); opacity: .55; }
.court.done::before { display: none; }
.court .ctop { display: flex; justify-content: space-between; align-items: center; font: 700 13px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.team-line { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 7px 0; }
.team-line + .team-line { border-top: 1px dashed rgba(255, 255, 255, .1); }
.team-line .names { font-weight: 600; font-size: 15px; line-height: 1.25; }
.team-line .g { font: 800 34px/1 var(--display); min-width: 28px; text-align: right; }
.team-line .p { font: 700 16px/1 var(--display); min-width: 38px; text-align: center; padding: 5px 6px; border-radius: 8px; background: rgba(0, 0, 0, .28); color: var(--ball); }
.team-line.lead .g { color: var(--orange2); }
.court .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.court.done { background: var(--card); border-color: var(--line); }
.queue li .vs { color: var(--muted); font-size: 13px; padding: 0 6px; }
.updated { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }

/* Standings */
table.st { width: 100%; border-collapse: collapse; font-size: 15px; }
table.st th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.st th:nth-child(2), table.st td:nth-child(2) { text-align: left; }
table.st td { text-align: right; padding: 9px 4px; border-bottom: 1px solid var(--line); }
table.st td:first-child { color: var(--muted); width: 28px; }
table.st tr:first-child td:nth-child(2) { color: var(--ball); font-weight: 700; }
table.st td.pts { font: 700 18px var(--display); }

/* Main: mode picker */
.cat { margin-top: 18px; }
.cat h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 620px) { .modes { grid-template-columns: repeat(3, 1fr); } }
.mode { text-align: left; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 12px; cursor: pointer; min-height: 104px; display: flex; flex-direction: column; gap: 6px; }
.mode b { font: 700 19px/1.1 var(--display); }
.mode span { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.mode.ready { border-color: rgba(255, 122, 26, .5); background: linear-gradient(160deg, rgba(255, 122, 26, .13), var(--card) 60%); }
.mode.soon { opacity: .55; cursor: default; }
.mode .pill { align-self: flex-start; margin-top: auto; }

/* Player picker */
.picker { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; background: var(--bg2); }
.picker label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picker label:last-child { border-bottom: 0; }
.picker input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--orange); flex: none; }
.picker .nm { flex: 1; font-weight: 600; }
.sticky-cta { position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); margin: 16px -16px 0; padding: 12px 16px 38px; z-index: 5; background: linear-gradient(180deg, rgba(11, 20, 17, 0), var(--bg) 22%); }
.sticky-cta .btn[disabled] { opacity: 1; background: var(--card2); border-color: var(--line); color: var(--muted); }

/* Referee screen */
.ref { display: flex; flex-direction: column; gap: 10px; }
.ref .board { display: flex; justify-content: center; align-items: center; gap: 14px; font: 700 15px var(--display); color: var(--muted); letter-spacing: .05em; }
.ref .board .sets { display: flex; gap: 6px; }
.tap { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 26vh; padding: 18px; border-radius: 20px; border: 2px solid var(--line); background: var(--card); cursor: pointer; text-align: left; touch-action: manipulation; user-select: none; }
.tap.a { border-color: #2d5a47; background: linear-gradient(160deg, #1a3b2e, #13261f); }
.tap.b { border-color: #5a3a22; background: linear-gradient(160deg, #3a2414, #22170f); }
.tap:active { transform: scale(.985); }
.tap .who2 { font-weight: 700; font-size: 17px; line-height: 1.3; }
.tap .lbl { font: 700 12px var(--display); letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.tap .pt { font: 800 clamp(64px, 20vw, 110px)/1 var(--display); color: var(--ball); text-align: right; }
.tap .gm { font: 700 20px var(--display); color: var(--text); text-align: right; }
.tap[disabled] { opacity: .55; }
.golden { text-align: center; font: 800 18px var(--display); letter-spacing: .14em; color: #1b1402; background: linear-gradient(90deg, #f3c94a, #ffe28a, #f3c94a); border-radius: 10px; padding: 6px; }
.result { text-align: center; padding: 14px; border-radius: 14px; background: rgba(215, 243, 74, .12); color: var(--ball); font: 700 22px var(--display); }
.ref .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Kas */
.sum3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum3 .card { padding: 12px; margin: 0; }
.sum3 small { display: block; font-size: 12px; color: var(--muted); }
.sum3 b { display: block; font: 700 19px var(--display); margin-top: 2px; word-break: break-word; }
.plus { color: var(--green); }
.minus { color: var(--red); }

/* Sheet (bottom dialog) */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet .grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: -6px auto 12px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions .btn { flex: 1; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); transform: translateX(-50%); max-width: 90vw; padding: 11px 16px; border-radius: 12px; background: #f1f6f2; color: #0b1411; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.toast.bad { background: var(--red); color: #fff; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
