/* ═══════════════════════════════════════════════════════════════
   ORÐAGREINING - Nordic Volcanic Dark Theme
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Volcanic Dark Palette */
    --bg-deep: #0a0b0f;
    --bg-surface: #12141a;
    --bg-elevated: #1a1d26;
    --bg-card: #1f222d;

    /* Aurora Accent Colors */
    --aurora-green: #4ade80;
    --aurora-teal: #2dd4bf;
    --aurora-blue: #60a5fa;
    --aurora-purple: #a78bfa;
    --aurora-pink: #f472b6;

    /* Lava Accents */
    --lava-red: #ef4444;
    --lava-orange: #f97316;
    --ember: #fbbf24;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Button States */
    --btn-idle: #2a2f3d;
    --btn-hover: #363c4d;
    --btn-selected: var(--aurora-teal);
    --btn-selected-text: #0a0b0f;

    /* Feedback */
    --correct: #22c55e;
    --wrong: #ef4444;

    /* Misc */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --glow-teal: rgba(45, 212, 191, 0.4);
    --glow-green: rgba(74, 222, 128, 0.4);

    /* Typography */
    --font-display: 'Instrument Serif', Georgia, serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* ═══════════════════════════════════════════════════════════════
   Reset & Base
   ═══════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════
   Background Effects
   ═══════════════════════════════════════════════════════════════ */

.aurora-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% -20%, rgba(45, 212, 191, 0.15), transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 0%, rgba(167, 139, 250, 0.1), transparent 40%),
        radial-gradient(ellipse 50% 30% at 50% 100%, rgba(239, 68, 68, 0.08), transparent 40%),
        linear-gradient(180deg, var(--bg-deep) 0%, #0d0e14 100%);
    z-index: -2;
    animation: auroraPulse 15s ease-in-out infinite alternate;
}

@keyframes auroraPulse {
    0% { opacity: 1; }
    100% { opacity: 0.7; }
}

.grain-overlay {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
}

/* ═══════════════════════════════════════════════════════════════
   App Container
   ═══════════════════════════════════════════════════════════════ */

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-md);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════
   Header
   ═══════════════════════════════════════════════════════════════ */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.home-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.home-btn:hover {
    background: var(--bg-elevated);
    transform: scale(1.1);
}

.home-btn:hover .logo-icon {
    text-shadow: 0 0 30px var(--glow-teal), 0 0 50px var(--glow-teal);
}

.logo-icon {
    font-size: 1.75rem;
    color: var(--aurora-teal);
    text-shadow: 0 0 20px var(--glow-teal);
    display: block;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--aurora-teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats {
    display: flex;
    gap: var(--space-lg);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
}

/* Floating "+points" that rises off the score when you answer correctly */
.score-pop {
    position: absolute;
    top: -0.4rem;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--aurora-green);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 0 12px var(--glow-green);
}

.score-pop.show {
    animation: scoreFloat 1s ease-out forwards;
}

@keyframes scoreFloat {
    0%   { opacity: 0; transform: translate(-50%, 0) scale(0.8); }
    20%  { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}

/* Score value pulses when it increases */
.stat-value.bump {
    animation: statBump 0.35s ease-out;
}

@keyframes statBump {
    0% { transform: scale(1); }
    45% { transform: scale(1.28); }
    100% { transform: scale(1); }
}

/* Live combo multiplier badge under the streak */
.multiplier-chip {
    margin-top: 2px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 999px;
    color: var(--ember);
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.multiplier-chip.active {
    opacity: 1;
    transform: scale(1);
}

.multiplier-chip.hot {
    color: #fff;
    background: linear-gradient(135deg, var(--lava-orange), var(--lava-red));
    border-color: transparent;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.6);
    animation: chipPulse 0.9s ease-in-out infinite;
}

@keyframes chipPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(249, 115, 22, 0.5); }
    50% { box-shadow: 0 0 20px rgba(249, 115, 22, 0.9); }
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-score .stat-value {
    color: var(--aurora-green);
}

.stat-timer .stat-value {
    color: var(--aurora-blue);
}

.stat-streak .stat-value {
    color: var(--ember);
}

/* ═══════════════════════════════════════════════════════════════
   Main Game Area
   ═══════════════════════════════════════════════════════════════ */

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    flex: 1;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

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

/* ═══════════════════════════════════════════════════════════════
   Start Screen
   ═══════════════════════════════════════════════════════════════ */

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: var(--space-xl);
}

