/* Lemmings Retro Modern Styling */

:root {
    --bg-main: #0b0f19;
    --bg-panel: #131b2e;
    --bg-card: #1e293b;
    --border-color: #334155;
    --accent-blue: #38bdf8;
    --accent-green: #4ade80;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --accent-purple: #c084fc;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --font-mono: 'Courier New', Courier, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Container */
.game-container {
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.1);
    display: flex;
    flex-direction: column;
    width: 932px;
    max-width: 100%;
    overflow: hidden;
}

/* Top Header */
.top-header {
    background: #0f172a;
    border-bottom: 2px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4ade80 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.level-title {
    font-size: 0.9rem;
    color: var(--accent-orange);
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

select.retro-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

select.retro-select:hover {
    border-color: var(--accent-blue);
}

/* Main Viewport Screen & In-Game Arcade Overlay */
.screen-area {
    position: relative;
    background: #020617;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
    width: 100%;
}

canvas#gameCanvas {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
    image-rendering: pixelated;
    background: #020617;
    touch-action: none; /* The canvas handles pan & tap itself */
}

/* 🌟 IN-GAME TOP HUD (Cyber Glassmorphism Header Overlay) */
.in-game-top-hud {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    z-index: 20;
    pointer-events: auto;
}

.top-hud-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 130px;
}

.hud-cyber-tag {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #38bdf8;
    text-transform: uppercase;
}

.hud-level-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.top-hud-center {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(2, 6, 23, 0.65);
    border: 1px solid rgba(51, 65, 85, 0.7);
    border-radius: 8px;
    padding: 4px 8px;
}

.hud-stat-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.pill-label {
    font-size: 0.6rem;
    font-weight: 800;
    color: #94a3b8;
}

.pill-val {
    font-weight: 800;
    color: #f8fafc;
}

