@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');


:root {
    --blue: #2977f5;
    --blue-600: #1f66de;
    --blue-700: #1a52b3;
    --blue-100: #e8f1ff;
    --blue-50: #e4eefc;

    --ink: #12203a;
    --ink-soft: #3c4c67;
    --muted: #6c7b92;
    --faint: #98a4b7;

    --page: #f6f8fc;
    --surface: #ffffff;
    --line: #e5ebf4;
    --line-strong: #d5deea;

    --green: #1fb86a;
    --green-dark: #12844c;
    --green-soft: #e5f8ee;
    --amber: #df8a1c;
    --amber-soft: #fdf2df;
    --red: #e04b52;
    --red-dark: #b7373d;
    --red-soft: #fdecec;

    --radius-sm: 12px;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    --sidebar-w: 264px;
    --shadow-sm: 0 2px 8px rgba(18, 32, 58, 0.04);
    --shadow-md: 0 20px 48px rgba(18, 32, 58, 0.08);
    --shadow-float: 0 18px 40px rgba(18, 32, 58, 0.12);

    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
    background: var(--page);
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(900px 520px at 86% -12%, rgba(41, 119, 245, 0.10), transparent 68%),
        radial-gradient(680px 420px at 6% 104%, rgba(31, 184, 106, 0.055), transparent 70%);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 3px;
}

::selection {
    background: var(--blue);
    color: #fff;
}

[hidden] {
    display: none !important;
}

*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    border: 2px solid var(--page);
    border-radius: 999px;
    background: #cbd6e5;
}

*::-webkit-scrollbar-thumb:hover {
    background: #b3c2d7;
}

/* --------------------------------------------------------------- sidebar -- */

.app-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    padding: 30px 20px 22px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.nav-left {
    display: flex;
    align-items: center;
    padding: 0 8px;
    margin-bottom: 36px;
}

.brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.brand img {
    display: block;
    width: 138px;
    height: auto;
    border-radius: 6px;
}

.links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 700;
    transition: background 140ms ease, color 140ms ease;
}

.nav-link svg {
    flex: 0 0 auto;
    width: 21px;
    height: 21px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-link:hover {
    background: #f0f5fd;
    color: var(--ink);
}

.nav-link.active {
    background: var(--blue-100);
    color: var(--blue-700);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: auto;
    padding: 16px 8px 2px;
    border-top: 1px solid var(--line);
}

.nav-avatar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--blue-100);
    color: var(--blue-700);
}

.nav-avatar svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.nav-user-name {
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user-sub {
    overflow: hidden;
    color: var(--faint);
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--faint);
    transition: background 140ms ease, color 140ms ease;
}

.nav-logout svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-logout:hover {
    background: var(--red-soft);
    color: var(--red);
}

/* ----------------------------------------------------------------- shell -- */

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-w);
    padding: clamp(30px, 5vw, 56px) clamp(22px, 4.8vw, 64px) 84px;
}

