:root {
    color-scheme: light;
    --bg: #f3f7fb;
    --surface: #ffffff;
    --ink: #18212f;
    --muted: #607086;
    --line: #d9e2ef;
    --blue: #1f6feb;
    --blue-dark: #154fa8;
    --green: #18864b;
    --red: #b42318;
    --yellow: #f7c948;
    --teal: #0f766e;
    --shadow: 0 18px 45px rgba(24, 33, 47, 0.1);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(31, 111, 235, 0.08), transparent 280px),
        var(--bg);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

a {
    color: var(--blue);
}

.shell {
    width: min(1120px, calc(100% - 28px));
    margin: 0 auto;
    padding: 24px 0 44px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--teal);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 5vw, 4rem);
}

h2 {
    margin-bottom: 8px;
    font-size: 1.45rem;
}

h3 {
    margin-bottom: 12px;
    font-size: 1rem;
}

.player-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 8px 24px rgba(24, 33, 47, 0.06);
}

.top-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--blue-dark);
    font-weight: 850;
    text-decoration: none;
}

.player-pill span {
    color: var(--muted);
    font-size: 0.9rem;
}

.panel,
.question-card,
.summary,
.leaderboard {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
    gap: 28px;
    align-items: start;
    padding: 28px;
}

.login-panel p,
.section-heading p,
.hint {
    color: var(--muted);
    line-height: 1.55;
}

.help-line {
    margin: -6px 0 0;
}

.help-line a,
.all-keys-link {
    color: var(--blue-dark);
    font-weight: 850;
    text-decoration: none;
}

.help-line a:hover,
.all-keys-link:hover,
.top-link:hover {
    text-decoration: underline;
}

.login-form,
.answer-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 750;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
}

input:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(31, 111, 235, 0.16);
}

select:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(31, 111, 235, 0.16);
}

