/* Meta-flow overlays: title, mode select, pause, results */
.meta-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 8, 4, 0.88);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.meta-overlay[hidden] {
    display: none !important;
}

.meta-panel {
    text-align: center;
    max-width: 520px;
    width: 92%;
    padding: 2rem 1.5rem;
}

.meta-panel[hidden] {
    display: none !important;
}

.meta-logo {
    font-size: clamp(2.5rem, 8vw, 4rem);
    letter-spacing: 0.2em;
    color: #ffb347;
    text-shadow: 0 0 20px rgba(255, 179, 71, 0.6);
    margin-bottom: 0.5rem;
}

.meta-tagline {
    opacity: 0.75;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.meta-heading {
    color: #ffb347;
    margin-bottom: 1.25rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 1.1rem;
}

.meta-btn {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 0.5rem auto;
    padding: 0.75rem 1.25rem;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #ffb347;
    background: rgba(255, 179, 71, 0.12);
    border: 2px solid rgba(255, 179, 71, 0.45);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.meta-btn:hover {
    background: rgba(255, 179, 71, 0.25);
    box-shadow: 0 0 16px rgba(255, 179, 71, 0.35);
}

.meta-btn-primary {
    background: rgba(255, 179, 71, 0.28);
    border-color: #ffb347;
}

.meta-btn-ghost {
    opacity: 0.7;
    border-color: transparent;
    background: transparent;
}

.mode-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 480px) {
    .mode-card-grid {
        grid-template-columns: 1fr;
    }
}

.mode-card {
    text-align: left;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    color: #ffb347;
    background: rgba(0, 0, 0, 0.35);
    border: 2px solid rgba(255, 179, 71, 0.35);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}

.mode-card:hover {
    border-color: #ffb347;
    transform: translateY(-2px);
}

.mode-card-title {
    display: block;
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.mode-card-desc {
    display: block;
    font-size: 0.72rem;
    opacity: 0.75;
    line-height: 1.35;
}

.meta-results-body {
    text-align: left;
    margin: 1rem auto 1.25rem;
    max-width: 320px;
    font-size: 0.9rem;
    line-height: 1.6;
    opacity: 0.9;
}

.meta-results-body p {
    margin: 0.35rem 0;
}

.meta-level-banner {
    position: fixed;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    font-family: 'Courier New', monospace;
    font-size: 1.25rem;
    color: #fff;
    background: rgba(255, 140, 50, 0.85);
    border: 2px solid #ffb347;
    border-radius: 4px;
    z-index: 1000001;
    pointer-events: none;
    letter-spacing: 0.08em;
}

.meta-level-banner[hidden] {
    display: none !important;
}

body.meta-active #ui {
    pointer-events: none;
}

body.meta-active:not(.meta-pre-game) canvas {
    filter: brightness(0.55);
}

/* Title + mode select: no 3D/HUD bleed-through */
body.meta-pre-game #gameContainer {
    background: radial-gradient(ellipse 120% 80% at 50% 40%, #1a1410 0%, #0a0804 55%, #050403 100%);
}

body.meta-pre-game #gameCanvas,
body.meta-pre-game #ui {
    visibility: hidden !important;
    pointer-events: none !important;
}

body.meta-pre-game .meta-overlay {
    background: radial-gradient(ellipse 100% 70% at 50% 35%, #1e1812 0%, #0a0804 70%);
    backdrop-filter: none;
}

/* Meta menus: custom cursor follower (title, mode select, pause, results) */
body.meta-ui-cursor,
body.meta-ui-cursor canvas,
body.meta-ui-cursor .meta-overlay,
body.meta-ui-cursor .meta-btn,
body.meta-ui-cursor .mode-card {
    cursor: none !important;
}

#meta-custom-cursor {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    margin-top: -14px;
    pointer-events: none;
    z-index: 1000005;
    border: 2px solid #ffb347;
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(255, 179, 71, 0.75), inset 0 0 8px rgba(255, 179, 71, 0.35);
    background: radial-gradient(circle at 35% 35%, #fff8e8 0%, #ffb347 45%, transparent 70%);
}

#meta-custom-cursor::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 4px;
    margin: -2px 0 0 -2px;
    background: #fff8e8;
    border-radius: 50%;
    box-shadow: 0 0 6px #ffb347;
}

