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

body {
    background: #0a0a0f;
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(20, 40, 20, 0.6) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(10, 20, 30, 0.5) 0%, transparent 60%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    /* 1000x1000 logical surface (backing store is 1000*devicePixelRatio for hi-DPI
       crispness; JS sets the inline 1000px display size). Cap to the window's
       smaller side so it always fits, square and crisp. */
    max-width: 100vmin;
    max-height: 100vmin;
    border: 2px solid #2a3a2a;
    /* Layered box-shadow: inner glow + outer dramatic depth shadow */
    box-shadow:
        0 0 0 1px #111,
        0 0 30px 8px rgba(0, 0, 0, 0.9),
        0 8px 40px 10px rgba(0, 0, 0, 0.8),
        0 20px 80px 20px rgba(0, 0, 0, 0.6),
        inset 0 0 60px 20px rgba(0, 0, 0, 0.3);
    /* Subtle perspective tilt for a slight 3D feel */
    transform: perspective(1200px) rotateX(1.5deg);
    transform-origin: center center;
}

/* ── Mobile / touch devices ───────────────────────────────────────────────
   Scoped to `html.touch`, which main.js adds on coarse-pointer (touch) devices.
   Using a JS-set class (not a bare @media query) keeps ONE source of truth, so
   the JS layout math and the CSS never disagree. Fill the whole screen (canvas
   backing + logical viewport are sized by JS to the device aspect ratio, so no
   letterbox), drop the desktop chrome (tilt/border/100vmin cap), and kill page
   scroll/zoom/overscroll so the game owns every gesture. */
html.touch, html.touch body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    background: #000;
}
html.touch body { display: block; }
html.touch #game {
    position: absolute;
    inset: 0;
    touch-action: none;
    /* JS sets exact pixel width/height to innerWidth × innerHeight */
    max-width: none;
    max-height: none;
    border: none;
    box-shadow: none;
    transform: none;
}

/* Full-screen overlay; container ignores touches, children capture them. */
    .touch-controls {
        position: fixed;
        inset: 0;
        z-index: 10;
        pointer-events: none;
        user-select: none;
        -webkit-user-select: none;
        touch-action: none;
        font-size: 0; /* emoji sizing controlled per-button */
    }
    .touch-controls > * { pointer-events: none; }
    .tc-joy, .tc-btn { pointer-events: auto; }

    /* Analog joystick, bottom-left (respect notch/home-indicator insets). */
    .tc-left {
        position: absolute;
        left: calc(env(safe-area-inset-left) + 4vmin);
        bottom: calc(env(safe-area-inset-bottom) + 5vmin);
    }
    .tc-joy {
        position: relative;
        width: 34vmin;
        height: 34vmin;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.08);
        border: 0.6vmin solid rgba(255, 255, 255, 0.22);
        touch-action: none;
    }
    .tc-knob {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 15vmin;
        height: 15vmin;
        margin: -7.5vmin 0 0 -7.5vmin;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.38);
        pointer-events: none;
    }

    /* Action cluster, bottom-right. */
    .tc-right {
        position: absolute;
        right: calc(env(safe-area-inset-right) + 4vmin);
        bottom: calc(env(safe-area-inset-bottom) + 5vmin);
        display: flex;
        align-items: flex-end;
        gap: 3vmin;
    }
    .tc-weapons {
        position: absolute;
        right: calc(env(safe-area-inset-right) + 4vmin);
        bottom: calc(env(safe-area-inset-bottom) + 30vmin);
        display: flex;
        gap: 2vmin;
    }
    .tc-top {
        position: absolute;
        right: calc(env(safe-area-inset-right) + 3vmin);
        top: calc(env(safe-area-inset-top) + 3vmin);
        display: flex;
        gap: 2vmin;
    }

    .tc-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.10);
        border: 0.5vmin solid rgba(255, 255, 255, 0.22);
        color: #fff;
        touch-action: none;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.05s, filter 0.05s;
    }
    .tc-attack   { width: 22vmin; height: 22vmin; font-size: 9.5vmin; background: rgba(200, 50, 50, 0.30); border-color: rgba(255, 120, 120, 0.4); }
    .tc-interact { width: 15vmin; height: 15vmin; font-size: 7vmin;  background: rgba(80, 160, 220, 0.28); }
    .tc-dash     { width: 15vmin; height: 15vmin; font-size: 7vmin;  background: rgba(120, 200, 120, 0.26); }
    .tc-wpn      { width: 12vmin; height: 12vmin; font-size: 6vmin; }
    .tc-sys      { width: 11vmin; height: 11vmin; font-size: 5vmin; background: rgba(0, 0, 0, 0.35); }

    .tc-active { transform: scale(0.90); filter: brightness(1.5); }
    .tc-locked { opacity: 0.28; }
    .tc-sel    { box-shadow: 0 0 0 0.7vmin rgba(255, 220, 80, 0.95); }

/* ── Title / victory menu overlay (Start / Play-Again button + support links) ─
   Real DOM controls, not canvas taps: an explicit Start BUTTON (no whole-screen
   "tap to start", which swallowed Ko-fi taps) and real <a> support links (mobile
   Safari blocks window.open from non-click gestures). main.js positions this over
   the lower canvas and toggles visibility by game state. */
.menu-overlay {
    position: fixed;
    z-index: 9;                       /* above canvas, below touch-controls (10) */
    transform: translate(-50%, -50%); /* centered on the (left,top) main.js sets */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    pointer-events: none;             /* container ignores taps; controls re-enable */
    text-align: center;
}
.menu-btn {
    pointer-events: auto;
    white-space: nowrap;              /* keep "Tap to Start" on one line */
    font: bold 20px monospace;
    color: #fff;
    background: rgba(180, 30, 30, 0.94);
    border: 2px solid #f66;
    border-radius: 10px;
    padding: 11px 26px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
    animation: menu-pulse 1.1s ease-in-out infinite;
}
.menu-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55); }
@keyframes menu-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.3); } }

.support-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}
.support-bar .support-label {
    color: #9d9;
    font: bold 16px monospace;
    text-shadow: 0 2px 0 #000;
}
.support-bar .support-row { display: flex; gap: 16px; }
.support-link {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font: bold 16px monospace;
    text-decoration: none;
    background: rgba(21, 42, 21, 0.92);
    color: #cfc;
    border: 2px solid #5c5;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}
.support-link.paypal {
    background: rgba(21, 21, 42, 0.92);
    color: #cdf;
    border-color: #58f;
}
