/* Display headings: Rokkitt everywhere a heading matters. */
h1, h2, .font-display {
    font-family: 'Rokkitt', Georgia, serif;
    font-optical-sizing: auto;
    letter-spacing: -0.02em;
}
h1 { font-weight: 800; }

/* Subtle page backdrop wave — very low opacity, adds life without noise */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.04;
    background:
        radial-gradient(1200px 500px at 20% -10%, #2A5578 0%, transparent 60%),
        radial-gradient(900px 400px at 95% 18%, #E84E1B 0%, transparent 55%);
    z-index: -1;
}

/* Hero wave divider at bottom of the hero */
.hero-wave {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    width: 100%;
    height: 28px;
    display: block;
    color: #FAF9F7;
}
.dark .hero-wave { color: #0f172a; }

/* Card lift */
.card-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px -12px rgba(6, 25, 41, 0.22);
}
.dark .card-lift:hover {
    box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.5);
}

/* Exam tint badges */
.badge-kvb1 { background: #E7EBF0; color: #0A2540; }
.badge-kvb2 { background: #FEF3F0; color: #7A230B; }
.badge-marifoon { background: #EBF5FF; color: #0E478F; }
.dark .badge-kvb1 { background: rgba(42,85,120,0.25); color: #C4CDD9; }
.dark .badge-kvb2 { background: rgba(232,78,27,0.18); color: #FDBBAC; }
.dark .badge-marifoon { background: rgba(51,153,255,0.18); color: #ADD6FF; }

/* Focus states */
*:focus-visible {
    outline: 2px solid #E84E1B;
    outline-offset: 2px;
}

/* Timer states */
.timer-warning {
    color: #D97706;
}

.timer-critical {
    color: #DC2626;
    animation: pulse-critical 1s ease-in-out infinite;
}

@keyframes pulse-critical {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Image lightbox */
.lightbox-trigger {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.lightbox-trigger:hover {
    transform: scale(1.02);
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 37, 64, 0.9);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Progress bar */
.progress-bar {
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
}

/* Accuracy bars */
.accuracy-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

/* Answer button letter badges */
.choice-badge {
    min-width: 2.25rem;
    height: 2.25rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    flex-shrink: 0;
}

/* Question nav grid circles */
.nav-circle {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

/* Donut score chart */
.score-donut {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-donut::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(
        var(--score-color) 0deg,
        var(--score-color) var(--score-angle),
        #E5E7EB var(--score-angle),
        #E5E7EB 360deg
    );
}

.score-donut::after {
    content: '';
    position: absolute;
    inset: 1.25rem;
    border-radius: 50%;
    background: white;
}

.dark .score-donut::after {
    background: #0F172A;
}

.score-donut-inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

/* Touch targets */
@media (pointer: coarse) {
    button, a, input[type="radio"], input[type="checkbox"] {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Print styles */
@media print {
    nav, .no-print {
        display: none !important;
    }
}

/* Buttons: press feedback and disabled state */
.btn {
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Answer choice rows */
.choice {
    width: 100%;
    text-align: left;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.choice:focus-visible {
    outline: 2px solid #E84E1B;
    outline-offset: 2px;
}

/* Letter badge (A, B, C, D) */
.choice-badge {
    min-width: 2.25rem;
    height: 2.25rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Question nav grid circles */
.nav-circle {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}

/* Current question: the active waypoint gets the accent. */
.nav-circle.is-current {
    background-color: #E84E1B;
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 0 0 3px rgba(232, 78, 27, 0.25);
}

/* Answered question: filled calm ring. */
.nav-circle.is-answered {
    background-color: #D6EBFF;
    color: #1461B8;
}

.dark .nav-circle.is-answered {
    background-color: rgba(51, 153, 255, 0.2);
    color: #85C2FF;
}

/* Unanswered question: quiet outline. */
.nav-circle.is-unanswered {
    background-color: transparent;
    color: #4F7391;
    border: 1px solid #C4CDD9;
}

.dark .nav-circle.is-unanswered {
    color: #94A3B8;
    border-color: #475569;
}

.nav-circle:hover {
    transform: scale(1.08);
}

.nav-circle:focus-visible {
    outline: 2px solid #E84E1B;
    outline-offset: 2px;
}

/* Flag toggle button on the question panel */
.flag-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4F7391;
    transition: color 0.15s ease;
}

.flag-toggle:hover {
    color: #3399FF;
}

.flag-toggle.is-flagged {
    color: #3399FF;
    font-weight: 600;
}

.dark .flag-toggle {
    color: #94A3B8;
}

.dark .flag-toggle.is-flagged,
.dark .flag-toggle:hover {
    color: #85C2FF;
}

/* Question nav grid cells (exam mode) */
.nav-cell {
    position: relative;
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: transform 0.15s ease, background-color 0.15s ease,
        border-color 0.15s ease, color 0.15s ease;
}

/* Active question: single prominent orange border. Exactly one cell has this. */
.nav-cell.is-active {
    background-color: #FFFFFF;
    color: #0A2540;
    border: 3px solid #E84E1B;
    font-weight: 600;
}

.dark .nav-cell.is-active {
    background-color: #1E293B;
    color: #F1F5F9;
}

/* Answered: neutral filled background. */
.nav-cell.is-answered {
    background-color: #1B3F5C;
    color: #FFFFFF;
    border: 1px solid #1B3F5C;
}

.dark .nav-cell.is-answered {
    background-color: #2A5578;
    border-color: #2A5578;
}

/* Unanswered: white with thin border. */
.nav-cell.is-unanswered {
    background-color: #FFFFFF;
    color: #4F7391;
    border: 1px solid #C4CDD9;
}

.dark .nav-cell.is-unanswered {
    background-color: #1E293B;
    color: #94A3B8;
    border-color: #475569;
}

/* Flagged: small flag icon, top-right corner, calm blue. Stacks with every state. */
.nav-cell.is-flagged::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -4px;
    width: 14px;
    height: 14px;
    background-color: #3399FF;
    border: 2px solid #FAF9F7;
    border-radius: 3px;
    /* Lucide flag glyph as a mask, drawn in white on the blue badge */
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M4 22V2h2v3h11l-3 4 3 4H6v9H4z'/%3E%3C/svg%3E") center / 10px 10px no-repeat,
        linear-gradient(#3399FF, #3399FF);
    -webkit-mask-composite: source-over;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M4 22V2h2v3h11l-3 4 3 4H6v9H4z'/%3E%3C/svg%3E") center / 10px 10px no-repeat;
}

.dark .nav-cell.is-flagged::after {
    border-color: #0F172A;
}

.nav-cell:hover {
    transform: scale(1.08);
}

.nav-cell:focus-visible {
    outline: 2px solid #E84E1B;
    outline-offset: 2px;
}

/* Exam timer */
.timer {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.timer-warning {
    color: #D97706;
}

.timer-critical {
    color: #DC2626;
    animation: pulse-critical 1s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .timer-critical {
        animation: none;
        font-weight: 700;
    }
}

/* Modal overlay and card */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 25, 41, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none;
}

.dark .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

.modal-card {
    background: #FFFFFF;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    max-width: 28rem;
    width: 100%;
    padding: 1.5rem;
    animation: modal-in 0.18s ease-out;
}

.dark .modal-card {
    background: #1E293B;
    color: #F1F5F9;
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .modal-card {
        animation: none;
    }
}

/* Brand spinner: the wheel mark rotates */
.spinner-wheel {
    animation: wheel-turn 1.2s linear infinite;
    transform-origin: center;
}

@keyframes wheel-turn {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner-wheel {
        animation: none;
    }
}

/* HTMX indicator and global brand spinner container */
.htmx-indicator {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
}

.htmx-request .htmx-indicator,
.htmx-indicator.is-active {
    opacity: 1;
    visibility: visible;
}

#brand-spinner {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(250, 249, 247, 0.85);
    pointer-events: none;
}

.dark #brand-spinner {
    background: rgba(15, 23, 42, 0.85);
}

#brand-spinner .spinner-wheel {
    width: 40px;
    height: 40px;
    color: #4F7391;
}

.dark #brand-spinner .spinner-wheel {
    color: #94A3B8;
}

#brand-spinner-message {
    font-size: 0.875rem;
    font-weight: 500;
    color: #0A2540;
}

.dark #brand-spinner-message {
    color: #F1F5F9;
}

/* Vaarkaart - SVG trail with buoy markers and sailboat for today */

/* Token blocks - light mode */
.treasure-map {
    --water-base: #DCEBFA;
    --water-far: #E8F3FD;
    --water-mid: #D8E9F9;
    --water-near: #CBE1F6;
    --water-line: #1B3F5C;
    --flag-pass: #059669;
    --flag-fail: #C0392B;
    --flag-gold: #F5C542;
    --flag-gold-edge: #B07E12;
    --flag-shine: #FFF3C4;
    --decor-wood: #8A6A4B;
    --decor-gull: #4F7391;
}

/* Token blocks - dark mode */
.dark .treasure-map {
    --water-base: #072133;
    --water-far: #0A2B42;
    --water-mid: #082539;
    --water-near: #061D2E;
    --water-line: #7DA8C7;
    --flag-pass: #34D399;
    --flag-fail: #E8776B;
    --flag-gold: #FFD966;
    --flag-gold-edge: #C79A1E;
    --flag-shine: #FFF8DC;
    --decor-wood: #A98A6A;
    --decor-gull: #9DB6CC;
}

.treasure-map-container {
    position: relative;
    width: 100%;
    max-height: 420px;
}

.treasure-map-svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 420px;
    border-radius: 12px;
}

/* Archived/expired journey: dimmed grayscale treatment */
.treasure-map--archived .treasure-map-container {
    filter: grayscale(0.4) opacity(0.85);
}

.dark .treasure-map--archived .treasure-map-container {
    filter: grayscale(0.35) opacity(0.80);
}

/* Water background */
.water-base {
    fill: var(--water-base);
}

.water-band--far {
    fill: var(--water-far);
}

.water-band--mid {
    fill: var(--water-mid);
}

.water-band--near {
    fill: var(--water-near);
}

.water-pattern-wave {
    stroke: var(--water-line);
    stroke-width: 1.4;
    opacity: 0.07;
}

.dark .water-pattern-wave {
    opacity: 0.14;
}

/* Water texture waves - sparse gentle squiggles under the trail */
.treasure-waves path {
    fill: none;
    stroke: var(--water-line, #1B3F5C);
    stroke-width: 1.5;
    stroke-linecap: round;
    opacity: 0.10;
}

.dark .treasure-waves path {
    opacity: 0.14;
}

.treasure-trail {
    stroke: #0A2540;
    opacity: 0.45;
}

.dark .treasure-trail {
    stroke: #C4CDD9;
    opacity: 0.30;
}

.treasure-markers-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* Base marker styles */
.treasure-marker {
    position: absolute;
    pointer-events: auto;
    cursor: default;
    transition: transform 0.15s ease;
}

.treasure-marker:focus-visible {
    outline: 2px solid #E84E1B;
    outline-offset: 2px;
}

.treasure-marker:hover,
.treasure-marker:focus {
    transform: scale(1.25);
    z-index: 10;
}

.marker-icon {
    display: block;
    width: 100%;
    height: 100%;
    transform-origin: 50% 88%;
}

/* Buoy markers - sizes per B4 table */
.treasure-buoy {
    width: 18px;
    height: 23px;
    margin-left: -9px;
    margin-top: -19.8px;
    --buoy-stroke: #4F7391;
    --buoy-fill: none;
    --buoy-pennant: transparent;
}

@media (min-width: 640px) {
    .treasure-buoy {
        width: 20px;
        height: 26px;
        margin-left: -10px;
        margin-top: -22.4px;
    }
}

/* Exam buoy markers */
.treasure-exam-buoy {
    width: 20px;
    height: 30px;
    margin-left: -10px;
    margin-top: -27.4px;
    --buoy-stroke: #0A2540;
    --buoy-fill: none;
}

@media (min-width: 640px) {
    .treasure-exam-buoy {
        width: 24px;
        height: 36px;
        margin-left: -12px;
        margin-top: -32.9px;
    }
}

.dark .treasure-exam-buoy {
    --buoy-stroke: #C4CDD9;
}

/* Decoration markers */
.treasure-decor {
    opacity: 0.30;
}

.dark .treasure-decor {
    opacity: 0.34;
}

.treasure-decor--plain {
    opacity: 0.22;
}

.treasure-decor--gull {
    width: 16px;
    height: 10px;
    margin-left: -8px;
    margin-top: -17px;
}

@media (min-width: 640px) {
    .treasure-decor--gull {
        width: 18px;
        height: 11px;
        margin-left: -9px;
        margin-top: -19px;
    }
}

.treasure-decor--driftwood {
    width: 18px;
    height: 10px;
    margin-left: -9px;
    margin-top: -7.9px;
}

@media (min-width: 640px) {
    .treasure-decor--driftwood {
        width: 20px;
        height: 11px;
        margin-left: -10px;
        margin-top: -8.7px;
    }
}

.treasure-decor--plain {
    width: 12px;
    height: 8px;
    margin-left: -6px;
    margin-top: -4.6px;
}

@media (min-width: 640px) {
    .treasure-decor--plain {
        width: 14px;
        height: 9px;
        margin-left: -7px;
        margin-top: -5.2px;
    }
}

.buoy-icon,
.exam-buoy-icon,
.gull-icon,
.driftwood-icon,
.ripple-icon {
    width: 100%;
    height: 100%;
    display: block;
}

/* Marker states */
.treasure-marker--inactive {
    --buoy-stroke: #4F7391;
    --buoy-fill: none;
    --buoy-pennant: transparent;
}

.dark .treasure-marker--inactive {
    --buoy-stroke: #7690A8;
}

.treasure-marker--active {
    --buoy-stroke: #0A2540;
    --buoy-fill: #0A2540;
    --buoy-pennant: #059669;
}

.dark .treasure-marker--active {
    --buoy-stroke: #C4CDD9;
    --buoy-fill: #C4CDD9;
    --buoy-pennant: #34D399;
}

.treasure-marker--future {
    opacity: 0.4;
    --buoy-stroke: #9DADBF;
    --buoy-fill: none;
    --buoy-pennant: transparent;
}

.dark .treasure-marker--future {
    --buoy-stroke: #475569;
}

/* Exam flags */
.exam-flag {
    stroke: none;
}

.exam-flag--pass {
    fill: var(--flag-pass);
}

.exam-flag--fail {
    fill: var(--flag-fail);
}

.exam-flag--gold {
    fill: var(--flag-gold);
    stroke: var(--flag-gold-edge);
    stroke-width: 0.5;
    filter: drop-shadow(0 0 2px rgba(245, 197, 66, 0.55));
}

.exam-flag-shine {
    fill: var(--flag-shine);
    opacity: 0.75;
}

.exam-mini-flag {
    stroke: none;
}

/* Day number labels */
.treasure-marker-label {
    position: absolute;
    top: calc(100% - 2px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 600;
    color: #1B3F5C;
    white-space: nowrap;
    pointer-events: none;
}

@media (min-width: 640px) {
    .treasure-marker-label {
        font-size: 10px;
        top: calc(100% - 1px);
    }
}

.dark .treasure-marker-label {
    color: #B8D9F5;
}

/* Sailboat marker for today */
.treasure-boat {
    width: 35px;
    height: 41px;
    margin-left: -17.5px;
    margin-top: -35.4px;
    z-index: 5;
    filter: drop-shadow(0 0 4px rgba(10, 37, 64, 0.4));
    --boat-hull: #0A2540;
    --boat-stroke: #0A2540;
    --boat-sail: white;
    --boat-sail-shade: #DCE4EC;
    --boat-stripe: #FAF9F7;
    --boat-wake: #4F7391;
    --boat-pennant: transparent;
}

@media (min-width: 640px) {
    .treasure-boat {
        width: 40px;
        height: 47px;
        margin-left: -20px;
        margin-top: -40.6px;
    }
}

.boat-icon {
    width: 100%;
    height: 100%;
    display: block;
}

.dark .treasure-boat {
    filter: drop-shadow(0 0 4px rgba(250, 249, 247, 0.4));
    --boat-hull: #C4CDD9;
    --boat-stroke: #C4CDD9;
    --boat-sail: #FAF9F7;
    --boat-sail-shade: #94A3B8;
    --boat-stripe: #1E293B;
    --boat-wake: #7DA8C7;
}

/* Sailboat with active practice: show green pennant */
.treasure-boat--active {
    --boat-pennant: #059669;
}

.dark .treasure-boat--active {
    --boat-pennant: #34D399;
}

/* Sailboat pennant colour by today's best exam outcome (J6) */
.treasure-boat--cum_laude {
    --boat-pennant: var(--flag-gold);
}

.treasure-boat--passed {
    --boat-pennant: var(--flag-pass);
}

.treasure-boat--failed {
    --boat-pennant: var(--flag-fail);
}

/* Consolidated tooltip styles for all markers */
.treasure-marker[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 0.375rem 0.625rem;
    background: #0A2540;
    color: #FFFFFF;
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: pre-line;
    width: max-content;
    max-width: 260px;
    text-align: left;
    border-radius: 0.375rem;
    display: none;
    z-index: 30;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dark .treasure-marker[data-tooltip]::after {
    background: #F1F5F9;
    color: #0A2540;
}

.treasure-marker[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #0A2540;
    display: none;
    z-index: 30;
}

.dark .treasure-marker[data-tooltip]::before {
    border-top-color: #F1F5F9;
}

.treasure-marker:hover[data-tooltip]::after,
.treasure-marker:hover[data-tooltip]::before,
.treasure-marker:focus[data-tooltip]::after,
.treasure-marker:focus[data-tooltip]::before {
    display: block;
}

/* Legend chip styles */
.legend-chip {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.legend-chip path,
.legend-chip line {
    fill: none;
    stroke: #4F7391;
}

.legend-chip--active path,
.legend-chip--active line {
    fill: #0A2540;
    stroke: #0A2540;
}

.legend-chip--active path:last-child {
    fill: #059669;
    stroke: none;
}

.dark .legend-chip--active path,
.dark .legend-chip--active line {
    fill: #C4CDD9;
    stroke: #C4CDD9;
}

.dark .legend-chip--active path:last-child {
    fill: #34D399;
}

.legend-chip--exam path,
.legend-chip--exam line {
    fill: none;
    stroke: #0A2540;
}

.dark .legend-chip--exam path,
.dark .legend-chip--exam line {
    stroke: #C4CDD9;
}

.legend-chip--flag {
    width: 12px;
    height: 12px;
}

.legend-chip--flag .legend-flag--pass {
    fill: var(--flag-pass);
}

.legend-chip--flag .legend-flag--fail {
    fill: var(--flag-fail);
}

.legend-chip--flag .legend-flag--gold {
    fill: var(--flag-gold);
    stroke: var(--flag-gold-edge);
    stroke-width: 0.5;
}

/* Finish beacon (lighthouse with checkered band) */
.treasure-finish {
    opacity: 0.7;
}

.finish-rock {
    fill: #4F7391;
}

.finish-tower {
    fill: #FAF9F7;
    stroke: #0A2540;
    stroke-width: 1;
}

.finish-checker--dark {
    fill: var(--water-line, #1B3F5C);
}

.finish-checker--light {
    fill: #FFFFFF;
}

.finish-lamp {
    fill: var(--flag-gold);
    opacity: 0.6;
}

.finish-roof {
    fill: #0A2540;
}

.treasure-finish-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: #1B3F5C;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dark .finish-rock {
    fill: #64748B;
}

.dark .finish-tower {
    fill: #1E293B;
    stroke: #C4CDD9;
}

.dark .finish-checker--dark {
    fill: #C4CDD9;
}

.dark .finish-roof {
    fill: #C4CDD9;
}

.dark .treasure-finish-label {
    fill: #B8D9F5;
}

/* Finish bunting and flags (hidden by default) */
.finish-bunting,
.finish-flag {
    display: none;
}

.treasure-finish--lit .finish-lamp {
    fill: var(--flag-gold);
    opacity: 0.9;
}

.treasure-finish--celebrating .finish-lamp {
    fill: var(--flag-gold);
    opacity: 1;
}

.treasure-finish--celebrating .finish-bunting {
    display: block;
    stroke: #0A2540;
}

.dark .treasure-finish--celebrating .finish-bunting {
    stroke: #C4CDD9;
}

.treasure-finish--celebrating .finish-flag {
    display: block;
}

.treasure-finish--celebrating .finish-flag--1 {
    fill: var(--flag-pass);
}

.treasure-finish--celebrating .finish-flag--2 {
    fill: var(--flag-gold);
}

.treasure-finish--celebrating .finish-flag--3 {
    fill: var(--flag-fail);
}

/* Start lighthouse */
.treasure-start {
    opacity: 0.7;
}

.start-rock {
    fill: #4F7391;
}

.start-tower {
    fill: #FAF9F7;
    stroke: #0A2540;
    stroke-width: 1;
}

.start-band {
    fill: #C0392B;
}

.start-lamp {
    fill: var(--flag-gold);
    opacity: 0.6;
}

.start-roof {
    fill: #0A2540;
}

.treasure-start-label {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    fill: #1B3F5C;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dark .start-rock {
    fill: #64748B;
}

.dark .start-tower {
    fill: #1E293B;
    stroke: #C4CDD9;
}

.dark .start-roof {
    fill: #C4CDD9;
}

.dark .treasure-start-label {
    fill: #B8D9F5;
}

/* Animations - all inside prefers-reduced-motion: no-preference */
@media (prefers-reduced-motion: no-preference) {
    @keyframes marker-bob {
        0%, 100% {
            transform: translateY(0) rotate(-2.4deg);
        }
        50% {
            transform: translateY(-2.6px) rotate(2.4deg);
        }
    }

    @keyframes boat-swell {
        0%, 100% {
            transform: translateY(0) rotate(-3deg);
        }
        50% {
            transform: translateY(-3.6px) rotate(3deg);
        }
    }

    @keyframes wave-drift {
        0%, 100% {
            transform: translateX(0);
        }
        50% {
            transform: translateX(8px);
        }
    }

    @keyframes water-pan {
        0% {
            transform: translateX(0);
        }
        100% {
            transform: translateX(-60px);
        }
    }

    @keyframes flag-flutter {
        0%, 100% {
            transform: scaleX(1);
        }
        50% {
            transform: scaleX(0.82);
        }
    }

    @keyframes harbor-pulse {
        0%, 100% {
            transform: scale(1);
            opacity: 0.7;
        }
        50% {
            transform: scale(3.4);
            opacity: 0;
        }
    }

    /* Apply bob to .marker-icon (not the outer span) to fix hover-zoom bug */
    .treasure-marker .marker-icon {
        animation: marker-bob 3.6s ease-in-out infinite;
    }

    /* 7 phase buckets (7 coprime with 6-per-row grid) */
    .treasure-marker:nth-child(7n+1) .marker-icon { animation-delay: 0s; }
    .treasure-marker:nth-child(7n+2) .marker-icon { animation-delay: -0.51s; }
    .treasure-marker:nth-child(7n+3) .marker-icon { animation-delay: -1.03s; }
    .treasure-marker:nth-child(7n+4) .marker-icon { animation-delay: -1.54s; }
    .treasure-marker:nth-child(7n+5) .marker-icon { animation-delay: -2.06s; }
    .treasure-marker:nth-child(7n+6) .marker-icon { animation-delay: -2.57s; }
    .treasure-marker:nth-child(7n) .marker-icon { animation-delay: -3.09s; }

    .treasure-boat .marker-icon {
        animation: boat-swell 4.2s ease-in-out infinite;
    }

    .treasure-waves path {
        animation: wave-drift 8s ease-in-out infinite;
    }

    .treasure-waves path:nth-child(2n) {
        animation-delay: -2s;
    }

    .treasure-waves path:nth-child(3n) {
        animation-delay: -4s;
    }

    .water-texture {
        animation: water-pan 26s linear infinite;
    }

    .exam-flag,
    .exam-mini-flag {
        animation: flag-flutter 2.8s ease-in-out infinite;
        transform-box: fill-box;
        transform-origin: left center;
    }

    .exam-flag:nth-of-type(2) { animation-delay: -0.7s; }
    .exam-mini-flag:nth-of-type(1) { animation-delay: -1.4s; }
    .exam-mini-flag:nth-of-type(2) { animation-delay: -2.1s; }

    .treasure-finish--lit .finish-lamp,
    .treasure-finish--celebrating .finish-lamp {
        animation: harbor-pulse 3s ease-in-out infinite;
    }
}

@media (prefers-reduced-motion: reduce) {
    .treasure-marker,
    .treasure-marker .marker-icon,
    .treasure-boat,
    .treasure-boat .marker-icon,
    .treasure-waves path,
    .water-texture,
    .exam-flag,
    .exam-mini-flag,
    .finish-lamp {
        animation: none;
        transition: none;
    }
}

/* Toast notification system */
.toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 24rem;
    pointer-events: none;
}

@media (max-width: 639px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    border: 1px solid;
    font-size: 0.875rem;
    line-height: 1.4;
    background: #FFFFFF;
    box-shadow: 0 10px 25px -5px rgba(6, 25, 41, 0.15), 0 8px 10px -6px rgba(6, 25, 41, 0.1);
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
}

.dark .toast {
    background: #1E293B;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(1rem);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (max-width: 639px) {
    @keyframes toast-in {
        from {
            opacity: 0;
            transform: translateY(-0.5rem);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

.toast--removing {
    animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(1rem);
    }
}

@media (max-width: 639px) {
    @keyframes toast-out {
        from {
            opacity: 1;
            transform: translateY(0);
        }
        to {
            opacity: 0;
            transform: translateY(-0.5rem);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }
    .toast--removing {
        animation: none;
        opacity: 0;
    }
}

.toast--success {
    border-color: #A7F3D0;
    background: #ECFDF5;
    color: #065F46;
}

.dark .toast--success {
    border-color: #065F46;
    background: rgba(6, 95, 70, 0.2);
    color: #A7F3D0;
}

.toast--error,
.toast--warning {
    border-color: #FECACA;
    background: #FEF2F2;
    color: #991B1B;
}

.dark .toast--error,
.dark .toast--warning {
    border-color: #991B1B;
    background: rgba(153, 27, 27, 0.2);
    color: #FECACA;
}

.toast--info {
    border-color: #BFDBFE;
    background: #EFF6FF;
    color: #1E40AF;
}

.dark .toast--info {
    border-color: #1E40AF;
    background: rgba(30, 64, 175, 0.2);
    color: #BFDBFE;
}

.toast__icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.0625rem;
}

.toast__message {
    flex: 1;
    min-width: 0;
}

.toast__dismiss {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s ease;
    padding: 0.125rem;
    margin: -0.125rem;
    border-radius: 0.25rem;
}

.toast__dismiss:hover,
.toast__dismiss:focus {
    opacity: 1;
}

.toast__dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ─── Exam tools: Kaart viewer ─────────────────────────────────────────── */

.modal-card-wide {
    max-width: min(76rem, 96vw);
    height: min(84vh, 56rem);
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
}

@media (max-width: 640px) {
    .modal-card-wide {
        height: calc(100dvh - 2rem);
    }
}

.chart-viewport {
    position: relative;
    flex: 1;
    overflow: hidden;
    border-radius: 0.75rem;
    border: 1px solid #E2E8F0;
    background: #F8FAFC;
    touch-action: none;
    cursor: grab;
}

.dark .chart-viewport {
    border-color: #334155;
    background: #0F172A;
}

.chart-viewport.is-panning {
    cursor: grabbing;
}

#chart-image {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
}

.chart-message {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: #64748B;
}

.dark .chart-message {
    color: #94A3B8;
}


.chart-ctrl {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: 1.5px solid #CBD5E1;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-height: 2rem;
}

.dark .chart-ctrl {
    border-color: #475569;
    color: #94A3B8;
}

.chart-ctrl:hover {
    border-color: #94A3B8;
    background: #F1F5F9;
}

.dark .chart-ctrl:hover {
    border-color: #64748B;
    background: #1E293B;
}

/* Floating calculator panel (non-blocking, draggable) */
.calc-panel { position: fixed; right: 1rem; bottom: 1rem; width: 18.5rem; z-index: 45; box-shadow: 0 20px 45px -12px rgba(6,25,41,0.4); }
.dark .calc-panel { box-shadow: 0 20px 45px -12px rgba(0,0,0,0.6); }
.calc-panel.hidden { display: none; }
.calc-panel:focus { outline: none; }
.calc-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.5rem 0.5rem 1rem; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.calc-panel.is-dragging .calc-header { cursor: grabbing; }
.calc-body { padding: 0 0.75rem 0.75rem; }
.calc-panel.is-minimized { width: auto; min-width: 13rem; }
.calc-panel.is-minimized .calc-body { display: none; }
.calc-panel.is-minimized .calc-icon-minimize { display: none; }
.calc-panel:not(.is-minimized) .calc-icon-restore { display: none; }
@media (max-width: 639px) { .calc-panel { right: 0.5rem; bottom: 0.5rem; } }

/* Floating chart panel (non-blocking, draggable, resizable on desktop) */
.chart-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(44rem, 70vw);
    height: min(30rem, 70vh);
    min-width: 20rem;
    max-width: 96vw;
    min-height: 16rem;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    z-index: 46;
    background: #FFFFFF;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
}
.dark .chart-panel { background: #1E293B; }
.chart-panel.hidden { display: none; }
.chart-header { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.chart-panel.is-dragging .chart-header { cursor: grabbing; }

.chart-zoom-controls {
    padding-right: 2.75rem;
}

.chart-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 2.75rem;
    height: 2.75rem;
    cursor: nwse-resize;
    touch-action: none;
    border-bottom-right-radius: 1rem;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0.375rem;
    color: #94A3B8;
}
.dark .chart-resize-handle { color: #475569; }

@media (max-width: 639px) {
    .chart-panel {
        inset: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        transform: none;
        z-index: 60;
        min-width: unset;
        max-width: unset;
        min-height: unset;
        max-height: unset;
    }
    .chart-header { cursor: default; }
    .chart-resize-handle { display: none; }
    body.chart-open { overflow: hidden; }
}
