/* =========================================
   KOURSIER - Joyful & Accessible Theme
   ========================================= */

:root {
    /* Joyful palette */
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8eef4;
    --blue-primary: #3b82f6;
    --blue-light: #60a5fa;
    --blue-dark: #2563eb;
    --orange-primary: #f97316;
    --orange-light: #fb923c;
    --orange-dark: #ea580c;
    --green-primary: #22c55e;
    --green-light: #4ade80;
    --green-dark: #16a34a;
    --red-primary: #ef4444;
    --red-light: #f87171;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(249, 115, 22, 0.2);

    /* Accessible font sizes */
    --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Dark mode */
html.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --blue-primary: #60a5fa;
    --blue-light: #93c5fd;
    --blue-dark: #3b82f6;
    --orange-primary: #fb923c;
    --orange-light: #fdba74;
    --orange-dark: #f97316;
    --green-primary: #4ade80;
    --green-light: #86efac;
    --green-dark: #22c55e;
    --red-primary: #f87171;
    --red-light: #fca5a5;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-light: #64748b;
    --border-color: #334155;
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(249, 115, 22, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
}

/* SCREENS */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* =========================================
   MENU SCREEN
   ========================================= */
#menu-screen {
    background: linear-gradient(135deg, #f0f4f8 0%, #dbeafe 50%, #fef3c7 100%);
}

.menu-container {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1.5rem;
    padding-top: calc(2rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    text-align: center;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.logo h1 span {
    color: var(--orange-primary);
}

.logo .tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    font-weight: 500;
}

/* Language selector */
.lang-selector {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin-bottom: 0.25rem;
}

.lang-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s ease;
}

.lang-btn.active {
    background: var(--orange-primary);
    border-color: var(--orange-primary);
    color: #fff;
}

.lang-btn:hover:not(.active) {
    background: var(--bg-secondary);
    border-color: var(--text-light);
    color: var(--text-secondary);
}

.menu-section h2 {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.75rem;
}

/* Mode selector */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.mode-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    box-shadow: var(--shadow-soft);
    min-height: 48px;
    touch-action: manipulation;
}

.mode-btn .mode-icon {
    font-size: 1.5rem;
}

.mode-btn .mode-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.mode-btn.active {
    border-color: var(--blue-primary);
    background: #eff6ff;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.mode-btn.active .mode-name {
    color: var(--blue-primary);
}

/* Distance selector */
.distance-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.dist-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    box-shadow: var(--shadow-soft);
    min-width: 52px;
    text-align: center;
}

.dist-btn.active {
    border-color: var(--orange-primary);
    background: #fff7ed;
    color: var(--orange-primary);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.12);
}

.dist-btn:hover:not(.active) {
    border-color: var(--text-light);
    background: var(--bg-tertiary);
}

.custom-dist {
    flex: 1;
    min-width: 100px;
}

.custom-dist input {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: var(--shadow-soft);
    outline: none;
    transition: border-color 0.2s ease;
    -moz-appearance: textfield;
    -webkit-user-select: text;
    user-select: text;
}

@keyframes toastIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.custom-dist input::-webkit-outer-spin-button,
.custom-dist input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-dist input:focus {
    border-color: var(--orange-primary);
}

.custom-dist input::placeholder {
    color: var(--text-light);
}

/* BUTTONS */
.primary-btn {
    background: linear-gradient(135deg, var(--orange-primary), var(--orange-dark));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}

.primary-btn .btn-sub {
    font-size: 0.7rem;
    font-weight: 500;
    opacity: 0.8;
    letter-spacing: 0;
}

.primary-btn:hover {
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.45);
    transform: translateY(-2px);
}

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

.secondary-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* STATS PREVIEW */
.stats-preview {
    display: flex;
    justify-content: space-around;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--orange-primary);
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-light);
    text-transform: uppercase;
}

/* =========================================
   GAME SCREEN
   ========================================= */
#game-screen {
    padding: 0;
    background: var(--bg-primary);
}

