/* ScoreTally (Čárky) – dark mobile-first design taken from the Claude Design mockups (390 × 844). */

:root {
    --c-page: #0B0D10;
    --c-screen: #111418;
    --c-card: #1A1F26;
    --c-card-muted: #161A20;
    --c-border: #2E3640;
    --c-divider: #232A33;
    --c-text: #F2F3F5;
    --c-label: #C9D0DA;
    --c-muted: #98A2B3;
    --c-subtle: #7C8696;
    --c-accent: #FFC93C;
    --c-accent-hover: #FFD86B;
    --c-accent-bg: #2A2614;
    --c-blue: #5AB4FF;
    --c-green: #4FD1A5;
    --c-green-bg: #12291F;
    --c-danger: #FF8A5C;
    --c-danger-bg: #2A1812;
    --c-on-color: #111418;
    --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Space Grotesk", Inter, system-ui, sans-serif;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--c-page);
    color: var(--c-text);
    font-family: var(--font-body);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    /* iOS Safari: no zoom on a quick double tap (e.g. "5", "0" on the keypad); pinch zoom stays available. */
    touch-action: manipulation;
}

a { color: var(--c-accent); }
a:hover { color: var(--c-accent-hover); }

h1:focus { outline: none; }

button, input { font: inherit; color: inherit; }
button, a, input, select, label { cursor: pointer; touch-action: manipulation; }
input { cursor: text; }
button:disabled { cursor: default; opacity: .55; }

:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Screen ---------- */

.app { min-height: 100dvh; display: flex; justify-content: center; }

.screen {
    width: 100%;
    max-width: 480px;
    min-height: 100dvh;
    background: var(--c-screen);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
}

.screen-centered { align-items: stretch; text-align: center; }

.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--c-muted); }
.subtle { color: var(--c-subtle); }
.hint { margin: 0; font-size: 13px; line-height: 1.4; color: var(--c-muted); }
.center { text-align: center; }

.title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1.1; letter-spacing: -0.02em; }
.title-sm { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; }
.lead { margin: 0; color: var(--c-muted); font-size: 15px; line-height: 1.45; }
.section-label { margin: 0; font-size: 14px; font-weight: 600; color: var(--c-label); }

/* ---------- Header ---------- */

.app-header { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }

.page-header { display: flex; align-items: center; gap: 12px; }
.page-header-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.page-header-text small { font-size: 13px; color: var(--c-muted); }
.page-header-text strong { font-family: var(--font-display); font-weight: 700; font-size: 18px; }

.icon-btn {
    width: 44px; height: 44px; flex: none;
    border-radius: 22px; border: 1px solid var(--c-border);
    background: var(--c-card); color: var(--c-text);
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
    text-decoration: none;
}
.icon-btn:hover { color: var(--c-text); border-color: var(--c-muted); }
.icon-btn-plain { border: 0; background: transparent; color: var(--c-subtle); }

/* ---------- Buttons ---------- */

.btn {
    min-height: 60px; padding: 0 20px;
    border-radius: 18px; border: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    font-family: var(--font-display); font-weight: 700; font-size: 17px;
    text-decoration: none; text-align: center;
}
.btn-sm { min-height: 48px; font-size: 15px; border-radius: 16px; }
.btn-primary { background: var(--c-accent); color: var(--c-on-color); }
.btn-primary:hover { background: var(--c-accent-hover); color: var(--c-on-color); }
.btn-outline { background: transparent; border: 1.5px solid var(--c-accent); color: var(--c-accent); }
.btn-outline:hover { color: var(--c-accent-hover); border-color: var(--c-accent-hover); }
.btn-secondary { background: var(--c-card); border: 1px solid var(--c-border); color: var(--c-text); }
.btn-secondary:hover { color: var(--c-text); border-color: var(--c-muted); }
.btn-ready { background: var(--c-green-bg); border: 2px solid var(--c-green); color: var(--c-green); }
.btn-danger { background: var(--c-danger-bg); border: 1.5px solid var(--c-danger); color: var(--c-danger); }
.btn-ghost { background: transparent; color: var(--c-muted); font-family: var(--font-body); font-weight: 600; font-size: 15px; min-height: 48px; }
.btn-ghost:hover { color: var(--c-text); }

