/* The crowd runner: a track drawn on a canvas under a header, with the question panel over its top part. The
   overlay is fixed over the page like the other games and carries game-dark-surface, so it is dark in both
   themes. The canvas reads its colours from the custom properties below, and the lane colours are shared by
   the gates on the track and the options in the panel, so a lane and its answer read as one thing. */
.crowd-run-overlay {
    --crowd-run-road: #2a2b32;
    --crowd-run-road-edge: #1c1d22;
    --crowd-run-stripe: rgba(236, 236, 241, 0.16);
    --crowd-run-crowd: #60a5fa;
    --crowd-run-crowd-head: #dbeafe;
    --crowd-run-enemy: #f97316;
    --crowd-run-enemy-head: #ffedd5;
    --crowd-run-enemy-cap: #7c2d12;
    --crowd-run-gain: rgba(45, 212, 191, 0.5);
    --crowd-run-loss: rgba(248, 113, 113, 0.5);
    --crowd-run-text: #f8fafc;
    --crowd-run-castle: #94a3b8;
    --crowd-run-castle-dark: #475569;
    --crowd-run-obstacle: #cbd5e1;
    --crowd-run-lane-0: #3b82f6;
    --crowd-run-lane-1: #f59e0b;
    --crowd-run-lane-2: #22c55e;
    --crowd-run-lane-3: #ec4899;
    --crowd-run-lane-4: #a855f7;

    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--crowd-run-road-edge);
    color: var(--crowd-run-text);
    padding-bottom: env(safe-area-inset-bottom);
}

html:has(.crowd-run-overlay) {
    overscroll-behavior: none;
}

.crowd-run-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top));
    font-variant-numeric: tabular-nums;
}

.crowd-run-score {
    font-size: 1.25rem;
    font-weight: 800;
}

.crowd-run-close-button {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    min-width: 2.75rem;
    min-height: 2.75rem;
}

/* The finger steers on the canvas, so the browser must not take the drag for a scroll or a back gesture. */
.crowd-run-track {
    position: relative;
    flex: 1;
    min-height: 0;
    touch-action: none;
    user-select: none;
}

.crowd-run-canvas {
    position: absolute;
    inset: 0;
    display: block;
}

.crowd-run-panel {
    position: absolute;
    top: calc(3.5rem + env(safe-area-inset-top));
    left: 50%;
    z-index: 20;
    width: min(32rem, calc(100% - 2rem));
    transform: translateX(-50%);
    padding: 0.75rem 1rem 1rem;
    border-radius: 1rem;
    background: rgba(15, 23, 42, 0.92);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45);
    animation: crowd-run-drop-in 220ms ease-out;
}

.crowd-run-panel-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.crowd-run-tag {
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    background: rgba(94, 234, 212, 0.16);
    color: #5eead4;
    font-size: 0.85rem;
    font-weight: 700;
}

.crowd-run-tag.is-rematch {
    background: rgba(253, 224, 71, 0.18);
    color: #fde047;
}

.crowd-run-question-text {
    margin: 0 0 0.6rem;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.crowd-run-options {
    display: grid;
    gap: 0.4rem;
}

.crowd-run-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.35rem 0.6rem 0.35rem 0.35rem;
    border: 2px solid transparent;
    border-radius: 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    color: inherit;
    text-align: left;
}

.crowd-run-option:disabled {
    cursor: default;
}

.crowd-run-option-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-width: 3.25rem;
    height: 2rem;
    border-radius: 0.4rem;
    color: #0f172a;
    font-weight: 900;
}

.crowd-run-lane-0 .crowd-run-option-mark { background: var(--crowd-run-lane-0); }
.crowd-run-lane-1 .crowd-run-option-mark { background: var(--crowd-run-lane-1); }
.crowd-run-lane-2 .crowd-run-option-mark { background: var(--crowd-run-lane-2); }
.crowd-run-lane-3 .crowd-run-option-mark { background: var(--crowd-run-lane-3); }
.crowd-run-lane-4 .crowd-run-option-mark { background: var(--crowd-run-lane-4); }

.crowd-run-option.is-chosen {
    border-color: rgba(255, 255, 255, 0.7);
}

/* After an answer the right option is marked by a border and a check as well as by colour. */
.crowd-run-option.is-correct {
    border-color: #5eead4;
    background: rgba(94, 234, 212, 0.18);
}

.crowd-run-option.is-correct .crowd-run-option-text::after {
    content: " \2713";
    font-weight: 900;
    color: #5eead4;
}

.crowd-run-option.is-wrong {
    border-color: #fca5a5;
    background: rgba(248, 113, 113, 0.14);
}

.crowd-run-option.is-dimmed {
    opacity: 0.55;
}

.crowd-run-verdict {
    margin: 0.6rem 0 0;
    font-weight: 800;
}

.crowd-run-verdict.is-right {
    color: #5eead4;
}

.crowd-run-verdict.is-wrong {
    color: #fca5a5;
}

.crowd-run-panel-loading {
    margin: 0;
}

.crowd-run-result {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.84);
    backdrop-filter: blur(2px);
    animation: crowd-run-fade-in 260ms ease-out;
}

.crowd-run-result-card {
    text-align: center;
    max-width: 22rem;
    width: 100%;
}

.crowd-run-result-title {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
    font-weight: 800;
}

.crowd-run-stars {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
    font-size: 2.25rem;
    color: #94a3b8;
}

.crowd-run-stars .is-earned {
    color: #fde047;
}

.crowd-run-result-record {
    display: inline-block;
    margin: 0 0 0.5rem;
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    background: rgba(253, 224, 71, 0.18);
    color: #fde047;
    font-weight: 800;
}

.crowd-run-result-score {
    margin: 0;
    font-size: 4.5rem;
    line-height: 1;
    font-weight: 900;
    color: #fde047;
    font-variant-numeric: tabular-nums;
}

.crowd-run-result-label {
    margin: 0.25rem 0 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.crowd-run-result-answers {
    margin: 0 0 1.5rem;
}

.crowd-run-result-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

@keyframes crowd-run-drop-in {
    from { opacity: 0; transform: translate(-50%, -0.75rem); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes crowd-run-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.crowd-run-difficulty-button,
.crowd-run-difficulty-button:hover,
.crowd-run-difficulty-button:focus,
.crowd-run-difficulty-button:active {
    margin-left: auto;
    min-height: 2.75rem;
    color: var(--crowd-run-text);
    border: 1px solid rgba(147, 197, 253, 0.6);
}

.crowd-run-difficulty-button + .crowd-run-close-button {
    margin-left: 0;
}

.crowd-run-difficulties {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.crowd-run-difficulty-choice,
.crowd-run-difficulty-choice:hover,
.crowd-run-difficulty-choice:focus,
.crowd-run-difficulty-choice:active {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-height: 2.75rem;
    text-align: left;
    color: var(--crowd-run-text);
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(147, 197, 253, 0.45);
}

.crowd-run-difficulty-choice.is-chosen {
    border-color: #93c5fd;
}

.crowd-run-difficulty-name {
    font-weight: 800;
}

.crowd-run-difficulty-description {
    font-size: 0.9rem;
    opacity: 0.85;
}

.crowd-run-option.is-locked {
    border-color: #fde047;
    background: rgba(253, 224, 71, 0.12);
}

.crowd-run-option-locked {
    margin-left: auto;
    color: #fde047;
    font-size: 0.85rem;
    font-weight: 800;
    white-space: nowrap;
}

.crowd-run-panel-hint {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    opacity: 0.85;
}