#map {
    position: absolute;
    inset: 0;
    z-index: auto;
    touch-action: none;
}

/* Escape zone overlay - always visible above fog */
#escape-overlay {
    position: fixed;
    z-index: 500;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.3s ease, top 0.3s ease;
}

#escape-overlay.hidden {
    display: none;
}

#escape-overlay .escape-marker {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(34, 197, 94, 0.2);
    border: 3px solid #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4), 0 0 40px rgba(34, 197, 94, 0.2);
    animation: escapePulse 1.5s ease-in-out infinite;
}

#escape-overlay .escape-marker-inner {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.6));
}

#escape-overlay .escape-label {
    font-family: system-ui, sans-serif;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #fff;
    background: #22c55e;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
    margin-top: 4px;
}

@keyframes escapePulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.4), 0 0 40px rgba(34, 197, 94, 0.2);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(34, 197, 94, 0.6), 0 0 60px rgba(34, 197, 94, 0.3);
        transform: scale(1.05);
    }
}

/* Leaflet theme overrides */
.leaflet-control-zoom {
    display: none !important;
}

.leaflet-control-attribution {
    background: rgba(255,255,255,0.85) !important;
    color: var(--text-light) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: var(--blue-primary) !important;
}

/* HUD */
#hud {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

#hud-top {
    display: flex;
    justify-content: space-around;
    padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 0.75rem 0.75rem;
    background: linear-gradient(to bottom, rgba(255,255,255,0.95), rgba(255,255,255,0.7), transparent);
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

.hud-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-light);
    text-transform: uppercase;
}

.hud-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--blue-dark);
}

/* Shadow Warning */
#shadow-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(239, 68, 68, 0.1);
    backdrop-filter: blur(8px);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    border: 2px solid var(--red-primary);
    animation: pulse 1s ease-in-out infinite;
}

#shadow-warning.hidden {
    display: none;
}

.warning-text {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: var(--red-primary);
}

.warning-bar {
    width: 160px;
    height: 4px;
    background: rgba(239, 68, 68, 0.2);
    margin: 0.4rem auto 0;
    border-radius: 2px;
    overflow: hidden;
}

.warning-fill {
    height: 100%;
    width: 10%;
    background: var(--red-primary);
    border-radius: 2px;
    transition: width 0.3s ease;
}
/* Leaflet theme overrides */
.player-marker {
    animation: playerPulse 2s ease-in-out infinite;
}

@keyframes playerPulse {
    0%, 100% { filter: drop-shadow(0 0 4px #3b82f6); }
    50% { filter: drop-shadow(0 0 12px #3b82f6); }
}

/* HUD Bottom */
#hud-bottom {
    position: absolute;
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    box-shadow: var(--shadow-medium);
    backdrop-filter: blur(10px);
}

.direction-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 60px;
}

.arrow-svg {
    width: 36px;
    height: 36px;
    transition: transform 0.5s ease;
    filter: drop-shadow(0 2px 4px rgba(249, 115, 22, 0.3));
}

.arrow-label {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--orange-primary);
}

.progress-ring {
    position: relative;
    width: 56px;
    height: 56px;
}

.progress-ring svg {
    transform: rotate(-90deg);
    width: 56px;
    height: 56px;
}

.progress-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 5;
}

.progress-fill {
    fill: none;
    stroke: var(--orange-primary);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    stroke-dashoffset: 251.2;
    transition: stroke-dashoffset 0.5s ease;
    filter: drop-shadow(0 0 3px rgba(249, 115, 22, 0.3));
}

.progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-primary);
}

.distance-left {
    display: flex;
    flex-direction: column;
}

#distance-left-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.sub-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-light);
    text-transform: uppercase;
}

/* =========================================
   GAME OVER SCREEN
   ========================================= */
#gameover-screen {
    background: linear-gradient(135deg, #f0f4f8 0%, #dbeafe 50%, #fef3c7 100%);
}