.rune-decoration {
    font-size: 2rem;
    letter-spacing: 0.5em;
    color: var(--aurora-teal);
    opacity: 0.5;
    margin-bottom: var(--space-lg);
    animation: runeGlow 3s ease-in-out infinite alternate;
}

@keyframes runeGlow {
    from { text-shadow: 0 0 10px var(--glow-teal); }
    to { text-shadow: 0 0 30px var(--glow-teal), 0 0 60px var(--glow-teal); }
}

.start-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: var(--space-md);
}

.intro-text {
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
    margin-bottom: var(--space-2xl);
}

.difficulty-select {
    margin-bottom: var(--space-2xl);
    width: 100%;
    max-width: 500px;
}

.difficulty-select h3 {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

@media (min-width: 600px) {
    .difficulty-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

.difficulty-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.difficulty-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--aurora-teal);
    transform: translateY(-2px);
}

.difficulty-btn.selected {
    background: var(--bg-elevated);
    border-color: var(--aurora-teal);
    box-shadow: 0 0 20px var(--glow-teal), inset 0 0 20px rgba(45, 212, 191, 0.1);
}

.diff-icon {
    font-size: 1.5rem;
    color: var(--aurora-teal);
}

.diff-name {
    font-weight: 600;
    font-size: 1rem;
}

.diff-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.start-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: linear-gradient(135deg, var(--aurora-teal), var(--aurora-green));
    border: none;
    border-radius: var(--radius-xl);
    color: var(--bg-deep);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--glow-teal);
}

.start-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 30px var(--glow-teal);
}

.start-btn:active {
    transform: translateY(0) scale(0.98);
}

.start-btn svg {
    width: 20px;
    height: 20px;
}

.secondary-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: var(--bg-card);
    border-color: var(--aurora-teal);
}

.secondary-btn svg {
    width: 18px;
    height: 18px;
}

/* ═══════════════════════════════════════════════════════════════
   Word Class Picker Screen
   ═══════════════════════════════════════════════════════════════ */

.wordclass-picker-screen {
    align-items: center;
    justify-content: center;
}

.picker-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
    padding: var(--space-xl);
    text-align: center;
}

.picker-content h2 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: var(--space-sm);
}

.picker-intro {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.wordclass-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    width: 100%;
    margin-bottom: var(--space-xl);
}

.wordclass-option {
    cursor: pointer;
}

.wordclass-option input {
    display: none;
}

.option-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all 0.2s ease;
}

.wordclass-option input:checked + .option-box {
    border-color: var(--aurora-teal);
    background: rgba(45, 212, 191, 0.1);
    box-shadow: 0 0 20px var(--glow-teal);
}

.wordclass-option:hover .option-box {
    background: var(--bg-elevated);
    border-color: var(--aurora-teal);
}

.option-name {
    font-weight: 600;
    font-size: 1rem;
}

.option-example {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.picker-actions {
    display: flex;
    gap: var(--space-md);
}

/* Hidden button class */
.class-btn.hidden-btn {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════
   Game Screen
   ═══════════════════════════════════════════════════════════════ */

.game-screen {
    gap: var(--space-lg);
}

/* Sentence Card */
.sentence-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
}

.sentence-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--aurora-teal), var(--aurora-purple), var(--aurora-pink));
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.instruction {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.progress {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--aurora-teal);
}

/* Progress bar that fills across a Lota (or drains in timed mode) */
.progress-track {
    height: 6px;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.progress-track.hidden {
    display: none;
}

.progress-track-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--aurora-teal), var(--aurora-green));
    box-shadow: 0 0 12px var(--glow-teal);
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Timed mode: bar drains and turns hot when time runs low */
.progress-track-fill.timed {
    background: linear-gradient(90deg, var(--aurora-green), var(--ember));
    transition: width 1s linear;
}

.progress-track-fill.low {
    background: linear-gradient(90deg, var(--lava-orange), var(--lava-red));
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
}

.sentence {
    font-family: var(--font-display);
    font-size: 1.75rem;
    line-height: 1.5;
    text-align: center;
    padding: var(--space-lg) 0;
}

.sentence .highlight {
    color: var(--ember);
    font-weight: 700;
    position: relative;
    display: inline-block;
}

.sentence .highlight::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ember);
    border-radius: 2px;
    animation: highlightPulse 1.5s ease-in-out infinite;
}

@keyframes highlightPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.attempts-indicator {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    padding-top: var(--space-md);
}

.attempt-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--btn-idle);
    transition: all 0.3s ease;
}