.app-main > * {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.home-page > * {
    max-width: 1120px;
}

.quiz-page > * {
    max-width: 860px;
}

.admin-page > * {
    max-width: 1240px;
}

.thanks-page > * {
    max-width: 560px;
}

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

h1 {
    color: var(--ink);
    font-size: clamp(34px, 4.6vw, 54px);
    font-weight: 800;
    line-height: 1.06;
    letter-spacing: -2.2px;
}

h2 {
    color: var(--ink);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* ------------------------------------------------------------- home page -- */

.home-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
    padding: 12px 0 30px;
    border-bottom: 1px solid var(--line);
}

.home-clock {
    flex: 0 0 auto;
    padding: 15px 20px 14px;
    border-radius: 20px;
    text-align: right;
}

.home-clock-label {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    color: var(--blue-700);
    font-size: 13px;
    font-weight: 700;
}

.home-clock-label svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.home-clock-value {
    display: block;
    margin-top: 5px;
    color: var(--blue);
    font-size: clamp(28px, 3.6vw, 42px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -1.6px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.home-clock[data-state='ended'] {
    background: #f1f4f9;
}

.home-clock[data-state='ended'] .home-clock-label {
    color: var(--muted);
}

.home-clock-value[data-state='ended'] {
    color: var(--muted);
}

.home-board {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
    margin-top: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.home-auth,
.home-rules {
    padding: clamp(26px, 3.4vw, 38px);
}

.home-auth {
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

.home-rules {
    border-left: 1px solid var(--line);
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
}

.home-auth h2,
.home-rules h2 {
    font-size: 23px;
}

.login-form {
    margin-top: 22px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 15px;
}

.field label,
.form-row label {
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    padding: 13px 15px;
    border: 1.5px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font-size: 16px;
    transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

input[type='checkbox'],
input[type='radio'] {
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    border-radius: 5px;
    accent-color: var(--blue);
    box-shadow: none;
}

input::placeholder,
textarea::placeholder {
    color: var(--faint);
}

input:hover,
textarea:hover,
select:hover {
    border-color: #c2cedd;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-100);
    outline: none;
}

textarea {
    min-height: 96px;
    line-height: 1.55;
    resize: vertical;
}

.form-note {
    min-height: 20px;
    margin-top: 10px;
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
}

.done-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.done-meta span + span::before {
    content: '·';
    margin-right: 7px;
    color: var(--faint);
}

.done-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
}

#rules-list {
    display: grid;
    gap: 15px;
    margin: 22px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: rule;
}

#rules-list li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    color: var(--ink-soft);
    font-size: 14px;
    line-height: 1.55;
    counter-increment: rule;
}

#rules-list li::before {
    content: counter(rule);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-top: 1px;
    border-radius: 9px;
    background: var(--blue-50);
    color: var(--blue-700);
    font-size: 11px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- buttons -- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 52px;
    padding: 11px 18px;
    border: 0;
    border-radius: 14px;
    background: #eef2f8;
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 0 #dde5f0;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, opacity 120ms ease;
}

.btn:hover {
    background: #e6edf7;
}

.btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #dde5f0;
}

.btn:disabled,
.btn[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
    transform: none;
}

.btn-primary {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 4px 0 var(--blue-700);
}

.btn-primary:hover {
    background: var(--blue-600);
}

.btn-primary:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--blue-700);
}

.btn-ghost {
    border: 1.5px solid var(--line-strong);
    background: transparent;
    color: var(--ink-soft);
}

.btn-ghost:hover {
    border-color: #c2cedd;
    background: var(--blue-50);
    color: var(--ink);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    box-shadow: 0 4px 0 var(--red-dark);
}

.btn-danger:hover {
    background: #d0434a;
}

.btn-danger:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--red-dark);
}

.btn-lg {
    min-height: 52px;
    padding: 14px 24px;
    border-radius: 16px;
    font-size: 15px;
}

.btn-block {
    width: 100%;
    margin-top: 22px;
}

/* ------------------------------------------------------------- quiz page -- */

.quiz-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 4px;
}

.quiz-heading {
    min-width: 0;
}

.quiz-heading h1 {
    overflow: hidden;
    font-size: clamp(25px, 3.2vw, 34px);
    letter-spacing: -1.2px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quiz-sub {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.quiz-top-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 9px;
}

.quiz-timer {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--blue-50);
    color: var(--blue-700);
    font-size: 14px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.quiz-timer svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    stroke-width: 1.9;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.quiz-timer.is-urgent {
    background: var(--amber-soft);
    color: var(--amber);
}

.quiz-timer[data-state='ended'] {
    background: #eef1f6;
    color: var(--muted);
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 22px;
}

.quiz-progress-track {
    flex: 1 1 auto;
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef7;
}

.quiz-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--blue);
    transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1), background 240ms ease;
}

.quiz-progress-fill.is-complete {
    background: var(--green);
}

