:root {
    --bg: #071319;
    --surface: #0d2028;
    --surface-2: #12313c;
    --line: rgba(187, 238, 222, 0.16);
    --text: #eef9f6;
    --muted: #9db8b4;
    --primary: #2dd4bf;
    --primary-dark: #0f766e;
    --accent: #38bdf8;
    --danger: #f87171;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(45, 212, 191, 0.18), transparent 34rem),
        linear-gradient(135deg, #071319 0%, #0a1d26 52%, #061014 100%);
}

a {
    color: inherit;
}

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

.hero,
.card,
.quiz-shell,
.dashboard {
    animation: rise 260ms ease-out;
}

.hero {
    min-height: calc(100vh - 48px);
    display: grid;
    align-content: center;
    gap: 32px;
}

.hero-copy {
    max-width: 720px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
    line-height: 1.08;
}

h1 {
    font-size: clamp(2.1rem, 7vw, 4.8rem);
}

h2 {
    font-size: 1.15rem;
}

p {
    color: var(--muted);
    line-height: 1.55;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 680px;
}

.admin-corner-link {
    position: fixed;
    right: 14px;
    bottom: 12px;
    z-index: 5;
    padding: 8px 10px;
    border: 1px solid rgba(187, 238, 222, 0.12);
    border-radius: 8px;
    color: rgba(238, 249, 246, 0.46);
    background: rgba(7, 19, 25, 0.48);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.admin-corner-link:hover,
.admin-corner-link:focus {
    color: var(--text);
    border-color: var(--line);
    background: rgba(13, 32, 40, 0.9);
}

.button {
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    color: #031311;
    background: var(--primary);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button.primary {
    background: var(--primary);
}

.button.accent {
    background: var(--accent);
}

.button.ghost,
.button.quiet {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--line);
}

.button.danger {
    color: #2b0707;
    background: var(--danger);
}

.button.small {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.86rem;
}

.button.full {
    width: 100%;
}

.card,
.question-card,
.panel,
.metric {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(13, 32, 40, 0.86);
    box-shadow: var(--shadow);
}

.card {
    padding: 28px;
}

.narrow {
    max-width: 560px;
    margin: 48px auto;
}

.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.self-start {
    align-self: flex-start;
}

.back-link {
    display: inline-flex;
    margin-bottom: 18px;
    color: var(--muted);
    text-decoration: none;
}

.form-stack {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

label {
    color: var(--text);
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: #091920;
    font: inherit;
}

textarea {
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: rgba(238, 249, 246, 0.48);
}

select option {
    color: #08151a;
    background: #ffffff;
}

.hint {
    margin: 0;
    font-size: 0.92rem;
}

.hidden {
    display: none;
}

.flash-stack {
    position: sticky;
    top: 16px;
    z-index: 10;
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.flash {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.78);
}

.quiz-shell {
    max-width: 880px;
    margin: 20px auto 48px;
}

.quiz-header,
.dashboard-top,
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.progress-label {
    min-width: 68px;
    padding: 10px 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 900;
    color: var(--primary);
    background: rgba(45, 212, 191, 0.1);
}

.progress-track {
    height: 10px;
    margin: 18px 0 22px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 180ms ease;
}

.question-list {
    display: grid;
    gap: 16px;
}

.question-card {
    margin: 0;
    padding: 18px;
}

.question-card legend {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    font-size: 1.03rem;
    font-weight: 800;
}

.question-card legend span {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #031311;
    background: var(--primary);
}

.option-card {
    display: grid;
    grid-template-columns: auto 34px 1fr;
    align-items: center;
    gap: 10px;
    min-height: 50px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
}

.option-card:has(input:checked) {
    border-color: var(--primary);
    background: rgba(45, 212, 191, 0.12);
}

.option-card input {
    width: 18px;
    min-height: 18px;
}

.option-key {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--primary);
    background: rgba(45, 212, 191, 0.1);
    font-weight: 900;
}

.success-mark {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
    border-radius: 50%;
    color: #031311;
    background: var(--primary);
    font-size: 2.2rem;
    font-weight: 900;
}

.dashboard {
    display: grid;
    gap: 20px;
    margin-bottom: 48px;
}

.metric-grid,
.chart-grid {
    display: grid;
    gap: 14px;
}

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

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

.metric,
.panel {
    min-width: 0;
    padding: 18px;
}

.metric span,
.metric small {
    display: block;
    color: var(--muted);
}

.metric strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 2rem;
    color: var(--primary);
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.panel-note {
    margin: 6px 0 0;
    font-size: 0.92rem;
}

.student-search {
    max-width: 280px;
    min-height: 44px;
}

.question-editor {
    max-width: 860px;
    margin: 32px auto;
}

.admin-question-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

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

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.check-row input {
    width: 18px;
    min-height: 18px;
}

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

.row-actions form {
    margin: 0;
}

.danger-box {
    display: grid;
    gap: 12px;
    margin-top: 22px;
    padding: 16px;
    border: 1px solid rgba(248, 113, 113, 0.45);
    border-radius: 8px;
    background: rgba(127, 29, 29, 0.22);
}

.danger-box h2,
.danger-box p {
    margin: 0;
}

.data-totals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.data-totals span {
    padding: 10px;
    border-radius: 8px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.05);
}

.data-totals strong {
    color: var(--text);
}

.student-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.student-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.student-card summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    cursor: pointer;
    list-style: none;
}