.attempt-dot.used {
    background: var(--lava-red);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* Classification Buttons */
.classification-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.button-group {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    border: 1px solid var(--border-subtle);
    transition: all 0.3s ease;
}

.button-group.hidden {
    display: none;
}

.button-group.reveal {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.group-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    padding-left: var(--space-xs);
}

.button-row {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

.button-row:last-child {
    margin-bottom: 0;
}

.class-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--btn-idle);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.class-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.05));
    opacity: 0;
    transition: opacity 0.15s ease;
}

.class-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
}

.class-btn:hover::before {
    opacity: 1;
}

.class-btn:active {
    transform: translateY(0);
}

.class-btn.selected {
    background: var(--btn-selected);
    color: var(--btn-selected-text);
    border-color: var(--aurora-green);
    box-shadow: 0 0 15px var(--glow-teal);
    font-weight: 600;
}

.class-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Confirm Button */
.confirm-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
}

/* Game-mode selector reuses .difficulty-btn styling but needs a 3-up grid */
.mode-buttons {
    grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 600px) {
    .mode-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* "Finish game" button, in the header next to score and time */
.finish-btn {
    align-self: center;
    min-width: 7.5rem;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.finish-btn.armed,
.finish-btn.armed:hover {
    border-color: var(--ember);
    color: var(--ember);
    background: rgba(251, 191, 36, 0.12);
}

.finish-btn:hover {
    border-color: var(--aurora-teal);
    color: var(--text-primary);
}

.finish-btn.hidden {
    display: none;
}

.confirm-btn {
    padding: var(--space-md) var(--space-2xl);
    background: var(--btn-idle);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: not-allowed;
    transition: all 0.3s ease;
}

.confirm-btn:not(:disabled) {
    background: linear-gradient(135deg, var(--aurora-teal), var(--aurora-green));
    border-color: transparent;
    color: var(--bg-deep);
    cursor: pointer;
    box-shadow: 0 4px 20px var(--glow-teal);
}

.confirm-btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--glow-teal);
}

.confirm-btn:not(:disabled):active {
    transform: translateY(0);
}

/* Feedback */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none; /* brief overlay — never block the buttons underneath */
}

.feedback.hidden {
    display: none;
}

.feedback-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-lg) var(--space-2xl);
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: 1.6rem;
    text-align: center;
    color: white;
    animation: feedbackPop 0.45s cubic-bezier(0.18, 1.5, 0.4, 1);
}

.feedback-icon {
    font-size: 2.75rem;
    line-height: 1;
}

@keyframes feedbackPop {
    0%   { transform: scale(0.4) rotate(-8deg); opacity: 0; }
    55%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Soft glowing halo behind the badge for extra pop */
.feedback-content::before {
    content: '';
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    background: radial-gradient(circle, currentColor 0%, transparent 65%);
    opacity: 0.18;
    z-index: -1;
    animation: feedbackHalo 0.6s ease-out;
}

@keyframes feedbackHalo {
    0% { transform: scale(0.5); opacity: 0; }
    60% { opacity: 0.22; }
    100% { transform: scale(1.1); opacity: 0.12; }
}

.feedback.correct .feedback-content {
    background: linear-gradient(135deg, var(--correct), var(--aurora-teal));
    box-shadow: 0 8px 40px rgba(34, 197, 94, 0.5);
}

.feedback.wrong .feedback-content {
    background: linear-gradient(135deg, var(--wrong), var(--lava-orange));
    box-shadow: 0 8px 40px rgba(239, 68, 68, 0.5);
}

.feedback.show-answer .feedback-content {
    background: linear-gradient(135deg, var(--aurora-blue), var(--aurora-teal));
    box-shadow: 0 8px 40px rgba(96, 165, 250, 0.45);
}

/* ═══════════════════════════════════════════════════════════════
   Results Screen
   ═══════════════════════════════════════════════════════════════ */

.results-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: var(--space-xl);
}

.results-icon {
    font-size: 4rem;
    color: var(--ember);
    margin-bottom: var(--space-lg);
    animation: starSpin 2s ease-in-out infinite;
}

@keyframes starSpin {
    0%, 100% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
}

.results-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin-bottom: var(--space-xl);
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    width: 100%;
    max-width: 350px;
}

.final-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-lg);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
}

.final-stat-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    color: var(--aurora-teal);
}

.final-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Árangursmerki — earned for this game only */
.badges {
    width: 100%;
    max-width: 520px;
    margin: calc(-1 * var(--space-lg)) 0 var(--space-2xl);
}