.quiz-progress-count {
    flex: 0 0 auto;
    min-width: 48px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.notice-banner {
    margin-top: 18px;
    padding: 13px 16px;
    border: 1px solid #cfe0ff;
    border-radius: 14px;
    background: var(--blue-50);
    color: var(--blue-700);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
}

.notice-banner.is-error {
    border-color: #f6cfd1;
    background: var(--red-soft);
    color: var(--red-dark);
}

.quiz-stage,
.quiz-review {
    margin-top: 20px;
    padding: clamp(24px, 4vw, 44px);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.quiz-stage {
    display: flex;
    min-height: 360px;
    flex-direction: column;
    justify-content: center;
}

.quiz-question-text {
    margin-top: 0;
    color: var(--ink);
    font-size: clamp(21px, 2.8vw, 29px);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.6px;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.quiz-media {
    margin-top: 22px;
}

.quiz-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 18px;
}

.quiz-file {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 14px;
    color: var(--blue-700);
    font-size: 14px;
    font-weight: 800;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.quiz-answer-label {
    display: block;
    margin-top: 30px;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
}

.quiz-answer {
    min-height: 120px;
    margin-top: 9px;
    padding: 16px 18px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.55;
}

.quiz-answer:disabled {
    background: #f7f9fc;
    color: var(--muted);
}

.quiz-empty {
    max-width: 460px;
    margin: 0 auto;
    padding: 24px 0;
    text-align: center;
}

.quiz-empty h2 {
    font-size: 26px;
}

.quiz-empty p {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
}

.quiz-loading {
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
}

.quiz-actions {
    position: sticky;
    bottom: 18px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 20px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow-float);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.quiz-actions .btn-lg {
    min-width: 190px;
}

.quiz-map {
    display: flex;
    gap: 8px;
    margin-top: 22px;
    padding: 2px 2px 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.quiz-map::-webkit-scrollbar {
    display: none;
}

.quiz-map button {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 13px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.quiz-map button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.quiz-map button.answered {
    border-color: transparent;
    background: var(--green-soft);
    color: var(--green-dark);
}

.quiz-map button.current {
    border-color: var(--blue);
    color: var(--blue);
    box-shadow: 0 0 0 4px var(--blue-100);
}

.quiz-map button.answered.current {
    color: var(--blue-700);
}

.quiz-review {
    margin-top: 20px;
}

.review-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.review-head h2 {
    font-size: 27px;
}

.review-summary {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.review-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.review-grid button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    border: 1.5px solid var(--line-strong);
    border-radius: 13px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.review-grid button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.review-grid button.answered {
    border-color: transparent;
    background: var(--green-soft);
    color: var(--green-dark);
}

.review-note {
    margin-top: 26px;
    color: var(--muted);
    font-size: 14px;
}

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

/* ---------------------------------------------------------------- modal -- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 22, 43, 0.38);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    animation: modalIn 160ms ease both;
}

.modal-card {
    width: 100%;
    max-width: 420px;
    padding: 30px;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 30px 70px rgba(10, 22, 43, 0.24);
    animation: modalCardIn 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-card h2 {
    font-size: 24px;
}

.modal-message {
    margin-top: 10px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 26px;
}

@keyframes modalIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalCardIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


.thanks-page {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 20px;
    padding-bottom: 100px;
    text-align: center;
}

.thanks-card {
    width: 100%;
    padding: clamp(36px, 5vw, 54px);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.thanks-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    margin: 0 auto 24px;
    border-radius: 24px;
    background: var(--green-soft);
    color: var(--green-dark);
}

.thanks-icon svg {
    width: 38px;
    height: 38px;
    stroke: currentColor;
    stroke-width: 2.4;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.thanks-card h1 {
    font-size: clamp(30px, 4vw, 42px);
    letter-spacing: -1.6px;
}

.thanks-card p {
    margin-top: 12px;
    color: var(--muted);
    font-size: 15px;
}

.thanks-card .btn {
    margin-top: 30px;
}

/* --------------------------------------------------------------- admin --- */

.admin-page h1 {
    font-size: clamp(30px, 3.8vw, 42px);
    letter-spacing: -1.4px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
    margin-top: 26px;
}

.home-card {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.home-card[style*='grid-column'] {
    grid-column: 1 / -1;
}

.home-card h2 {
    margin-bottom: 4px;
    font-size: 18px;
}

.home-card p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.home-card h2 .small-muted {
    margin-left: 6px;
}

.small-muted {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 13px;
}

.form-row select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) calc(50% - 2px), calc(100% - 15px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 38px;
}

.inline-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.status-msg {
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}

.status-success {
    background: var(--green-soft);
    color: var(--green-dark);
}

.status-error {
    background: var(--red-soft);
    color: var(--red-dark);
}

.stocks-table {
    width: 100%;
    margin-top: 12px;
    border-collapse: collapse;
    font-size: 13px;
}

.stocks-table th,
.stocks-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.stocks-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.stocks-table tbody tr:hover {
    background: #fafcff;
}

.stocks-table a {
    color: var(--blue-700);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.text-center {
    text-align: center !important;
}

.activity-scroll {
    max-height: 280px;
    margin-top: 12px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.activity-scroll .stocks-table {
    margin-top: 0;
    padding: 0 10px;
}

.activity-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
}

.cw-builder-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    gap: 18px;
    margin-top: 16px;
}

.cw-admin-preview {
    min-height: 160px;
    padding: 14px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfcfe;
}

.crossword-grid {
    display: grid;
    width: max-content;
}

.cw-admin-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line-strong);
    color: var(--blue-700);
    font-size: 11px;
    font-weight: 800;
}

.cw-admin-cell.black {
    border-color: transparent;
    background: var(--ink);
}

.cw-admin-cell-num {
    position: absolute;
    top: 0;
    left: 2px;
    color: var(--muted);
    font-size: 7px;
    font-weight: 700;
}

.cw-word-list {
    max-height: 320px;
    overflow-y: auto;
}

.cw-word-row {
    display: grid;
    grid-template-columns: 26px 46px minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: 6px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12px;
}

.cw-word-num {
    color: var(--muted);
    font-weight: 800;
}

.cw-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 20px;
    border-radius: 6px;
    background: var(--blue-50);
    color: var(--blue-700);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.cw-badge.down {
    background: var(--green-soft);
    color: var(--green-dark);
}

.cw-word-answer {
    color: var(--ink);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.cw-word-clue {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.overlay2 {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(10, 22, 43, 0.4);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.admin-code-popup {
    display: flex;
    width: min(760px, 94vw);
    max-height: 84vh;
    flex-direction: column;
    align-items: stretch;
    padding: 24px;
    overflow: auto;
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 30px 70px rgba(10, 22, 43, 0.24);
}

.admin-code-popup h2 {
    margin-bottom: 4px;
}

.admin-code-popup a {
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.admin-code-popup a:hover {
    color: var(--blue-700);
}

/* ------------------------------------------------------------ responsive -- */

@media (max-width: 980px) {
    .home-board {
        grid-template-columns: minmax(0, 1fr);
    }

    .home-auth {
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .home-rules {
        border-top: 1px solid var(--line);
        border-left: 0;
        border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    }

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

    .home-card[style*='grid-column'] {
        grid-column: auto;
    }

    .cw-builder-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 860px) {
    :root {
        --sidebar-w: 0px;
    }

    .app-nav {
        inset: auto 0 0 0;
        width: auto;
        height: auto;
        flex-direction: row;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        border-right: 0;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 -8px 28px rgba(18, 32, 58, 0.06);
    }

    .nav-left,
    .nav-user {
        display: none;
    }

    .links {
        flex: 1 1 auto;
        flex-direction: row;
        justify-content: space-around;
        max-width: 440px;
        margin: 0 auto;
        gap: 2px;
    }

    .nav-link {
        flex-direction: column;
        gap: 3px;
        min-width: 64px;
        min-height: 0;
        padding: 7px 12px;
        border-radius: 13px;
        font-size: 11px;
    }

    .nav-link svg {
        width: 22px;
        height: 22px;
    }

    .app-main {
        margin-left: 0;
        padding: 26px 18px calc(102px + env(safe-area-inset-bottom));
    }

    .home-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
        padding-top: 8px;
    }

    .home-clock {
        width: 100%;
        text-align: left;
    }

    .home-clock-label {
        justify-content: flex-start;
    }

    h1 {
        letter-spacing: -1.6px;
    }

    .quiz-topbar {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .quiz-heading {
        flex: 1 1 100%;
    }

    .quiz-top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .quiz-timer {
        flex: 1 1 auto;
        justify-content: center;
    }

    .quiz-actions {
        bottom: calc(78px + env(safe-area-inset-bottom));
        padding: 10px;
    }

    .quiz-actions .btn-lg {
        min-width: 0;
        flex: 1 1 auto;
    }

    .quiz-stage,
    .quiz-review {
        min-height: 320px;
        padding: 22px 20px;
    }

    .review-head {
        flex-direction: column;
        gap: 4px;
    }

    .review-actions {
        flex-direction: column-reverse;
    }

    .review-actions .btn {
        width: 100%;
    }

    .thanks-page {
        justify-content: flex-start;
        padding-top: 12vh;
    }
}

@media (max-width: 560px) {
    .home-clock-value {
        font-size: 30px;
    }

    .done-meta span + span::before {
        content: none;
    }

    .quiz-heading h1 {
        white-space: normal;
    }

    .modal-card {
        padding: 24px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