body.meta-ui-cursor #meta-custom-cursor {
    display: block;
}

.meta-mode-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 480px;
    margin: 0.25rem auto 0;
}

.meta-mode-actions .meta-btn {
    flex: 1 1 140px;
    margin: 0;
}

/* Settings opened from mode select — above meta overlay */
#settings-modal.settings-over-meta {
    z-index: 1000002;
}

body.meta-settings-open .meta-overlay {
    pointer-events: none;
}

body.meta-settings-open #settings-modal.settings-over-meta {
    pointer-events: auto;
}

/* Campaign level start strip (non-blocking) */
.campaign-intro-strip {
    position: fixed;
    top: calc(72px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 999985;
    text-align: center;
    padding: 14px 28px;
    pointer-events: none;
    border: 2px solid rgba(255, 179, 71, 0.55);
    background: rgba(12, 8, 2, 0.88);
    box-shadow: 0 0 28px rgba(255, 179, 71, 0.2);
    max-width: min(92vw, 480px);
}

.campaign-intro-strip[hidden] {
    display: none !important;
}

.campaign-intro-strip .campaign-level-num {
    font-size: 1.75rem;
    letter-spacing: 0.2em;
    color: #ffb347;
    margin-bottom: 6px;
}

.campaign-intro-hint {
    font-size: 0.82rem;
    color: #ffe8c8;
    opacity: 0.9;
    margin: 0;
}

.campaign-intro-hint strong {
    color: #ffd27a;
}

/* Campaign level complete (blocking) */
.campaign-panel {
    position: fixed;
    inset: 0;
    z-index: 999990;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 6, 2, 0.72);
    pointer-events: auto;
}

.campaign-panel[hidden] {
    display: none !important;
}

.campaign-panel-inner {
    text-align: center;
    max-width: 420px;
    padding: 2rem 1.5rem;
    border: 2px solid rgba(255, 179, 71, 0.5);
    background: rgba(20, 14, 6, 0.92);
    box-shadow: 0 0 40px rgba(255, 179, 71, 0.15);
}

.campaign-level-num {
    font-size: clamp(2rem, 6vw, 3rem);
    letter-spacing: 0.25em;
    color: #ffb347;
    text-shadow: 0 0 24px rgba(255, 179, 71, 0.5);
    margin-bottom: 1rem;
}

.campaign-panel-hint {
    font-size: 0.95rem;
    line-height: 1.5;
    opacity: 0.88;
    color: #ffe8c8;
}

.campaign-panel-hint strong {
    color: #ffd27a;
}

.campaign-complete-title {
    color: #ffb347;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    font-size: 1.35rem;
}

.campaign-complete-stats {
    text-align: left;
    margin: 0 auto 1.5rem;
    max-width: 260px;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #ffe8c8;
}

.campaign-complete-stats p {
    margin: 0.25rem 0;
}

.campaign-continue-btn {
    cursor: pointer;
    animation: campaign-pulse 1.6s ease-in-out infinite;
}

@keyframes campaign-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 179, 71, 0.3); }
    50% { box-shadow: 0 0 22px rgba(255, 179, 71, 0.55); }
}

#objective-banner .ob-timer {
    color: #7dffb3;
    min-width: 4.5em;
}

#objective-banner .ob-timer.running {
    color: #5cff9a;
    text-shadow: 0 0 8px rgba(92, 255, 154, 0.4);
}

.campaign-timer-sep {
    display: none;
}

#objective-banner.campaign-active .campaign-timer-sep {
    display: inline;
}

.campaign-highscores {
    margin: 1.25rem auto 1rem;
    max-width: 360px;
    text-align: left;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 179, 71, 0.25);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.campaign-highscores .hs-title {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #ffb347;
    opacity: 0.85;
}

.campaign-highscores .hs-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.campaign-highscores .hs-list li {
    display: flex;
    gap: 0.6rem;
    padding: 0.18rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.campaign-highscores .hs-list li:last-child {
    border-bottom: none;
}

.campaign-highscores .hs-rank {
    width: 1.5rem;
    opacity: 0.6;
}

.campaign-highscores .hs-score {
    color: #ffd28a;
    font-weight: 700;
    min-width: 3.5rem;
}

.campaign-highscores .hs-meta {
    margin-left: auto;
    opacity: 0.7;
    font-size: 0.85rem;
}