.pill-val.highlight {
    color: #38bdf8;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

.pill-val.success {
    color: #4ade80;
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

.pill-sub {
    color: #38bdf8;
    font-weight: bold;
    font-size: 0.72rem;
}

.top-hud-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rate-control-box {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(2, 6, 23, 0.75);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 6px;
    padding: 2px 6px;
}

.rate-label {
    font-size: 0.58rem;
    font-weight: 800;
    color: #94a3b8;
}

.rate-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 800;
    color: #38bdf8;
    min-width: 18px;
    text-align: center;
}

.mini-hud-btn {
    background: #1e293b;
    border: 1px solid #475569;
    color: #f8fafc;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.mini-hud-btn:hover {
    background: #0284c7;
    border-color: #38bdf8;
}

.hud-action-btn {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(71, 85, 105, 0.8);
    border-radius: 6px;
    color: #f8fafc;
    padding: 4px 7px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}

.hud-action-btn:hover {
    background: #334155;
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.hud-action-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.hud-action-btn.danger {
    border-color: rgba(239, 68, 68, 0.6);
}

.hud-action-btn.danger:hover,
.hud-action-btn.danger.active {
    background: #dc2626;
    border-color: #ef4444;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
}

.btn-hotkey {
    font-size: 0.55rem;
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.45);
    padding: 1px 4px;
    border-radius: 3px;
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 🌟 BOTTOM CONTROLS & SKILLS COCKPIT */
.bottom-controls-bar {
    background: #0f172a;
    border-top: 2px solid var(--border-color);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.skills-dock-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.skill-btn {
    position: relative;
    background: rgba(30, 41, 59, 0.85);
    border: 2px solid rgba(71, 85, 105, 0.7);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 6px 8px;
    min-width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.skill-hotkey-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    background: #0f172a;
    border: 1px solid #38bdf8;
    color: #38bdf8;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 800;
    width: 15px;
    height: 15px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.skill-btn:hover:not(.disabled) {
    transform: translateY(-2px);
    border-color: #38bdf8;
    background: rgba(14, 116, 144, 0.5);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.skill-btn.active {
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    border-color: #38bdf8;
    transform: translateY(-2px);
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.skill-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #1e293b;
}

.skill-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.skill-name {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.skill-count {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: bold;
    color: var(--accent-green);
}

/* Radar Mini-Map Box */
.in-game-radar-box {
    background: #090d16;
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 8px;
    padding: 4px 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 2px;
    cursor: crosshair;
    flex-shrink: 0;
}

.radar-header-label {
    font-size: 0.58rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.radar-ping-dot {
    width: 5px;
    height: 5px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 6px #4ade80;
    animation: radar-blink 1.2s infinite ease-in-out;
}

@keyframes radar-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.7); }
}

canvas#miniMapCanvas {
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 4px;
    background: #090d16;
    image-rendering: pixelated;
    touch-action: none;
    display: block;
}

.replay-banner {
    background: #a855f7;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.68rem;
    animation: pulse-glow 1.5s infinite alternate;
}

.retro-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 6px 10px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.retro-btn:hover {
    background: #334155;
    border-color: var(--accent-blue);
}

.retro-btn.active {
    background: var(--accent-blue);
    color: #0f172a;
}

.retro-btn.danger {
    border-color: #ef4444;
}

.retro-btn.danger:hover,
.retro-btn.danger.active {
    background: #ef4444;
    color: white;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.retro-btn.primary {
    background: #0284c7;
    border-color: #38bdf8;
}

.retro-btn.primary:hover {
    background: #0369a1;
}

.retro-btn.demo-active {
    background: #7c3aed !important;
    border-color: #a855f7 !important;
    color: #ffffff !important;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.6) !important;
    animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
    0% { transform: scale(1); box-shadow: 0 0 10px rgba(168, 85, 247, 0.4); }
    100% { transform: scale(1.04); box-shadow: 0 0 20px rgba(168, 85, 247, 0.9); }
}

/* Modal overlays */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

.modal-content {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-content h2 {
    font-size: 1.5rem;
}

.modal-content p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Instructions footer */
.footer-info {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.footer-info kbd {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: var(--font-mono);
    color: var(--accent-blue);
}

/* ==========================================================================
   🌟 TITLE / START SCREEN OVERLAY
   ========================================================================== */
.title-screen-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.88) 0%, rgba(2, 6, 23, 0.97) 100%);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.title-screen-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.title-card {
    background: rgba(19, 27, 46, 0.92);
    border: 2px solid #38bdf8;
    border-radius: 16px;
    box-shadow: 0 0 50px rgba(56, 189, 248, 0.25), 0 20px 40px rgba(0, 0, 0, 0.8);
    padding: 32px 40px;
    text-align: center;
    max-width: 580px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: titleFloat 4s ease-in-out infinite alternate;
}

@keyframes titleFloat {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-6px); }
}

.title-badge {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid #38bdf8;
    color: #38bdf8;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    padding: 4px 14px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.title-main {
    font-size: 3.2rem;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #4ade80 0%, #38bdf8 50%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.4));
    line-height: 1.1;
    margin-bottom: 4px;
}

.title-subtitle {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fb923c;
    letter-spacing: 3px;
    margin-bottom: 20px;
}

.title-hero-preview {
    background: rgba(15, 23, 42, 0.6);
    border: 1px dashed rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 12px 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.hero-character-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-icon {
    font-size: 1.8rem;
    animation: iconBounce 1s infinite alternate;
}

@keyframes iconBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

.hero-caption {
    font-size: 0.85rem;
    color: #cbd5e1;
    font-weight: 500;
}

.title-menu-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.title-btn-start {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: 2px solid #86efac;
    border-radius: 12px;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 14px 32px;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(34, 197, 94, 0.5), 0 8px 16px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    animation: startPulse 2s infinite;
}

@keyframes startPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(34, 197, 94, 0.4); }
    50% { transform: scale(1.04); box-shadow: 0 0 35px rgba(34, 197, 94, 0.8); }
}

.title-btn-start:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    border-color: #ffffff;
    transform: scale(1.06) !important;
}

.title-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.title-btn-secondary {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #475569;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.title-btn-secondary:hover {
    background: #334155;
    border-color: #38bdf8;
    color: white;
}