.student-card summary::-webkit-details-marker {
    display: none;
}

.student-name {
    font-weight: 900;
}

.student-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 999px;
    color: #031311;
    background: var(--primary);
    font-size: 0.78rem;
    font-weight: 900;
    white-space: nowrap;
}

.badge.accent {
    background: var(--accent);
}

.badge.muted {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.badge.warn {
    color: #1f1300;
    background: #fbbf24;
}

.student-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 0 14px 14px;
}

.student-attempt {
    min-width: 0;
    padding: 12px;
    border: 1px solid rgba(187, 238, 222, 0.1);
    border-radius: 8px;
    background: rgba(7, 19, 25, 0.45);
}

.student-attempt h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.attempt-metrics {
    display: grid;
    gap: 3px;
    margin-bottom: 10px;
}

.attempt-metrics strong {
    color: var(--primary);
    font-size: 1.6rem;
}

.attempt-metrics small,
.attempt-metrics span {
    color: var(--muted);
}

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

.answer-pill {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 900;
}

.answer-pill.ok {
    color: #031311;
    background: var(--primary);
}

.answer-pill.bad {
    color: #2b0707;
    background: var(--danger);
}

canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 280px;
    margin-top: 16px;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-top: 14px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--primary);
    font-size: 0.86rem;
    text-transform: uppercase;
}

.qr-image {
    width: min(280px, 80vw);
    margin: 18px 0;
    padding: 12px;
    border-radius: 8px;
    background: white;
}

.url-pill {
    width: 100%;
    overflow-wrap: anywhere;
    padding: 12px;
    border-radius: 8px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 860px) {
    .page-shell {
        padding: 16px;
    }

    .action-grid,
    .chart-grid {
        grid-template-columns: 1fr;
    }

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

    .dashboard-top,
    .quiz-header,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar .button {
        width: 100%;
    }

    .dashboard {
        gap: 14px;
    }

    .dashboard-top h1 {
        font-size: 2rem;
    }

    .metric,
    .panel {
        padding: 14px;
    }

    .panel-heading {
        flex-direction: column;
    }

    .student-search {
        max-width: none;
    }

    .admin-question-grid,
    .admin-question-grid.compact {
        grid-template-columns: 1fr;
    }

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions .button,
    .row-actions form {
        width: 100%;
    }

    .data-totals {
        grid-template-columns: 1fr;
    }

    .student-card summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .student-badges {
        justify-content: flex-start;
    }

    .student-detail-grid {
        grid-template-columns: 1fr;
        padding: 0 12px 12px;
    }

    .answer-grid {
        grid-template-columns: repeat(5, minmax(42px, 1fr));
    }

    .metric strong {
        font-size: 1.55rem;
    }

    canvas {
        height: 220px;
    }

    .table-wrap {
        overflow: visible;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    table {
        min-width: 0;
    }

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

    tbody {
        display: grid;
        gap: 12px;
    }

    tr {
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.04);
    }

    td {
        display: grid;
        grid-template-columns: minmax(92px, 34%) 1fr;
        gap: 10px;
        padding: 8px 0;
        border-bottom: 1px solid rgba(187, 238, 222, 0.1);
        overflow-wrap: anywhere;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--primary);
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .hero {
        min-height: calc(100vh - 32px);
    }

    .card {
        padding: 22px;
    }

    h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 420px) {
    .page-shell {
        padding: 12px;
    }

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

    .dashboard-top h1 {
        font-size: 1.75rem;
    }

    td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

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