/* ==========================================
   PACXOMAN — modern neon arcade styles (CargoX edition)
   2D, responsive, mobile-first (portrait + landscape).
   ========================================== */
:root {
    --bg: #050914; --bg2: #0a1024; --panel: #0d1630; --panel2: #101a3a;
    --border: #1b3a8a; --neon: #2b6bff; --neon2: #43d6ff;
    --green: #5cbf3a; --yellow: #ffd24a; --pink: #ff7bd5; --red: #ff3b3b; --orange: #ff9f40;
    --capblue: #4a9eff;   /* the X in the logo — light blue, like the mascot's cap */
    --text: #dbe6ff; --muted: #8aa0d0;
    --font: 'Outfit', system-ui, sans-serif; --font2: 'Inter', system-ui, sans-serif;
    /* glass surface tokens (modern look) */
    --glass: linear-gradient(180deg, rgba(17,30,50,.6), rgba(10,20,36,.66));
    --glass-brd: rgba(255,255,255,.12);
    --glass-hi: inset 0 1px 0 rgba(255,255,255,.06);
    --sa-t: env(safe-area-inset-top, 0px); --sa-b: env(safe-area-inset-bottom, 0px);
    --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    /* Neutral dark-navy like cargoxrelayer.com / CargoX Adventures (not a bright
       blue halo). The maze keeps its own dark #050914 canvas background. */
    background: radial-gradient(ellipse at 50% -5%, #142c48 0%, #0a1626 45%, #07111d 100%);
    color: var(--text); font-family: var(--font2);
    overflow: hidden; overscroll-behavior: none;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
    touch-action: none;
}
#game-container { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---- top-corner controls ---- */
.game-back-link { position: fixed; top: calc(14px + var(--sa-t)); left: calc(16px + var(--sa-l)); z-index: 40; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.game-back-link:hover { color: var(--neon2); }
.lang-selector { position: fixed; top: calc(12px + var(--sa-t)); right: calc(14px + var(--sa-r)); z-index: 40; display: flex; gap: 6px; }
.lang-btn { background: rgba(20,32,70,.6); backdrop-filter: blur(8px); border: 1px solid var(--glass-brd); color: var(--muted); border-radius: 9px; padding: 5px 9px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: color .15s, border-color .15s, box-shadow .15s; }
.lang-btn.active, .lang-btn:hover { color: #fff; border-color: var(--neon2); box-shadow: 0 0 12px rgba(67,214,255,.4); }

/* ---- playing chrome ---- */
.hud { display: none; flex-direction: column; align-items: center; gap: 10px; width: 100%; height: 100%;
    padding: calc(12px + var(--sa-t)) calc(12px + var(--sa-r)) calc(12px + var(--sa-b)) calc(12px + var(--sa-l)); }
.hud.visible { display: flex; }
.hud-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: center; width: 100%; max-width: 1120px; }
.hud-logo { font-family: var(--font); font-weight: 900; font-size: 22px; letter-spacing: 1px; margin-right: auto; cursor: pointer; transition: opacity .15s; }
.hud-logo:hover { opacity: .82; }
.hud-logo .c { color: var(--green); text-shadow: 0 0 12px rgba(92,191,58,.6); }
.hud-logo .x { color: var(--capblue); text-shadow: 0 0 12px rgba(74,158,255,.6); }
.chip { background: var(--glass); backdrop-filter: blur(12px) saturate(1.2); border: 1px solid var(--glass-brd); border-radius: 14px;
    padding: 6px 14px; text-align: center; min-width: 74px; box-shadow: 0 4px 18px rgba(0,0,0,.28), var(--glass-hi); }
.chip label { display: block; font-size: 9px; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.chip b { font-family: var(--font); font-size: 18px; color: #fff; }
.chip.hud-compact { display: none; }                 /* shown only on compact/mobile layouts */
.chip.pw { min-width: 92px; }
.power-bar.mini { height: 6px; margin-top: 6px; }
.pause-btn { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-brd); color: var(--neon2); border-radius: 12px; width: 42px; height: 42px; font-size: 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.pause-btn:hover, .pause-btn:active { border-color: var(--neon2); box-shadow: 0 0 14px rgba(67,214,255,.35); }

.hud-main { display: flex; flex: 1 1 auto; min-height: 0; width: 100%; align-items: center; justify-content: center; gap: 14px; }
#canvas-container {
    flex: 0 0 auto; background: #050914;
    border: 1px solid rgba(67,214,255,.32); border-radius: 18px; padding: 8px;
    box-shadow: 0 0 0 1px rgba(43,107,255,.18), 0 24px 70px rgba(0,0,0,.5), 0 0 60px rgba(43,107,255,.22), inset 0 0 40px rgba(43,107,255,.1);
    display: flex; align-items: center; justify-content: center;
}
#game-canvas { display: block; border-radius: 10px; image-rendering: auto; }

/* ---- right panel (desktop) ---- */
#side-panel { width: 190px; display: flex; flex-direction: column; gap: 8px; }
.panel-sec { background: var(--glass); backdrop-filter: blur(12px) saturate(1.2); border: 1px solid var(--glass-brd); border-radius: 14px; padding: 9px 12px; box-shadow: var(--glass-hi); }
.panel-sec > label { display: block; font-size: 9px; letter-spacing: .14em; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.panel-sec > b { font-family: var(--font); font-size: 20px; color: #fff; }
.lives { display: flex; gap: 6px; }
.life-icon { width: 20px; height: 20px; border-radius: 5px; background: linear-gradient(150deg, #5cbf3a, #2f7a1c); box-shadow: 0 0 8px rgba(92,191,58,.5); position: relative; }
.life-icon::after { content: ''; position: absolute; top: -4px; left: 3px; right: 3px; height: 6px; border-radius: 4px 4px 0 0; background: #2b6bff; }
.power-bar { height: 7px; background: #071029; border-radius: 5px; margin-top: 6px; overflow: hidden; }
#power-fill, #power-fill-m { height: 100%; width: 0%; background: linear-gradient(90deg, var(--yellow), var(--orange)); transition: width .2s linear; }
.ctrl-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.ctrl-keys span { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; text-align: center; padding: 5px 0; color: var(--neon2); font-size: 13px; }
.legend .leg { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 5px; }
.leg i { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; }
.leg-dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.leg-doc { background: #e8f0ff; border-radius: 2px !important; }
.leg-cont { background: var(--green); border-radius: 3px !important; box-shadow: 0 0 8px var(--green); }
.leg-enemy { background: var(--pink); box-shadow: 0 0 8px var(--pink); }

.hud-bottom { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.hud-bottom span { display: inline-flex; align-items: center; gap: 6px; }

/* ---- mobile touch controls: split thumb pads (left = up/down, right = left/right) ---- */
#mobile-controls { display: none; position: fixed; left: 0; right: 0; bottom: calc(18px + var(--sa-b)); z-index: 35;
    justify-content: space-between; align-items: flex-end; pointer-events: none;
    padding: 0 calc(20px + var(--sa-r)) 0 calc(20px + var(--sa-l)); }
#mobile-controls.visible { display: flex; }
.pad { display: flex; gap: 14px; pointer-events: auto; opacity: .82; }
.pad-left { flex-direction: column; }     /* ▲ over ▼  → left thumb */
.pad-right { flex-direction: row; }        /* ◀ ▶       → right thumb */
.dpad-btn { width: 60px; height: 60px; border-radius: 16px; background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--neon); color: var(--neon2); font-size: 20px; cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.35), var(--glass-hi); transition: background .1s, color .1s, transform .06s; }
.dpad-btn:active { background: var(--neon); color: #fff; transform: scale(.94); }

/* ---- overlays ---- */
.overlay { display: none; position: absolute; inset: 0; z-index: 50; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(ellipse at 50% 0%, rgba(20,42,68,.9) 0%, rgba(7,17,30,.96) 72%);
    backdrop-filter: blur(8px); overflow-y: auto; }
.overlay.active { display: flex; }
.panel { width: 100%; max-width: 460px; background: linear-gradient(180deg, rgba(16,29,48,.92), rgba(10,20,34,.95)); border: 1px solid var(--glass-brd);
    border-radius: 22px; padding: 26px 24px; text-align: center; box-shadow: 0 24px 70px rgba(0,0,0,.6), inset 0 0 46px rgba(43,107,255,.12), var(--glass-hi); }
.logo { font-family: var(--font); font-weight: 900; font-size: 52px; letter-spacing: 2px; margin-bottom: 4px; line-height: 1; }
.logo .c { color: var(--green); text-shadow: 0 0 18px rgba(92,191,58,.6); } .logo .x { color: var(--capblue); text-shadow: 0 0 18px rgba(74,158,255,.6); }
.logo-sub { color: var(--neon2); letter-spacing: .3em; font-size: 12px; font-weight: 700; margin-bottom: 14px; }
/* Animated CargoX mascot (4-frame walk strip) between the logo and PLAY. */
.menu-mascot { width: 186px; height: 132px; margin: 2px auto 16px;
    background: url('img/menu-mascot.png') 0 0 / 744px 132px no-repeat;
    filter: drop-shadow(0 8px 10px rgba(0,0,0,.4)); }
@media (max-height: 560px) { .menu-mascot { display: none; } }   /* keep short/landscape menus compact */
.panel h2 { font-family: var(--font); font-weight: 800; font-size: 26px; margin-bottom: 8px; }
.panel .sub, .panel .lead { color: var(--muted); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }
.win-title { color: var(--green); text-shadow: 0 0 16px rgba(92,191,58,.5); }
.danger-title { color: var(--red); text-shadow: 0 0 16px rgba(255,59,59,.5); }
.medal { font-size: 54px; margin: 6px 0 14px; }

.menu-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.menu-buttons .row { display: flex; gap: 10px; }
.menu-buttons .row .btn { flex: 1; }
.btn { font-family: var(--font); font-weight: 800; letter-spacing: .04em; border: none; border-radius: 13px; padding: 13px 18px; font-size: 15px; cursor: pointer;
    transition: transform .12s, box-shadow .12s, background .12s, border-color .12s; }
.btn:active { transform: translateY(1px); }
/* Palette matched to CargoX Adventures: green-gradient primary (white text),
   neutral white-glass secondary, red-gradient danger. */
.btn.primary { background: linear-gradient(135deg, var(--green), #3d9022); color: #fff; box-shadow: 0 4px 14px rgba(92,191,58,.4); }
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(92,191,58,.6); }
.btn.secondary { background: rgba(255,255,255,.08); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.15); color: #fff; }
.btn.secondary:hover { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.25); transform: translateY(-2px); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; border: none; }
.btn.danger:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239,68,68,.4); }
.btn.glow { box-shadow: 0 0 20px rgba(92,191,58,.3); position: relative; overflow: hidden; }
/* Animated diagonal sheen on the PLAY button — same effect as CargoX Adventures. */
.btn.glow::after {
    content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,.2), transparent);
    transform: rotate(45deg); animation: shineEffect 3s infinite linear; pointer-events: none;
}
@keyframes shineEffect { 0% { left: -100%; } 100% { left: 100%; } }
.btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.15); color: #fff; text-decoration: none; text-align: center; }
.btn.ghost:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.25); }
.credits { color: var(--muted); font-size: 11px; margin-top: 18px; }

.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; text-align: left; }
.step { background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 14px; padding: 12px; position: relative; box-shadow: var(--glass-hi); }
.step .badge { position: absolute; top: -8px; left: -8px; width: 24px; height: 24px; border-radius: 50%; background: var(--neon); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.step h3 { font-size: 13px; color: var(--neon2); margin-bottom: 4px; } .step p { font-size: 12px; color: var(--muted); line-height: 1.4; }

.summary { background: var(--glass); border: 1px solid var(--glass-brd); border-radius: 14px; padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--glass-hi); }
.row-stat { display: flex; justify-content: space-between; padding: 4px 0; color: var(--muted); font-size: 14px; }
.row-stat strong { color: #fff; font-family: var(--font); }

/* ---- leaderboard ---- */
.lb-block { margin: 16px 0; }
.lb-title { font-family: var(--font); color: var(--green); font-size: 18px; margin-bottom: 10px; }
.lb-submit { display: flex; gap: 8px; margin-bottom: 8px; }
.lb-nick { flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; color: #fff; padding: 10px 12px; font-size: 14px; }
.lb-nick:focus { outline: none; border-color: var(--neon2); }
.lb-save-btn { padding: 10px 16px; font-size: 13px; }
.lb-msg { font-size: 12px; color: var(--yellow); min-height: 16px; margin-bottom: 6px; }
.lb-list { list-style: none; max-height: 44vh; overflow-y: auto; }
.lb-list .lb-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid rgba(27,58,138,.4); font-size: 14px; }
.lb-row .lb-rank { width: 34px; font-weight: 800; color: var(--neon2); } .lb-row .lb-name { flex: 1; text-align: left; }
.lb-row .lb-score { font-family: var(--font); font-weight: 800; color: var(--green); }
.lb-row.lb-me { background: rgba(92,191,58,.1); border-radius: 8px; }
.lb-empty { color: var(--muted); padding: 14px; font-size: 13px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Compact layout: narrow windows and phones — drop the verbose side
   panel + footer, surface lives/power as compact top chips, maze fills. */
@media (max-width: 860px) {
    #side-panel { display: none; }
    .hud-bottom { display: none; }
    .chip.hud-compact { display: block; }
    .hud-logo { display: none; }                 /* reclaim width for stats */
    .hud-top { gap: 7px; }
    .chip { min-width: 62px; padding: 5px 11px; }
    .chip b { font-size: 16px; }
}

/* Phone portrait — keep the D-pad centred; a touch more breathing room. */
@media (max-width: 560px) {
    .chip { min-width: 54px; padding: 5px 9px; }
    .chip label { font-size: 8px; }
    .chip b { font-size: 15px; }
    .steps { grid-template-columns: 1fr; }
    .logo { font-size: 40px; }
    .panel { padding: 22px 18px; }
}

/* Short / landscape screens (phones on their side) — the primary mobile mode.
   Slim top bar, maze maximised, D-pad tucked into the bottom-left for the thumb. */
@media (max-height: 560px) and (orientation: landscape) {
    .hud { gap: 6px; padding: calc(6px + var(--sa-t)) calc(8px + var(--sa-r)) calc(6px + var(--sa-b)) calc(8px + var(--sa-l)); }
    #side-panel { display: none; }
    .hud-bottom { display: none; }
    .chip.hud-compact { display: block; }
    .hud-logo { display: none; }
    .hud-top { gap: 6px; }
    .chip { min-width: 52px; padding: 3px 9px; border-radius: 11px; }
    .chip label { font-size: 8px; }
    .chip b { font-size: 14px; }
    .pause-btn { width: 36px; height: 36px; font-size: 14px; }
    #canvas-container { padding: 5px; border-radius: 13px; }
    /* thumb pads hug the bottom corners, a touch smaller + translucent */
    #mobile-controls { bottom: calc(10px + var(--sa-b)); padding: 0 calc(14px + var(--sa-r)) 0 calc(14px + var(--sa-l)); }
    .pad { opacity: .74; gap: 12px; }
    .dpad-btn { width: 52px; height: 52px; font-size: 18px; }
    /* language selector stays available on the menu; show() hides it only in-game */
}