.title-footer-badge {
    margin-top: 20px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.swissborg-badge {
    color: #01c38d;
    background: rgba(1, 195, 141, 0.1);
    border: 1px solid rgba(1, 195, 141, 0.3);
    padding: 4px 12px;
    border-radius: 12px;
}

/* ==========================================================================
   🗺️ LEVEL SELECT & GUIDE MODALS
   ========================================================================== */
.modal-content.wide {
    max-width: 680px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.level-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.level-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.level-card:hover {
    border-color: #38bdf8;
    background: #334155;
    transform: translateY(-2px);
}

.level-card-title {
    font-weight: 700;
    color: #38bdf8;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.level-card-desc {
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.3;
}

.level-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #fb923c;
    margin-top: 8px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin: 20px 0;
    text-align: left;
}

.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
}

.guide-header {
    font-weight: 700;
    color: #4ade80;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.guide-card p {
    font-size: 0.75rem;
    color: #cbd5e1;
    line-height: 1.3;
}

/* ==========================================================================
   🎬 RECORDING & REPLAY
   ========================================================================== */

/* Targeted hiding: a global `.hidden` would break the title screen fade, which
   relies on opacity/visibility rather than display. */
.replay-banner.hidden,
#btn-modal-save-replay.hidden {
    display: none;
}

.replay-banner {
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid var(--accent-purple);
    color: var(--accent-purple);
    border-radius: 12px;
    padding: 2px 10px;
    font-weight: bold;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    animation: replayPulse 1.6s infinite alternate;
}

@keyframes replayPulse {
    0% { box-shadow: 0 0 4px rgba(168, 85, 247, 0.3); }
    100% { box-shadow: 0 0 14px rgba(168, 85, 247, 0.8); }
}

.modal-btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   📱 RESPONSIVE & MOBILE PORTRAIT OPTIMIZATION
   ========================================================================== */

/* Footer instructions: mouse version by default, touch version on touch screens */
.footer-info .touch-controls {
    display: none;
}

@media (pointer: coarse) {
    .footer-info .desktop-controls { display: none; }
    .footer-info .touch-controls { display: block; }

    /* Touch targets sized for fingers */
    .retro-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-height: 40px;
    }

    .mini-hud-btn {
        width: 28px;
        height: 28px;
        font-size: 0.95rem;
    }

    .skill-btn {
        min-height: 48px;
    }

    /* Cancel the hover transform on touch */
    .skill-btn:hover:not(.disabled) {
        transform: none;
    }
}

