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

:root {
    --neon-cyan:    #00f0ff;
    --neon-magenta: #ff2eb7;
    --neon-yellow:  #ffe600;
    --neon-green:   #39ff14;
    --neon-red:     #ff003c;
    --bg:           #04020a;
    --bg-2:         #0d0820;
    --grid:         rgba(255, 46, 183, 0.06);
}

html, body {
    background: var(--bg);
    color: #cfd;
    font-family: 'VT323', monospace;
    font-size: 18px;
    overflow-x: hidden;
    min-height: 100vh;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Faint perspective grid floor — classic retro vibe */
    background-image:
        radial-gradient(ellipse 80% 60% at 50% 35%, rgba(255, 46, 183, 0.10), transparent 60%),
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px, 32px 32px;
    background-attachment: fixed;
}

/* Subtle CRT scanlines over the whole page */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0 2px,
        rgba(0, 0, 0, 0.20) 2px 3px
    );
    mix-blend-mode: multiply;
    z-index: 9999;
}

/* ─── Screens ────────────────────────────────────────────────────── */
.screen {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1.5rem;
}

/* ─── Neon headings ───────────────────────────────────────────────── */
.neon {
    font-family: 'Press Start 2P', monospace;
    letter-spacing: 0.05em;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
}

.neon-cyan {
    color: var(--neon-cyan);
    text-shadow:
        0 0 4px var(--neon-cyan),
        0 0 10px var(--neon-cyan),
        0 0 22px rgba(0, 240, 255, 0.5);
    animation: neon-flicker 4s infinite;
}

.neon-magenta {
    color: var(--neon-magenta);
    text-shadow:
        0 0 4px var(--neon-magenta),
        0 0 10px var(--neon-magenta),
        0 0 22px rgba(255, 46, 183, 0.5);
}

.neon-yellow {
    color: var(--neon-yellow);
    text-shadow:
        0 0 4px var(--neon-yellow),
        0 0 10px var(--neon-yellow),
        0 0 22px rgba(255, 230, 0, 0.5);
}

@keyframes neon-flicker {
    0%, 92%, 100% { opacity: 1; }
    93%           { opacity: 0.4; }
    94%           { opacity: 1; }
    96%           { opacity: 0.6; }
    97%           { opacity: 1; }
}

.blink { animation: blink 1.1s steps(2, end) infinite; }
@keyframes blink {
    0%, 49%  { opacity: 1; }
    50%, 100% { opacity: 0.25; }
}

/* ─── Landing ─────────────────────────────────────────────────────── */
#landing-cabinet {
    width: min(55vw, 240px);
    max-height: 38vh;
    object-fit: contain;
    opacity: 0.95;
    filter: drop-shadow(0 0 20px rgba(255, 46, 183, 0.4));
    animation: float 4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

#landing-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 360px;
}

#landing-content h1 {
    font-size: clamp(1.6rem, 7vw, 2.6rem);
}

.subtitle {
    color: var(--neon-magenta);
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    text-align: center;
    opacity: 0.85;
    text-shadow: 0 0 4px rgba(255, 46, 183, 0.5);
}

.landing-controls {
    margin-top: 1rem;
    padding: 0.8rem 1rem;
    border: 1px dashed rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.04);
    color: #aac;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    line-height: 1.5;
    text-align: left;
    width: min(95vw, 460px);
}

.landing-controls .lc-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    color: var(--neon-magenta);
    text-shadow: 0 0 4px rgba(255, 46, 183, 0.5);
    letter-spacing: 0.2em;
    text-align: center;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dotted rgba(255, 46, 183, 0.3);
}

.landing-controls ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.landing-controls li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
}

.landing-controls .lc-icon {
    color: var(--neon-yellow);
    text-shadow: 0 0 4px rgba(255, 230, 0, 0.6);
    min-width: 1.6em;
    text-align: center;
    font-weight: bold;
}

.landing-hint {
    color: #8888aa;
    font-size: 0.95rem;
    text-align: center;
    margin-top: 0.4rem;
    letter-spacing: 0.05em;
}

/* ─── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 20px 24px;
    border: 3px solid var(--neon-cyan);
    border-radius: 0;
    background: rgba(0, 240, 255, 0.08);
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    min-height: 68px;
    box-shadow:
        0 0 12px rgba(0, 240, 255, 0.45),
        inset 0 0 12px rgba(0, 240, 255, 0.15);
}

.btn-primary:hover,
.btn-primary:active {
    background: rgba(0, 240, 255, 0.18);
    box-shadow:
        0 0 18px rgba(0, 240, 255, 0.75),
        inset 0 0 18px rgba(0, 240, 255, 0.25);
}

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

.btn-primary .btn-title {
    font-size: 1rem;
    letter-spacing: 0.15em;
    color: var(--neon-yellow);
    text-shadow: 0 0 6px var(--neon-yellow);
}

.btn-primary .btn-desc {
    font-family: 'VT323', monospace;
    font-size: 0.9rem;
    color: #88ccee;
    text-shadow: none;
    letter-spacing: 0.05em;
}

.btn-secondary {
    padding: 10px 18px;
    border: 2px solid #555;
    border-radius: 0;
    background: transparent;
    color: #aab;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    cursor: pointer;
    min-height: 44px;
    min-width: 44px;
    text-transform: uppercase;
    transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-secondary:hover,
.btn-secondary:active {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

/* ─── Status banners ──────────────────────────────────────────────── */
.hero-ok {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.8rem;
    color: var(--neon-green);
    text-align: center;
    text-shadow: 0 0 8px var(--neon-green);
}