.gameover-container {
    width: 100%;
    max-width: 480px;
    padding: 2rem 1.5rem;
    padding-top: calc(2rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    text-align: center;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.gameover-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 900;
}

.gameover-icon.caught {
    background: #fef2f2;
    border: 3px solid var(--red-primary);
    color: var(--red-primary);
}

.gameover-icon.escaped {
    background: #f0fdf4;
    border: 3px solid var(--green-primary);
    color: var(--green-primary);
}

#gameover-title {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 0.05em;
}

#gameover-title.caught {
    color: var(--red-primary);
}

#gameover-title.escaped {
    color: var(--green-primary);
}

.gameover-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.gameover-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    padding: 1.25rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.go-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.go-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--blue-dark);
}

.go-label {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--text-light);
    text-transform: uppercase;
}

.gameover-actions {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.gameover-actions .primary-btn,
.gameover-actions .secondary-btn {
    flex: 1;
    justify-content: center;
}

/* =========================================
   LOADING
   ========================================= */
#loading {
    position: fixed;
    inset: 0;
    background: rgba(240, 244, 248, 0.95);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

#loading.hidden {
    display: none;
}

.loader {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--orange-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader p {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* =========================================
   ANTI-CHEAT OVERLAY
   ========================================= */
#anticheat-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(240, 244, 248, 0.92);
    backdrop-filter: blur(6px);
}

#anticheat-overlay.hidden {
    display: none;
}

.anticheat-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--orange-primary);
}

.anticheat-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.anticheat-box h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.anticheat-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.anticheat-timer {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--orange-primary);
    margin-bottom: 1rem;
}

#anticheat-resume {
    width: 100%;
    padding: 0.75rem;
}

#anticheat-resume:not(:disabled) {
    background: var(--orange-primary);
    color: #fff;
    border-color: var(--orange-primary);
    cursor: pointer;
}

#anticheat-resume:not(:disabled):hover {
    background: var(--orange-dark);
    border-color: var(--orange-dark);
}

/* Pause button */
.pause-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    touch-action: manipulation;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.pause-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-light);
}

/* Center on player button */
.center-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    touch-action: manipulation;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.center-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-light);
}

.center-btn:active {
    transform: scale(0.9);
}

/* GPS Lost Overlay */
#gps-lost-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

#gps-lost-overlay.hidden {
    display: none;
}

.gps-lost-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--red-primary);
}

.gps-lost-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.gps-lost-box h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.gps-lost-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.gps-lost-timer {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--red-primary);
    margin-bottom: 1rem;
}

/* Pause overlay enhancements */
#pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(240, 244, 248, 0.92);
    backdrop-filter: blur(6px);
}

#pause-overlay.hidden {
    display: none;
}

.pause-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-medium);
    border: 2px solid var(--blue-primary);
}

.pause-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.pause-box h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.pause-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.pause-actions {
    display: flex;
    gap: 0.75rem;
}

.pause-actions button {
    flex: 1;
}

/* =========================================
   GAME TYPE SELECTOR (single / tournee)
   ========================================= */
.game-type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
}

.game-type-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.875rem 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    box-shadow: var(--shadow-soft);
    min-height: 48px;
    touch-action: manipulation;
}

.game-type-btn .type-icon {
    font-size: 1.5rem;
}

.game-type-btn .type-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.game-type-btn.active {
    border-color: var(--green-primary);
    background: #f0fdf4;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.15);
}

.game-type-btn.active .type-name {
    color: var(--green-primary);
}

/* Tour stops selector */
.tour-stops-selector {
    display: flex;
    gap: 0.625rem;
    justify-content: center;
}

.stops-btn {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    box-shadow: var(--shadow-soft);
    min-height: 48px;
    touch-action: manipulation;
}

.stops-btn.active {
    border-color: var(--green-primary);
    background: #f0fdf4;
    color: var(--green-primary);
}

/* Menu nav buttons */
.menu-nav {
    display: flex;
    gap: 0.625rem;
    justify-content: center;
    padding-top: 0.5rem;
}

.nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 40px;
    touch-action: manipulation;
}

.nav-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-light);
    color: var(--text-primary);
}