.badges.hidden { display: none; }

.badges h3 {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
}

.badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(45, 212, 191, 0.08));
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 999px;
    text-align: left;
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    animation: badgeIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards;
}

@keyframes badgeIn {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.badge-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.badge-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ember);
    white-space: nowrap;
}

.badge-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.badge-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
    .badge { animation: none; opacity: 1; transform: none; }
}

/* ═══════════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════════ */

.footer {
    text-align: center;
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.admin-link:hover {
    color: var(--aurora-teal);
}

.attribution {
    font-size: 0.7rem;
    margin-top: var(--space-xs);
}

.attribution a {
    color: var(--text-muted);
    text-decoration: none;
}

.attribution a:hover {
    color: var(--aurora-teal);
}

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
    .header {
        flex-direction: column;
        gap: var(--space-md);
    }

    .stats {
        width: 100%;
        justify-content: space-around;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .start-content h2 {
        font-size: 1.75rem;
    }

    .difficulty-buttons {
        flex-direction: column;
    }

    .sentence {
        font-size: 1.35rem;
    }

    .button-row {
        flex-wrap: wrap;
    }

    .class-btn {
        flex: 1 1 calc(50% - var(--space-sm) / 2);
        min-width: 0;
        font-size: 0.85rem;
        padding: var(--space-sm);
    }

    .final-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .class-btn {
        flex: 1 1 100%;
    }

    .button-row {
        flex-direction: column;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Utility Classes
   ═══════════════════════════════════════════════════════════════ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════════════════════
   Class join (start screen)
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   Score board (results screen)
   ═══════════════════════════════════════════════════════════════ */

.board {
    margin: var(--space-lg) auto;
    max-width: 480px;
    text-align: left;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
}

.board-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
}

.board-header h3 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0;
}

.board-rank {
    color: var(--aurora-teal);
    font-weight: 600;
    white-space: nowrap;
}

.board-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.board-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto auto;
    gap: var(--space-sm);
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.board-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.board-row.me {
    background: rgba(45, 212, 191, 0.12);
    outline: 1px solid rgba(45, 212, 191, 0.4);
}

.board-pos {
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.board-row:nth-child(1) .board-pos { color: var(--ember); }
.board-row:nth-child(2) .board-pos { color: var(--text-secondary); }
.board-row:nth-child(3) .board-pos { color: var(--lava-orange); }

.board-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.board-score {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 3.5rem;
    text-align: right;
}

.board-note {
    margin: var(--space-sm) 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Later flex/grid rules above must not beat the .hidden state */
.join-field.hidden,
.join-game.hidden,
.board-teams.hidden,
#restartBtn.hidden,
#lobbyReturnBtn.hidden,
#resultsSessionNote.hidden,
.lobby-team.hidden,
.board.hidden {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════
   Weekly class goal (start screen) + team standings (results)
   ═══════════════════════════════════════════════════════════════ */

.board-teams {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.board-team {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "rank name" "rank avg" "rank played";
    column-gap: var(--space-sm);
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border-left: 4px solid var(--team);
}

.board-team.me {
    outline: 1px solid var(--team);
}

.board-team-rank {
    grid-area: rank;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--text-muted);
}

.board-team-name {
    grid-area: name;
    font-weight: 600;
    color: var(--team);
}

.board-team-avg {
    grid-area: avg;
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
}

.board-team-played {
    grid-area: played;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   Lobby — joined a live game, waiting for the teacher
   ═══════════════════════════════════════════════════════════════ */

.lobby-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: var(--space-xl);
    gap: var(--space-sm);
}

.lobby-icon {
    font-size: 3rem;
    color: var(--aurora-teal);
    animation: starSpin 3s ease-in-out infinite;
}

.lobby-content h2 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    margin: 0;
}

.lobby-name {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    justify-content: center;
}

.lobby-team {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 2px var(--space-sm);
    border-radius: 999px;
    color: var(--bg-deep);
    background: var(--team, var(--aurora-teal));
}

.lobby-session {
    color: var(--text-secondary);
    margin: 0;
}

.lobby-wait {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--text-secondary);
}

.lobby-wait.live {
    border-color: rgba(251, 191, 36, 0.5);
    color: var(--ember);
}

.lobby-dots {
    display: inline-flex;
    gap: 4px;
}

.lobby-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--aurora-teal);
    animation: lobbyDot 1.2s ease-in-out infinite;
}
.lobby-dots span:nth-child(2) { animation-delay: 0.2s; }
.lobby-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lobbyDot {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.lobby-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.lobby-leave {
    margin-top: var(--space-xl);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-decoration: underline;
}

.lobby-leave:hover { color: var(--text-primary); }

@media (prefers-reduced-motion: reduce) {
    .lobby-icon, .lobby-dots span { animation: none; }
}

/* ═══════════════════════════════════════════════════════════════
   Join a live game — front page entry + dedicated join screen
   ═══════════════════════════════════════════════════════════════ */

.no-stats .stats { display: none; }

.or-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    max-width: 420px;
    margin: var(--space-xl) auto var(--space-md);
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.or-divider::before, .or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.join-entry {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.join-entry:hover {
    background: var(--bg-elevated);
    border-color: rgba(251, 191, 36, 0.5);
    transform: translateY(-1px);
}

.join-entry-icon { font-size: 1.3rem; }

.join-entry-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.join-entry-text strong { color: var(--text-primary); font-weight: 500; font-size: 0.95rem; }
.join-entry-text span { font-size: 0.8rem; color: var(--text-muted); }
.join-entry-arrow { color: var(--text-muted); font-size: 1.1rem; }

.join-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: var(--space-xl) var(--space-md);
}

.join-content h2 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    margin-bottom: var(--space-lg);
}