.pill-btn {
    height: 36px; padding: 0 12px; border-radius: 18px;
    border: 1px solid var(--c-border); background: transparent; color: var(--c-text);
    font-size: 13px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.pill-btn:hover { color: var(--c-text); border-color: var(--c-muted); }

/* ---------- Cards ---------- */

.card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; border-radius: 20px;
    background: var(--c-card); border: 1px solid var(--c-border);
    color: var(--c-text); text-decoration: none; text-align: left; width: 100%;
}
a.card:hover, button.card:hover { color: var(--c-text); border-color: var(--c-muted); }
.card-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.card-text { font-size: 14px; line-height: 1.4; color: var(--c-muted); }

.game-card { padding: 18px; gap: 16px; }
.game-card .card-title { font-size: 19px; }
.game-card.selected, .game-card.selected:hover { border: 2px solid var(--c-accent); background: var(--c-accent-bg); }

.placeholder-card {
    display: flex; align-items: center; justify-content: center;
    height: 56px; border-radius: 20px; border: 1.5px dashed var(--c-border);
    color: var(--c-subtle); font-size: 14px;
}

.info-box { display: flex; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--c-card); color: var(--c-label); font-size: 14px; line-height: 1.45; }
.info-box svg { flex: none; margin-top: 1px; color: var(--c-blue); }
.info-box p { margin: 0; }

.error-box { padding: 12px 16px; border-radius: 14px; background: var(--c-danger-bg); border: 1px solid var(--c-danger); color: var(--c-danger); font-size: 14px; line-height: 1.4; }
.warning-text { color: var(--c-accent); }

.banner {
    position: sticky; top: 0; z-index: 10;
    margin: -8px 0 0; padding: 10px 14px; border-radius: 14px;
    background: var(--c-accent-bg); border: 1px solid var(--c-accent); color: var(--c-accent);
    font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .field legend { font-size: 14px; font-weight: 600; color: var(--c-label); padding: 0; }
fieldset.field { border: 0; margin: 0; padding: 0; }

.input {
    height: 56px; width: 100%;
    border-radius: 16px; border: 1.5px solid var(--c-border);
    background: var(--c-card); color: var(--c-text);
    padding: 0 18px; font-size: 17px; font-weight: 500;
}
.input:focus { outline: none; border-color: var(--c-accent); }
.input::placeholder { color: var(--c-subtle); font-weight: 400; }
.input-code { text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: .12em; text-transform: uppercase; height: 72px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
    height: 72px; border-radius: 16px; border: 1px solid var(--c-border);
    background: var(--c-card); color: var(--c-text);
    font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.choice[aria-pressed="true"] { border: 2px solid var(--c-accent); background: var(--c-accent-bg); color: var(--c-accent); }
.choice-custom { border-style: dashed; background: transparent; color: var(--c-label); font-family: var(--font-body); font-weight: 600; font-size: 16px; }

.progress { display: flex; gap: 6px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--c-border); }
.progress span.done { background: var(--c-accent); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--c-subtle); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }

/* ---------- Players ---------- */

.avatar {
    flex: none; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--c-on-color); font-weight: 700;
}
.avatar-free { background: transparent; border: 2px dashed currentColor; }
.avatar-dim { background: #3A4250; color: var(--c-label); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--c-card); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-row {
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 8px 8px 8px 14px; border-radius: 16px;
    background: var(--c-card); border: 2px solid transparent;
}
.player-row.me { border-color: var(--player-color, var(--c-accent)); }
.player-index { width: 16px; font-family: var(--font-display); font-weight: 700; color: var(--c-subtle); font-size: 15px; }
.player-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.player-name small { font-weight: 500; font-size: 13px; color: var(--c-muted); }
.player-status { font-size: 13px; color: var(--c-muted); display: flex; align-items: center; gap: 4px; }
.player-status svg { flex: none; }
.player-status.ready { color: var(--c-green); }
.player-status.waiting { color: var(--c-accent); }
.player-actions { display: flex; align-items: center; }
.player-actions .icon-btn { width: 36px; height: 36px; }
.player-menu { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 4px 42px; }