/* =========================================
   TUTORIAL OVERLAY
   ========================================= */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(240, 244, 248, 0.97);
    backdrop-filter: blur(8px);
}

#tutorial-overlay.hidden {
    display: none;
}

.tutorial-container {
    width: 90%;
    max-width: 400px;
    padding: 2rem 1.5rem;
    text-align: center;
}

.tutorial-pages {
    position: relative;
    min-height: 200px;
    margin-bottom: 1.5rem;
}

.tutorial-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tutorial-page.active {
    opacity: 1;
    visibility: visible;
}

.tutorial-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
}

.tutorial-page h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.tutorial-page p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tutorial-dots {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    transition: background 0.3s ease;
}

.tutorial-dot.active {
    background: var(--green-primary);
}

.tutorial-actions {
    display: flex;
    gap: 0.75rem;
}

.tutorial-actions button {
    flex: 1;
}

/* =========================================
   HISTORY SCREEN
   ========================================= */
#history-screen {
    background: linear-gradient(135deg, #f0f4f8 0%, #dbeafe 50%, #fef3c7 100%);
}

.history-container {
    width: 100%;
    max-width: 480px;
    height: 100dvh;
    padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
    margin-top: 2rem;
}

.history-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item.escaped {
    border-left: 4px solid var(--green-primary);
}

.history-item.caught {
    border-left: 4px solid var(--red-primary);
}

.history-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.history-date {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 600;
}

.history-detail {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
}

.history-mode {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
}

.history-time {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.history-tour-badge {
    font-size: 0.6rem;
    background: #f0fdf4;
    color: var(--green-dark);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
}

/* =========================================
   BADGES SCREEN
   ========================================= */
#badges-screen {
    background: linear-gradient(135deg, #f0f4f8 0%, #dbeafe 50%, #fef3c7 100%);
}

.badges-container {
    width: 100%;
    max-width: 480px;
    height: 100dvh;
    padding: calc(1.5rem + env(safe-area-inset-top, 0px)) 1.5rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.badges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badges-header h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.badges-grid {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    align-content: start;
}

.badge-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    box-shadow: var(--shadow-soft);
    text-align: center;
    transition: all 0.2s ease;
    min-height: 100px;
    justify-content: center;
}

.badge-item.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.badge-item.locked .badge-icon {
    filter: grayscale(1) brightness(0.7);
}

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

.badge-name {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.badge-desc {
    font-size: 0.55rem;
    color: var(--text-light);
    line-height: 1.2;
}

/* =========================================
   BADGE NOTIFICATION
   ========================================= */
#badge-notification {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    z-index: 300;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid var(--green-primary);
    border-radius: 16px;
    padding: 0.75rem 1.25rem;
    box-shadow: 0 8px 32px rgba(34, 197, 94, 0.3);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#badge-notification.show {
    transform: translateX(-50%) translateY(0);
}

#badge-notification.hidden {
    display: none;
}

.badge-notif-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.badge-notif-icon {
    font-size: 2rem;
}

.badge-notif-text {
    display: flex;
    flex-direction: column;
}

.badge-notif-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--green-dark);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.badge-notif-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* =========================================
   TOUR INDICATOR (HUD)
   ========================================= */
#tour-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    min-width: 50px;
}

#tour-indicator.hidden {
    display: none;
}

.tour-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-light);
    text-transform: uppercase;
}

.tour-count {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--green-dark);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-height: 600px) {
    .menu-container {
        gap: 1rem;
        padding: 1rem;
    }

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

    .stats-preview {
        padding-top: 0.75rem;
    }

    .tutorial-container {
        padding: 1rem;
    }

    .tutorial-icon {
        font-size: 3rem;
    }
}

@media (min-width: 768px) {
    .menu-container {
        max-width: 480px;
    }

    .gameover-container {
        max-width: 480px;
    }

    .history-container {
        max-width: 480px;
    }

    .badges-container {
        max-width: 480px;
    }

    .badges-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    #hud-bottom {
        bottom: 2rem;
    }
}