button,
.actions a,
.muted-link {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.actions a:hover {
    background: var(--blue-dark);
}

.feedback {
    margin-bottom: 16px;
    padding: 13px 15px;
    border-radius: 8px;
    border: 1px solid;
    font-weight: 750;
}

.feedback.success {
    color: #0f5132;
    background: #dff7ea;
    border-color: #9fe3bf;
}

.feedback.error {
    color: var(--red);
    background: #fde7e4;
    border-color: #f5b4ad;
}

.feedback.info {
    color: #164e63;
    background: #e0f2fe;
    border-color: #a5d8f3;
}

.selector-panel {
    padding: 26px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.section-heading p {
    max-width: 620px;
    margin-bottom: 0;
}

.grade-grid,
.type-grid,
.table-grid {
    display: grid;
    gap: 10px;
}

.grade-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
}

.choice-card,
.type-choice,
.table-grid label {
    position: relative;
    min-height: 78px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px;
    background: #fbfdff;
    cursor: pointer;
}

.choice-card input,
.type-choice input,
.table-grid input {
    position: absolute;
    inset: 10px 10px auto auto;
    width: 18px;
    height: 18px;
}

.choice-card span,
.type-choice span {
    display: block;
    padding-right: 24px;
}

.choice-card small,
.type-choice small {
    color: var(--muted);
}

.choice-card:has(input:checked),
.type-choice:has(input:checked),
.table-grid label:has(input:checked) {
    border-color: var(--blue);
    background: #edf5ff;
}

.type-list,
.table-picker {
    margin-top: 22px;
}

.type-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.type-choice.is-hidden {
    display: none;
}

.table-grid {
    grid-template-columns: repeat(12, minmax(44px, 1fr));
}

.table-grid label {
    min-height: 48px;
    display: grid;
    place-items: center;
    padding: 10px;
}

.table-grid input {
    position: static;
    width: 0;
    height: 0;
    opacity: 0;
}

.count-control {
    max-width: 220px;
    margin-top: 22px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.actions a {
    background: #e8eef7;
    color: var(--ink);
}

.workspace {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.summary,
.question-card {
    padding: 22px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
}

.progress-text {
    margin: -2px 0 12px;
    color: var(--muted);
    font-weight: 800;
}

.chips span {
    border-radius: 8px;
    background: #edf5ff;
    color: var(--blue-dark);
    padding: 7px 9px;
    font-size: 0.84rem;
    font-weight: 750;
}

.muted-link {
    display: block;
    margin-top: 10px;
    background: #eef2f7;
    color: var(--ink);
    text-align: center;
}

.muted-link.danger {
    color: var(--red);
}

.question-card {
    min-height: 420px;
    display: grid;
    align-content: center;
    gap: 18px;
}

.done-card .actions {
    margin-top: 0;
}

.question-type {
    margin: 0;
    color: var(--teal);
    font-weight: 850;
    text-transform: uppercase;
    font-size: 0.82rem;
}

.question {
    font-size: clamp(2rem, 6vw, 4.6rem);
    font-weight: 850;
    line-height: 1.12;
}

.visual {
    width: min(100%, 430px);
}

.shape {
    display: block;
    width: 100%;
    max-height: 140px;
}

.piece {
    fill: #fff;
    stroke: var(--ink);
    stroke-width: 2;
}

.piece.filled {
    fill: var(--yellow);
}

.clock {
    display: block;
    width: min(100%, 360px);
    margin-bottom: 10px;
    touch-action: none;
}

.clock-face {
    fill: #fff;
    stroke: var(--ink);
    stroke-width: 5;
}

.clock-number {
    fill: var(--ink);
    font-size: 18px;
    font-weight: 850;
    text-anchor: middle;
    dominant-baseline: central;
}

.clock-tick {
    stroke: var(--muted);
    opacity: 0.75;
}

.minute-tick {
    stroke-width: 2;
}

.five-minute {
    stroke: var(--ink);
    stroke-width: 4;
    opacity: 1;
}

.clock-hand {
    stroke: var(--ink);
    stroke-linecap: round;
}

.interactive-clock .clock-hand {
    cursor: grab;
    pointer-events: stroke;
}

.interactive-clock .clock-hand:active {
    cursor: grabbing;
}

.hour-hand {
    stroke-width: 9;
}

.minute-hand {
    stroke: var(--blue);
    stroke-width: 5;
}

.interactive-clock .hour-hand {
    stroke-width: 14;
}

.interactive-clock .minute-hand {
    stroke-width: 10;
}

.clock-center {
    fill: var(--red);
}

.fraction {
    display: inline-grid;
    vertical-align: middle;
    min-width: 0.9em;
    text-align: center;
    line-height: 1;
}

.fraction i {
    display: block;
    border-top: 0.08em solid currentColor;
    margin: 0.08em 0;
}

.answer-line {
    grid-template-columns: auto minmax(120px, 220px) auto;
    align-items: center;
}

.answer-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.time-builder {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 12px;
    max-width: 460px;
}

.time-builder select {
    min-height: 58px;
    font-size: 1.35rem;
    font-weight: 850;
    text-align: center;
}

.answer-options button {
    min-height: 64px;
    background: #eef2f7;
    color: var(--ink);
    font-size: 1.35rem;
}

.answer-options button:hover {
    background: #dfe8f4;
}

.leaderboard {
    margin-top: 18px;
    padding: 18px;
}

.compact-heading {
    margin-bottom: 12px;
}

.compact-heading h2 {
    margin-bottom: 0;
}

.compact-heading a {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
    text-decoration: none;
}

.podium {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr;
    gap: 12px;
}

.podium-card {
    min-height: 112px;
    display: grid;
    align-content: center;
    gap: 6px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.podium-card.goud {
    background: linear-gradient(135deg, #fff4bd, #facc15);
    border-color: #eab308;
}

.podium-card.zilver {
    background: linear-gradient(135deg, #f8fafc, #cbd5e1);
    border-color: #94a3b8;
}

.podium-card.koper {
    background: linear-gradient(135deg, #ffe5c2, #d97706);
    border-color: #b45309;
}

.rank-badge {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
    font-size: 1.15rem;
    font-weight: 950;
}

.podium-card strong {
    font-size: 1.08rem;
}

.podium-card span:last-child {
    color: #334155;
    font-weight: 800;
}

.leaderboard-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px 16px;
    margin: 14px 0 0;
    padding-left: 22px;
}

.leaderboard-list li {
    padding: 7px 0;
}

.leaderboard-list li::marker {
    color: var(--muted);
    font-weight: 800;
}

.key-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
}

.key-modal:target {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.46);
}

.key-card {
    position: relative;
    width: min(560px, calc(100% - 28px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    margin: 7vh auto 0;
    padding: 24px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 22px 70px rgba(15, 23, 42, 0.28);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #eef2f7;
    color: var(--ink);
    text-decoration: none;
    font-weight: 900;
}

.key-example {
    margin: 14px 0;
    padding: 16px;
    border-radius: 8px;
    background: #fff7d6;
    border: 1px solid #f3d36a;
    font-size: 1.35rem;
    font-weight: 900;
}

.key-card ol,
.key-overview-card ol {
    margin: 0 0 16px;
    padding-left: 24px;
    line-height: 1.6;
}

.key-card li,
.key-overview-card li {
    margin-bottom: 6px;
}

.keys-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.key-overview-card {
    padding: 20px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgba(24, 33, 47, 0.06);
}

.leaderboard-list span {
    margin-right: 8px;
}

@media (max-width: 820px) {
    .topbar,
    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .login-panel,
    .workspace {
        grid-template-columns: 1fr;
    }

    .grade-grid,
    .type-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-grid {
        grid-template-columns: repeat(6, minmax(44px, 1fr));
    }

    .podium {
        grid-template-columns: 1fr;
    }

    .leaderboard-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .keys-page {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .shell {
        width: min(100% - 16px, 1120px);
        padding-top: 12px;
    }

    .grade-grid,
    .type-grid,
    .answer-options,
    .leaderboard-list {
        grid-template-columns: 1fr;
    }

    .question-card,
    .summary,
    .selector-panel,
    .login-panel {
        padding: 16px;
    }

    .question {
        font-size: 2.15rem;
    }

    .answer-line {
        grid-template-columns: 1fr;
    }

    .time-builder {
        grid-template-columns: 1fr;
    }
}