/* 🌟 DEDICATED MOBILE & PORTRAIT MODE (Smart Vertical Arcade Cockpit) */
@media (max-width: 820px), (orientation: portrait) {
    body {
        padding: 0;
        margin: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        justify-content: stretch;
        align-items: stretch;
    }

    .game-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100%;
        border: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: #020617;
    }

    /* Compact Mobile Header */
    .top-header {
        padding: 4px 8px;
        gap: 6px;
        flex-shrink: 0;
        background: #090d16;
        border-bottom: 1px solid rgba(56, 189, 248, 0.25);
        display: flex;
        align-items: center;
        justify-content: space-between;
        overflow-x: auto;
        white-space: nowrap;
    }

    .logo-section {
        gap: 6px;
        flex-shrink: 0;
    }

    .game-title {
        font-size: 0.9rem;
        letter-spacing: 0.5px;
    }

    .level-title {
        display: none; /* Already shown in the top HUD */
    }

    .header-controls {
        gap: 4px;
        flex-shrink: 0;
    }

    .header-controls select.retro-select {
        padding: 4px 6px;
        font-size: 0.72rem;
        max-width: 110px;
    }

    .header-controls .retro-btn {
        padding: 4px 6px;
        font-size: 0.72rem;
        min-height: 28px;
    }

    /* Hide the secondary buttons on small screens */
    #btn-guide-header,
    .top-header label[title*="replay"] {
        display: none;
    }

    /* Screen Play Area (Flexible & Enlarged) */
    .screen-area {
        flex: 1;
        min-height: 0;
        position: relative;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        background: #020617;
        border-radius: 0;
    }

    canvas#gameCanvas {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        display: block;
    }

    /* Floating Mobile Top HUD */
    .in-game-top-hud {
        top: 6px;
        left: 6px;
        right: 6px;
        padding: 4px 8px;
        gap: 4px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        background: rgba(15, 23, 42, 0.88);
        border: 1px solid rgba(56, 189, 248, 0.35);
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
        z-index: 20;
    }

    .top-hud-left {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        min-width: auto;
    }

    .hud-cyber-tag {
        font-size: 0.52rem;
    }

    .hud-level-title {
        font-size: 0.75rem;
    }

    .top-hud-center {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 2px;
        padding: 2px 6px;
        background: rgba(2, 6, 23, 0.5);
    }

    .hud-stat-pill {
        font-size: 0.68rem;
        gap: 2px;
    }

    .pill-label {
        font-size: 0.55rem;
    }

    .top-hud-right {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 4px;
        width: 100%;
    }

    .rate-control-box {
        padding: 1px 4px;
        gap: 2px;
    }

    .rate-label {
        font-size: 0.52rem;
    }

    .rate-value {
        font-size: 0.72rem;
        min-width: 16px;
    }

    .hud-action-btn {
        padding: 3px 6px;
        font-size: 0.68rem;
        flex: 1;
        justify-content: center;
    }

    .btn-hotkey {
        display: none; /* No keyboard shortcuts shown on mobile */
    }

    /* 🎮 Bottom Skills Cockpit (Thumb Zone) */
    .bottom-controls-bar {
        flex-shrink: 0;
        width: 100%;
        padding: 6px 8px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: #090d16;
        border-top: 1px solid rgba(56, 189, 248, 0.35);
        display: flex;
        flex-direction: column;
        gap: 6px;
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.6);
        z-index: 10;
    }

    .skills-dock-container {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }

    .skill-btn {
        min-width: 0;
        height: 50px;
        padding: 4px 2px;
        border-radius: 8px;
        background: rgba(30, 41, 59, 0.85);
        border: 1.5px solid rgba(71, 85, 105, 0.8);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1px;
    }

    .skill-hotkey-badge {
        display: none; /* Hidden on mobile */
    }

    .skill-icon {
        font-size: 1.25rem;
        line-height: 1;
    }

    .skill-name {
        font-size: 0.58rem;
        font-weight: 800;
    }

    .skill-count {
        font-size: 0.72rem;
        font-weight: 800;
    }

    .skill-btn.active {
        background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
        border-color: #38bdf8;
        box-shadow: 0 0 14px rgba(56, 189, 248, 0.8);
        transform: scale(1.03);
    }

    .in-game-radar-box {
        display: none; /* The radar is hidden on mobile to leave all the room to the touch controls */
    }

    .footer-info {
        display: none; /* Hidden on small mobile screens */
    }

    /* Full-screen modals & title screen on mobile */
    .modal-overlay,
    .title-screen-overlay {
        position: fixed;
        z-index: 200;
    }

    .title-card {
        max-height: 92vh;
        max-height: 92dvh;
        width: 94%;
        padding: 20px 14px;
        overflow-y: auto;
    }

    .title-main {
        font-size: 2.2rem;
        letter-spacing: 2px;
    }

    .title-subtitle {
        font-size: 0.7rem;
        letter-spacing: 1.5px;
    }

    .title-hero-preview {
        padding: 8px 14px;
        margin-bottom: 16px;
    }

    .title-btn-start {
        font-size: 1rem;
        padding: 12px 24px;
        width: 100%;
        justify-content: center;
    }

    .title-btn-row {
        flex-direction: column;
        width: 100%;
    }

    .title-btn-secondary {
        width: 100%;
        padding: 10px;
    }

    .modal-content {
        max-height: 88vh;
        max-height: 88dvh;
        width: 94%;
        padding: 16px 12px;
        overflow-y: auto;
    }
}




/* ==========================================================================
   🌐 Online services: account, sign-in, nickname, leaderboard
   ========================================================================== */

/* Offline mode (file:// or missing API): hides the whole online UI */
.online-off #btn-leaderboard,
.online-off .auth-area {
    display: none;
}

.auth-area {
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 2px 4px 2px 10px;
}

.user-chip.hidden {
    display: none;
}

#user-pseudo-label {
    color: #4ade80;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

#user-pseudo-label:hover {
    text-decoration: underline;
}

#btn-admin-link {
    text-decoration: none;
}

/* --- Sign-in modal: provider buttons --- */

.provider-btn-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 22px auto;
    max-width: 320px;
}

.provider-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

.provider-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

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