.join-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 420px;
    padding: var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
}

.join-game {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
}

.join-game.found { border-color: rgba(45, 212, 191, 0.4); }
.join-game.missing { border-color: rgba(239, 68, 68, 0.45); }

.join-game-label {
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.join-game-name {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--text-primary);
    line-height: 1.15;
}

.join-game.found .join-game-name { color: var(--aurora-teal); }
.join-game.missing .join-game-name { color: var(--lava-orange); font-family: var(--font-body); font-size: 1.1rem; font-weight: 600; }

.join-game-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.join-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    text-align: left;
}

.join-field label {
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.join-field input {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1.25rem;
}

.join-field input:focus {
    outline: none;
    border-color: var(--aurora-teal);
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

#joinCodeInput {
    font-family: var(--font-mono);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.join-btn {
    width: 100%;
    justify-content: center;
    margin-top: var(--space-xs);
}

.join-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.join-hint.error { color: var(--lava-orange); }

.join-solo {
    margin-top: var(--space-lg);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    text-decoration: underline;
}

.join-solo:hover { color: var(--text-primary); }

/* Touch devices have no hover: don't leave buttons stuck in the hover state */
@media (hover: none) {
    .difficulty-btn:hover, .class-btn:hover, .start-btn:hover, .join-entry:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Teachers: header links + front page card
   ═══════════════════════════════════════════════════════════════ */

.header-nav { display: none; gap: var(--space-sm); align-items: center; }
.show-nav .header-nav { display: flex; }

.header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: var(--space-xs) var(--space-md);
    border-radius: 999px;
    border: 1px solid transparent;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.header-nav a:hover { color: var(--text-primary); background: var(--bg-card); }

.header-nav a.header-nav-teacher {
    color: var(--text-primary);
    border-color: rgba(45, 212, 191, 0.45);
    background: rgba(45, 212, 191, 0.08);
}

.header-nav a.header-nav-teacher:hover { border-color: var(--aurora-teal); background: rgba(45, 212, 191, 0.15); }

.teacher-entry {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    max-width: 420px;
    margin: var(--space-xl) auto 0;
    padding: var(--space-md);
    border: 1px dashed rgba(45, 212, 191, 0.35);
    border-radius: var(--radius-lg);
    text-align: left;
}

.teacher-entry-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.teacher-entry-text strong { color: var(--text-primary); font-weight: 500; font-size: 0.95rem; }
.teacher-entry-text span { color: var(--text-muted); font-size: 0.8rem; line-height: 1.45; }

.teacher-entry-actions { display: flex; flex-direction: column; align-items: center; gap: var(--space-xs); flex-shrink: 0; }

.teacher-entry-btn {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    background: var(--aurora-teal);
    color: var(--btn-selected-text);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.2s, box-shadow 0.2s;
}

.teacher-entry-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--glow-teal); }

.teacher-entry-link { color: var(--text-secondary); font-size: 0.78rem; }
.teacher-entry-link:hover { color: var(--text-primary); }

@media (max-width: 600px) {
    .header-nav { width: 100%; justify-content: center; }
    .teacher-entry { flex-direction: column; align-items: stretch; text-align: center; }
    .teacher-entry-actions { flex-direction: row; justify-content: center; gap: var(--space-md); }
}
