* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
    --ink: #17324d;
    --green: #3bd16f; --green-lip: #1f8a45;
    --orange: #ff8a1f; --orange-lip: #a64d00;
    --blue: #3a8bff; --blue-lip: #1d4f9e;
    --purple: #a259ff; --purple-lip: #5f2aa8;
    --yellow: #ffd23f; --yellow-lip: #b8860b;
    --stick: clamp(108px, 30vmin, 160px);
    --jump: clamp(84px, 24vmin, 112px);
    --small: clamp(60px, 17vmin, 76px);
    --pad: max(14px, env(safe-area-inset-bottom));
}
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; background: #3aa8f5; }
body { color: #fff; font: 700 16px "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game, #controls, #loading { position: fixed; inset: 0; }
#game { width: 100%; height: 100%; display: block; outline: 0; touch-action: none; }
/* Branded loading screen (owner): the store cover fills the screen, a chunky bar like the game's buttons and
   "Loading…" at the bottom. The "BallBlox Party" logo is never cut (QA before certification, 2026-11-16):
   - landscape art, logo in its top-left corner: cover anchored top-left, so only the right / bottom is cropped —
     the logo (left 35 %, top 28 % of the art) stays whole for every window from 21:9 down to 2:3;
   - narrower windows (phones): portrait art, logo across the top, cover anchored at the top;
   - taller than 9:16: the portrait art at full width from the top (no side crop), the sea colour below. */
#loading {
    z-index: 2;
    background: #02b2d2 url("loading-landscape.webp") left top / cover no-repeat;
    display: flex; align-items: flex-end; justify-content: center;
}
@media (max-aspect-ratio: 13/20) { #loading { background-image: url("loading-portrait.webp"); background-position: center top; } }
@media (max-aspect-ratio: 9/16) { #loading { background-size: 100% auto; } }
.loading-bottom {
    display: grid; justify-items: center; gap: 8px;
    margin-bottom: max(5vh, calc(env(safe-area-inset-bottom) + 18px));
    font-size: clamp(16px, 2.6vmin, 22px); text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(23, 50, 77, 0.6);
}
.loading-bar {
    width: min(420px, 70vw); height: 26px;
    border: 3px solid var(--ink); border-radius: 16px; background: #ffffff;
    box-shadow: 0 5px 0 var(--ink); overflow: hidden; box-sizing: border-box;
}
.loading-fill {
    width: 3%; height: 100%; border-radius: 12px;
    background: linear-gradient(var(--green) 55%, var(--green-lip));
    transition: width 120ms linear;
}
#controls { pointer-events: none; z-index: 1; }
button, #stick { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }

/* Chunky buttons: dark outline, coloured fill, a darker lip underneath that sinks when pressed. */
button {
    border: 3px solid var(--ink);
    border-radius: 18px;
    min-width: 56px;
    min-height: 44px;
    padding: 0 12px;
    color: #fff;
    background: #ffffff;
    font: inherit;
    font-size: 15px;
    text-shadow: 0 2px 0 var(--ink);
    box-shadow: 0 5px 0 var(--ink);
    transition: transform 60ms, box-shadow 60ms;
}
button:active, button.held { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

.toolbar {
    position: absolute;
    bottom: calc(var(--pad) + var(--stick) + 14px);
    left: max(12px, env(safe-area-inset-left));
    display: flex;
    gap: 8px;
}
.toolbar button { background: #ffffff; color: var(--ink); text-shadow: none; min-height: 40px; font-size: 14px; border-radius: 14px; box-shadow: 0 4px 0 var(--ink); }
.toolbar #checkpoint { background: var(--yellow); box-shadow: 0 4px 0 var(--yellow-lip); }

#stick {
    position: absolute;
    left: max(18px, env(safe-area-inset-left));
    bottom: var(--pad);
    width: var(--stick);
    aspect-ratio: 1;
    border: 3px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    background: rgba(23, 50, 77, 0.35);
}
#knob {
    position: absolute;
    left: 30%;
    top: 30%;
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--ink);
    box-shadow: 0 4px 0 var(--ink);
    pointer-events: none;
}

/* Action pad: a big JUMP in the corner, DASH to its left, BRAKE above it, GRAB / THROW above DASH. */
.actions {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    bottom: var(--pad);
    width: calc(var(--jump) + var(--small) + 12px);
    height: calc(var(--jump) + var(--small) + 12px);
}
.actions button { position: absolute; border-radius: 50%; padding: 0; min-width: 0; min-height: 0; }
.actions .jump { right: 0; bottom: 0; width: var(--jump); height: var(--jump); background: var(--green); box-shadow: 0 7px 0 var(--green-lip); font-size: 22px; }
.actions .jump:active { box-shadow: 0 2px 0 var(--green-lip); }
.actions [data-action="2"] { right: calc(var(--jump) + 10px); bottom: 2px; width: var(--small); height: var(--small); background: var(--orange); box-shadow: 0 5px 0 var(--orange-lip); }
.actions [data-action="2"]:active { box-shadow: 0 1px 0 var(--orange-lip); }
.actions #brake { right: calc((var(--jump) - var(--small)) / 2); bottom: calc(var(--jump) + 12px); width: var(--small); height: var(--small); background: var(--blue); box-shadow: 0 5px 0 var(--blue-lip); font-size: 14px; }
.actions #brake:active, .actions #brake.held { box-shadow: 0 1px 0 var(--blue-lip); }
.actions #throw { right: calc(var(--jump) + 10px); bottom: calc(var(--small) + 14px); width: var(--small); height: var(--small); background: var(--purple); box-shadow: 0 5px 0 var(--purple-lip); font-size: 12px; line-height: 1.05; }
.actions #throw:active { box-shadow: 0 1px 0 var(--purple-lip); }

/* Desktop: of the controls only the pause button shows (keyboard and mouse do the rest). */
body:not(.mobile) #controls > :not(#pause) { display: none !important; }

/* Pause: top-right corner, the only way out of a match on a phone (opens the game's pause window). */
#pause {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    width: 37px; min-width: 0; height: 37px; min-height: 0;
    padding: 0;
    border-radius: 11px;
    background: #ffffff;
    box-shadow: 0 3px 0 var(--ink);
    display: flex; align-items: center; justify-content: center; gap: 5px;
}
#pause svg { width: 22px; height: 22px; fill: var(--ink); }   /* the gear: one settings icon in the whole game */
#pause:active { box-shadow: 0 1px 0 var(--ink); }