.provider-icon {
    font-size: 1.15rem;
    font-weight: 900;
}

.provider-google {
    background: #ffffff;
    color: #1f2937;
    border-color: #d1d5db;
}

.provider-google .provider-icon {
    color: #4285f4;
}

/* --- Nickname modal --- */

.pseudo-input {
    width: 100%;
    max-width: 320px;
    margin: 14px auto 6px;
    display: block;
    padding: 12px 14px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #38bdf8;
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    letter-spacing: 0.04em;
}

.pseudo-input:focus {
    outline: none;
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

.pseudo-feedback {
    min-height: 1.2em;
    font-size: 0.85rem;
    color: #94a3b8;
}

.pseudo-feedback.ok {
    color: #4ade80;
}

.pseudo-feedback.warn {
    color: #f87171;
}

/* --- Score submission status (end-of-level modal) --- */

.score-submit-status {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #334155;
}

.score-submit-status.ok {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.5);
}

.score-submit-status.warn {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.5);
}

.score-submit-status.info {
    color: #38bdf8;
}

.score-submit-status.hidden {
    display: none;
}

/* --- Leaderboard --- */

.lb-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
}

.lb-table-wrap {
    max-height: 46vh;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #1e293b;
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.6);
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.lb-table th {
    position: sticky;
    top: 0;
    background: #0f172a;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    padding: 9px 12px;
    text-align: left;
}

.lb-table td {
    padding: 8px 12px;
    border-top: 1px solid #1e293b;
    text-align: left;
    white-space: nowrap;
}

.lb-rank {
    font-weight: 800;
    width: 46px;
}

.lb-pseudo {
    color: #e2e8f0;
    font-weight: 700;
}

.lb-score {
    color: #4ade80;
    font-weight: 800;
}

.lb-dim {
    color: #64748b;
}

.lb-me-row td {
    background: rgba(74, 222, 128, 0.09);
}

.lb-me {
    color: #38bdf8;
    font-size: 0.85rem;
    min-height: 1.2em;
}

.lb-loading {
    padding: 26px;
    color: #94a3b8;
    text-align: center;
}

@media (max-width: 760px) {
    .user-chip {
        padding: 2px 4px 2px 6px;
    }

    #user-pseudo-label {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ==========================================================================
   🔒 Authentication gate (sign-in required to play)
   ========================================================================== */

.auth-gate {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 50% 25%, rgba(15, 23, 42, 0.97), rgba(2, 6, 23, 0.99));
    backdrop-filter: blur(6px);
}

.auth-gate.hidden {
    display: none;
}

/* Prevents the page from scrolling while the gate is up */
body.gated {
    overflow: hidden;
}

/* The game modals are absolutely positioned (z-index 100) INSIDE the play
   area: without this, picking a nickname or viewing the leaderboard from the
   gate would render underneath it, and so be invisible. */
body.gated #pseudo-modal,
body.gated #leaderboard-modal {
    position: fixed;
    z-index: 9500;
}

.auth-gate-card {
    background: var(--bg-card, #0f172a);
    border: 2px solid var(--border-color, #1e293b);
    border-radius: 16px;
    padding: 32px 28px;
    text-align: center;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}

.auth-gate-lead {
    color: #cbd5e1;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 18px 0 4px;
}

.auth-gate-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px auto;
    max-width: 320px;
}

.auth-gate-actions .provider-btn.hidden,
.auth-gate-actions .title-btn-start.hidden {
    display: none;
}

.auth-gate-note {
    color: #f87171;
    font-size: 0.82rem;
    min-height: 1.1em;
    margin: 10px 0 0;
}

#btn-gate-leaderboard {
    margin-top: 6px;
}

@media (max-width: 600px) {
    .auth-gate-card {
        padding: 22px 16px;
    }
}

/* Development sign-in button: deliberately plain and distinct from the
   production buttons, so it can never be mistaken for a real provider. Only
   appears locally (see api/dev_login.php). */
.gate-dev-btn {
    background: transparent;
    color: #94a3b8;
    border: 1px dashed #475569;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 0.85rem;
    cursor: pointer;
}

.gate-dev-btn:hover {
    color: #cbd5e1;
    border-color: #64748b;
}

.gate-dev-btn.hidden {
    display: none;
}