/* selectable nickname slots on the join screen */
.slot {
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 0 16px; border-radius: 16px;
    border: 2px solid transparent; background: var(--c-card); cursor: pointer;
}
.slot.selected { border-color: var(--c-accent); background: var(--c-accent-bg); }
.slot.taken { background: var(--c-card-muted); color: var(--c-muted); cursor: default; min-height: 56px; }
.slot input[type=radio] { width: 22px; height: 22px; margin: 0; accent-color: var(--c-accent); }

/* ---------- QR ---------- */

.qr-box { background: #FFFFFF; border-radius: 28px; padding: 10px; display: flex; align-items: center; justify-content: center; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-box-lg { width: min(300px, 100%); align-self: center; }
.qr-box-sm { width: 76px; height: 76px; border-radius: 12px; padding: 3px; flex: none; }
.join-code { font-family: var(--font-display); font-weight: 700; font-size: 36px; letter-spacing: .12em; color: var(--c-accent); }
.join-code-sm { font-size: 18px; letter-spacing: .08em; }

/* ---------- Game ---------- */

.screen-game { gap: 12px; padding-left: 16px; padding-right: 16px; }

.badge {
    flex: none; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    padding: 2px 7px; border-radius: 8px; white-space: nowrap;
}
.badge-turn { background: var(--c-accent); color: var(--c-on-color); }
.badge-out { color: var(--c-label); border: 1px solid #3A4250; padding: 1px 7px; }

.score-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.score-row {
    display: flex; align-items: center; gap: 12px;
    min-height: 56px; padding: 6px 14px; border-radius: 16px;
    background: var(--c-card); border: 2px solid transparent;
}
.score-row.turn { background: var(--c-accent-bg); border-color: var(--c-accent); }
.score-row.hit { border-color: var(--c-danger); }
.score-row.out { background: var(--c-card-muted); }
.score-row.out .player-name { color: var(--c-muted); text-decoration: line-through; }
.score-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.score-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.score-row-note { font-size: 12px; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.score-value { font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.score-row.out .score-value { color: var(--c-subtle); }
.score-delta { font-size: 14px; font-weight: 700; color: var(--c-danger); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 4px; border-radius: 2px; background: var(--c-border); overflow: hidden; }
.score-row.turn .bar { background: #3A3520; }
.bar span { display: block; height: 100%; border-radius: 2px; }

.last-entry {
    display: flex; align-items: center; gap: 10px; min-height: 36px;
    padding: 4px 6px 4px 12px; border-radius: 12px; background: var(--c-card-muted);
    font-size: 13px; color: var(--c-label);
}
.last-entry span { flex: 1; min-width: 0; }
.last-entry button { height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--c-muted); font-size: 12px; font-weight: 600; }
.last-entry button:hover { color: var(--c-text); }

.phase-steps { display: flex; gap: 6px; padding: 0 4px; }
.phase-steps div { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--c-subtle); }
.phase-steps div::before { content: ""; height: 4px; border-radius: 2px; background: var(--c-border); }
.phase-steps div.active { color: var(--c-blue); }
.phase-steps div.active::before { background: var(--c-blue); }

.input-panel {
    display: flex; flex-direction: column; gap: 10px;
    padding: 14px; border-radius: 24px; background: var(--c-card); border: 1px solid var(--c-border);
}
.input-panel.my-turn { border: 2px solid var(--c-accent); }
.input-panel-head { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.input-panel-head .hint { font-size: 13px; }

.target-chip {
    position: relative; height: 36px; padding: 0 10px 0 6px; border-radius: 18px;
    border: 1px solid var(--c-border); background: #232A33; color: var(--c-text);
    display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px;
}
.target-chip select { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; font-size: 16px; /* < 16px makes iOS zoom on focus */ }

.entry-display { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 6px; }
.entry-value { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; color: var(--c-accent); font-variant-numeric: tabular-nums; }
.entry-value.empty { color: var(--c-subtle); }
.entry-preview { font-size: 14px; color: var(--c-muted); font-variant-numeric: tabular-nums; text-align: right; }
.entry-preview strong { color: var(--c-text); }

.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.keypad button, .value-grid button {
    border: 0; border-radius: 14px; background: #232A33; color: var(--c-text);
    font-family: var(--font-display); font-weight: 600; font-size: 22px; font-variant-numeric: tabular-nums;
    display: flex; align-items: center; justify-content: center; padding: 0;
}
.keypad button { height: 50px; }
.keypad button:active, .value-grid button:active { background: #2E3640; }
.value-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.value-grid button { height: 42px; border-radius: 11px; font-weight: 700; font-size: 16px; }
.value-grid button[aria-pressed="true"] { background: var(--c-accent); color: var(--c-on-color); }

.preview-box { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: #232A33; }
.preview-box .preview-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--c-screen); color: var(--c-danger); display: flex; align-items: center; justify-content: center; }
.preview-box div:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; color: var(--c-label); }
.preview-box strong { font-size: 14px; color: var(--c-text); }

.input-actions { display: flex; gap: 8px; }
.input-actions .btn { min-height: 56px; border-radius: 16px; }

/* ---------- Sheet (game options) ---------- */

.sheet-backdrop { 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: 480px; background: var(--c-screen); border-radius: 24px 24px 0 0;
    border-top: 1px solid var(--c-border);
    padding: 20px 16px max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px;
}
.sheet-title { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.sheet-item {
    display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 16px; border-radius: 16px;
    background: var(--c-card); border: 0; color: var(--c-text); text-decoration: none; font-weight: 600; font-size: 15px; text-align: left; width: 100%;
}
.sheet-item:hover { color: var(--c-text); background: #20262E; }
.sheet-item.danger { color: var(--c-danger); }

/* ---------- Results ---------- */

.results-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding-top: 12px; }
.trophy-avatar { position: relative; }
.trophy-avatar .trophy {
    position: absolute; top: -10px; right: -10px; width: 34px; height: 34px; border-radius: 17px;
    background: var(--c-accent); border: 3px solid var(--c-screen); color: var(--c-on-color);
    display: flex; align-items: center; justify-content: center;
}
.rank { width: 22px; font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--c-muted); }
.rank.first { color: var(--c-accent); }
.result-row.winner { border-color: var(--player-color); background: color-mix(in srgb, var(--player-color) 14%, var(--c-card)); }

.wins-card { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border-radius: 20px; background: var(--c-card); }
.wins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px 8px; }
.wins-grid div { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; text-align: center; overflow-wrap: anywhere; }

.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-radius: 16px; background: var(--c-card); overflow: hidden; }
.history-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--c-divider); }
.history-list li:last-child { border-bottom: 0; }
.history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.history-text small { font-size: 12px; color: var(--c-muted); }

/* ---------- Blazor ---------- */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow; color: #111;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; border: 0; background: transparent; font-size: 20px; }

#app-splash {
    position: fixed; inset: 0; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
    background: var(--c-screen); color: var(--c-muted); font-size: 15px;
}
#app-splash img { animation: splash-pulse 1.4s ease-in-out infinite; }
@keyframes splash-pulse { 50% { opacity: .55; transform: scale(.94); } }
body:has(main.app) #app-splash { display: none; }
@media (prefers-reduced-motion: reduce) { #app-splash img { animation: none; } }

.loading { display: flex; align-items: center; justify-content: center; min-height: 40vh; color: var(--c-muted); }
