/* Invadatorii — the fixed shooter (js/invadatorii.js). Theme-aware like the other game pages: tokens
   on :root, redefined under body.dark-theme. The playfield itself is night sky in both themes. */
:root {
    --iv-accent: #0e7490;
    --iv-accent-2: #0891b2;
    --iv-on-accent: #ffffff;
    --iv-gold: #f59e0b;
    --iv-page-bg: #f0f5f8;
    --iv-card-bg: #ffffff;
    --iv-card-border: #d3e1e8;
    --iv-muted: #556570;
    --iv-shadow: 0 10px 30px rgba(10, 40, 70, .14);
    --iv-overlay: rgba(5, 20, 35, .55);
    --iv-stage-bg: #070b1d;
    --iv-hud-bg: linear-gradient(180deg, #050816, #0c1430);
}

body.dark-theme {
    --iv-accent: #67e8f9;
    --iv-accent-2: #a5f3fc;
    --iv-on-accent: #04202a;
    --iv-page-bg: #0a0f17;
    --iv-card-bg: #121b27;
    --iv-card-border: #24364a;
    --iv-muted: #9fb3c3;
    --iv-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --iv-overlay: rgba(0, 0, 0, .65);
    --iv-stage-bg: #03050f;
    --iv-hud-bg: linear-gradient(180deg, #02040b, #081022);
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` would kill position: sticky. */
.iv-body, body.iv-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--iv-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.iv-main { padding-top: 92px; padding-bottom: 40px; }
.iv-game .container, .iv-hero .container { max-width: 760px; }

/* ---- hero ---- */
.iv-hero { text-align: center; padding: 4px 0 12px; }
.iv-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.iv-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #0e7490, #16a34a); box-shadow: var(--iv-shadow); }
.iv-lead { max-width: 600px; margin: 0 auto; color: var(--iv-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage ---- */
.iv-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 640px;
    margin: 0 auto;
    background: var(--iv-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--iv-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.iv-stage:focus-visible { box-shadow: 0 0 0 3px var(--iv-accent), var(--iv-shadow); }
@media (max-width: 575.98px) {
    .iv-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.iv-stage:fullscreen { width: 100%; height: 100%; max-width: none; border-radius: 0; margin: 0; }
.iv-stage:-webkit-full-screen { width: 100%; height: 100%; max-width: none; border-radius: 0; margin: 0; }
.iv-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; max-width: none; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .iv-stage.is-max { height: 100dvh; } }

.iv-hud { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; background: var(--iv-hud-bg); color: #fff; border-bottom: 2px solid #16314a; }
.iv-stat { display: flex; flex-direction: column; line-height: 1.05; min-width: 52px; }
.iv-stat small { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #93c5d8; white-space: nowrap; }
.iv-stat b { font-size: 1.15rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #fde68a; }
.iv-stat-wave { min-width: 40px; }
.iv-lives { display: flex; gap: 3px; align-items: center; min-width: 20px; flex: 1 1 auto; justify-content: center; }
.iv-life { position: relative; width: 18px; height: 9px; margin-top: 5px; border-radius: 2px 2px 1px 1px; background: #4ade80; }
.iv-life::before { content: ""; position: absolute; left: 50%; top: -5px; width: 4px; height: 6px; margin-left: -2px; border-radius: 1px; background: #4ade80; }
.iv-lives-more { font-weight: 800; font-size: .85rem; color: #e9e5ff; }
.iv-tools { flex: none; display: flex; gap: 5px; }
.iv-round { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .16); display: grid; place-items: center; background: rgba(255, 255, 255, .08); color: #fff; font-size: 15px; cursor: pointer; touch-action: manipulation; padding: 0; }
.iv-round:hover, .iv-round:focus-visible { background: rgba(8, 145, 178, .85); }
.iv-round:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.iv-round span[hidden], .iv-round[hidden] { display: none; }

.iv-view { position: relative; flex: none; width: 100%; aspect-ratio: var(--iv-ar, 1); max-height: calc(100vh - 170px); min-height: 300px; background: #03050f; overflow: hidden; touch-action: none; }
@supports (height: 100svh) { .iv-view { max-height: calc(100svh - 170px); } }
.iv-stage:fullscreen .iv-view, .iv-stage.is-max .iv-view { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.iv-stage:-webkit-full-screen .iv-view { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.iv-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.iv-banner { position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 92%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.25rem, 6vw, 2.1rem); line-height: 1.15; text-shadow: 0 3px 12px rgba(0, 0, 0, .5); background: linear-gradient(135deg, rgba(14, 116, 144, .92), rgba(22, 163, 74, .92)); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.iv-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.iv-banner small { display: block; font-size: .5em; font-weight: 700; opacity: .95; }

.iv-hint { position: absolute; left: 50%; bottom: 18%; z-index: 2; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: rgba(3, 6, 18, .72); border: 1px solid rgba(103, 232, 249, .35); color: #e0f7fb; font-weight: 700; font-size: .9rem; white-space: nowrap; pointer-events: none; animation: iv-hint 1.6s ease-in-out infinite; }
.iv-hint[hidden] { display: none; }
@keyframes iv-hint { 0%, 100% { transform: translateX(-60%); } 50% { transform: translateX(-40%); } }

/* ---- the menu over the playfield (new game / pause) ---- */
.iv-menu { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(3, 6, 18, .66); backdrop-filter: blur(2px); overflow-y: auto; }
.iv-menu[hidden] { display: none; }
.iv-panel { width: min(100%, 380px); padding: 16px; border-radius: 18px; background: var(--iv-card-bg); color: var(--text-color); border: 1px solid var(--iv-card-border); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); display: flex; flex-direction: column; gap: 10px; }
.iv-menu-title { margin: 0; font-size: 1.3rem; font-weight: 900; text-align: center; }
.iv-menu-sub { margin: -4px 0 0; text-align: center; color: var(--iv-muted); font-size: .92rem; }
.iv-menu-sub[hidden] { display: none; }
.iv-field { display: flex; flex-direction: column; gap: 5px; }
.iv-label { font-weight: 800; font-size: .88rem; }
.iv-chips { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; padding: 4px; border-radius: 14px; background: var(--iv-page-bg); border: 1px solid var(--iv-card-border); }
.iv-chip { min-height: 44px; padding: 4px 6px; border: 0; border-radius: 10px; background: transparent; color: inherit; font-weight: 800; font-size: .92rem; cursor: pointer; touch-action: manipulation; }
.iv-chip[aria-checked="true"] { background: var(--iv-accent); color: var(--iv-on-accent); }
.iv-chip:focus-visible { outline: 2px solid var(--iv-gold); outline-offset: 2px; }
.iv-keys { margin: 0; font-size: .78rem; color: var(--iv-muted); text-align: center; line-height: 1.5; }
.iv-keys kbd, .iv-help kbd { background: var(--iv-page-bg); color: inherit; border: 1px solid var(--iv-card-border); padding: 0 5px; border-radius: 5px; font-size: .8em; }

.iv-btn { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid var(--iv-card-border); background: var(--iv-card-bg); color: inherit; font-weight: 800; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; transition: background .15s, border-color .15s, transform .1s; }
.iv-btn:hover { border-color: var(--iv-accent); }
.iv-btn:active { transform: scale(.98); }
.iv-btn[hidden] { display: none; }
.iv-btn-primary { background: var(--iv-accent); border-color: var(--iv-accent); color: var(--iv-on-accent); }
.iv-btn-primary:hover { background: var(--iv-accent-2); border-color: var(--iv-accent-2); }
.iv-wide { width: 100%; }

.iv-status { min-height: 1.5em; margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--iv-muted); font-size: .92rem; }
.iv-record { margin: 4px 0 0; text-align: center; color: var(--iv-muted); font-size: .9rem; }
.iv-record b { color: var(--text-color); }
.iv-reset-wrap { margin: 2px 0 0; text-align: center; }
.iv-reset-wrap[hidden] { display: none; }
.iv-link { border: 0; background: none; color: var(--iv-accent); font-weight: 700; font-size: .85rem; text-decoration: underline; cursor: pointer; padding: 6px; }

/* ---- help ---- */
.iv-help { max-width: 640px; margin: 14px auto 0; padding: 12px 16px; border-radius: 16px; background: var(--iv-card-bg); border: 1px solid var(--iv-card-border); box-shadow: var(--iv-shadow); }
.iv-help summary { font-weight: 800; cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: 8px; }
.iv-help summary svg, .iv-help summary i { color: var(--iv-accent); }
.iv-help ul { margin: 10px 0 6px; padding-left: 20px; line-height: 1.55; font-size: .95rem; }
.iv-help li { margin-bottom: 6px; }
.iv-credit { margin: 6px 0 0; font-size: .82rem; color: var(--iv-muted); }
.iv-powered { margin: 18px 0 0; text-align: center; color: var(--iv-muted); font-size: .9rem; }
.iv-powered a { color: var(--iv-accent); font-weight: 700; }

/* ---- game over ---- */
.iv-overlay { position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--iv-overlay); }
.iv-overlay[hidden] { display: none; }
.iv-dialog { width: min(100%, 400px); padding: 20px 18px 16px; border-radius: 20px; background: var(--iv-card-bg); color: var(--text-color); border: 1px solid var(--iv-card-border); box-shadow: 0 20px 50px rgba(0, 0, 0, .4); text-align: center; }
.iv-dialog-icon { width: 58px; height: 58px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; color: #fff; background: linear-gradient(135deg, #0e7490, #16a34a); }
.iv-dialog h2 { font-size: 1.4rem; font-weight: 900; margin: 0 0 8px; }
.iv-final { list-style: none; margin: 0 0 6px; padding: 0; }
.iv-final li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--iv-page-bg); margin-bottom: 6px; font-weight: 700; }
.iv-final li b { font-variant-numeric: tabular-nums; }
.iv-over-sub { color: var(--iv-muted); margin: 0 0 12px; font-size: .92rem; }
.iv-over-sub strong { color: var(--iv-gold); }
.iv-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.iv-dialog-actions .iv-btn { flex: 1 1 140px; }

@media (max-width: 400px) {
    .iv-hud { gap: 4px; padding-left: 8px; }
    .iv-stat { min-width: 44px; }
    .iv-stat b { font-size: 1rem; }
    .iv-round { width: 36px; height: 36px; font-size: 14px; }
    .iv-life { width: 15px; height: 8px; }
}