.hero-err {
    font-family: 'VT323', monospace;
    font-size: 1.1rem;
    color: var(--neon-red);
    text-align: center;
    max-width: 320px;
    text-shadow: 0 0 6px rgba(255, 0, 60, 0.6);
}

.hero-scanning {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.9rem;
    color: var(--neon-yellow);
    text-align: center;
    letter-spacing: 0.15em;
    text-shadow: 0 0 8px rgba(255, 230, 0, 0.6);
}

.port-info-text {
    color: #99c;
    font-size: 0.95rem;
    text-align: center;
}
.port-info-text strong { color: var(--neon-cyan); }

/* ─── Picker ──────────────────────────────────────────────────────── */
.picker-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 360px;
    background: linear-gradient(180deg, rgba(20, 8, 40, 0.95), rgba(8, 4, 20, 0.95));
    border: 3px solid var(--neon-magenta);
    border-radius: 0;
    padding: 1.2rem;
    box-shadow:
        0 0 18px rgba(255, 46, 183, 0.55),
        inset 0 0 18px rgba(255, 46, 183, 0.1);
}

.picker-card h2 {
    font-size: 0.85rem;
    letter-spacing: 0.2em;
}

#picker-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.picker-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    background: rgba(0, 240, 255, 0.06);
    border: 2px solid #335;
    border-radius: 0;
    color: var(--neon-cyan);
    cursor: pointer;
    min-height: 56px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-align: left;
    width: 100%;
    text-transform: uppercase;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.picker-entry:hover,
.picker-entry:active {
    background: rgba(0, 240, 255, 0.18);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 14px rgba(0, 240, 255, 0.5);
}

.picker-entry .picker-meta {
    color: #779;
    font-size: 0.55rem;
    font-family: 'VT323', monospace;
}

/* ─── Connecting overlay ──────────────────────────────────────────── */
.connecting-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    border: 2px dashed var(--neon-yellow);
    background: rgba(255, 230, 0, 0.05);
    box-shadow: 0 0 18px rgba(255, 230, 0, 0.3);
}

/* ─── Game view ────────────────────────────────────────────────────── */
#game-view {
    justify-content: center;
    gap: 0.5rem;
    padding: 0.25rem;
}

#cabinet-wrapper {
    position: relative;
    /* 690/926 ≈ 0.745. To keep the cabinet ≤ 86vh tall, the width must be
       ≤ 86vh × 0.745 = 64vh (in width units). */
    width: min(99vw, calc(86vh * 690 / 926), 700px);
    aspect-ratio: 690 / 926;
    filter: drop-shadow(0 0 18px rgba(0, 240, 255, 0.35));
}

#cabinet-img {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    pointer-events: none;
}

#screen-container {
    position: absolute;
    top: 41.5%;
    /* Slightly wider than the original PNG aperture (62.32%) → a few px of
       black bar appears on each side, the canvas keeps its 4:3 aspect. */
    left: 16.84%;
    width: 66.32%;
    height: 33.04%;
    overflow: hidden;
    background: #000;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 0 8px #000,
        inset 0 0 18px rgba(0, 240, 255, 0.5);
}

#arcade-canvas {
    display: block;
    height: 100%;
    width: auto;
    aspect-ratio: 320 / 240;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    touch-action: manipulation;
}

/* CRT scanlines on the canvas itself, tighter than the page-wide overlay */
#screen-container::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0 2px,
        rgba(0, 0, 0, 0.35) 2px 3px
    );
    mix-blend-mode: multiply;
    z-index: 3;
}

.game-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: min(99vw, 700px);
    flex-wrap: wrap;
}

.game-controls {
    display: flex;
    gap: 1rem;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    flex: 1;
    min-width: 8rem;
    text-transform: uppercase;
}

#status {
    color: var(--neon-yellow);
    text-shadow: 0 0 4px rgba(255, 230, 0, 0.6);
}
#status.connected {
    color: var(--neon-green);
    text-shadow: 0 0 4px rgba(57, 255, 20, 0.6);
}
#status.error {
    color: var(--neon-red);
    text-shadow: 0 0 4px rgba(255, 0, 60, 0.6);
}
#fps { color: #557; }

/* ─── Screen-only mode (toggle via the FULL button) ────────────────
   Hides the cabinet PNG and resizes the wrapper to the canvas's 4:3
   aspect so the game fills as much of the viewport as possible. */
body.screen-mode #cabinet-wrapper {
    width: min(99vw, calc(86vh * 4 / 3), 1000px);
    aspect-ratio: 4 / 3;
    filter: drop-shadow(0 0 12px rgba(0, 240, 255, 0.5));
}
body.screen-mode #cabinet-img { display: none; }
body.screen-mode #screen-container {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--neon-cyan);
}

/* ─── Wider screens ─────────────────────────────────────────────── */
@media (min-width: 768px) {
    #landing-cabinet { max-height: 50vh; width: min(35vw, 320px); }
    .btn-primary { max-width: 360px; }
    .subtitle { font-size: 0.7rem; }
}
