@font-face {
    font-family: 'Varela Round';
    src: url('../fonts/VarelaRound-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    /* Safe area insets for notched / rounded-corner phones.
       Requires viewport-fit=cover (set in the <meta viewport> tag).
       Read in JS via getComputedStyle so game layout can offset UI elements. */
    --safe-area-top:    env(safe-area-inset-top,    0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left:   env(safe-area-inset-left,   0px);
    --safe-area-right:  env(safe-area-inset-right,  0px);
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* dynamic viewport height — tracks iOS URL bar show/hide */
    overflow: hidden;
    background-color: #000;
    color: #FFF;
    font: 12px 'Varela Round', Verdana, sans-serif;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.canvasWrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
}

/*
 * Faux fullscreen for iPhone WebKit (Safari/Chrome/Firefox on iPhone) where
 * the real Fullscreen API is missing or a no-op. We allow a 1px scroll so
 * `window.scrollTo(0, 1)` can nudge Safari into hiding its URL bar.
 * Touch-scroll is already disabled globally via `touch-action: none`, so
 * this doesn't interfere with gameplay.
 */
html.faux-fullscreen,
html.faux-fullscreen body {
    overflow: visible;
}
html.faux-fullscreen body {
    min-height: 101dvh;
}
.canvas {
    margin: 0 auto;
    display: block;
    position: absolute;
}
.fgCanvas {
    z-index: 1;
}
.bgCanvas {
    z-index: 0;
}
.help {
    position: absolute;
    width: 100%;
    top: 30px;
    z-index: 2;
}
.helpContent {
    position: relative;
    width: 90%;
    max-width: 700px;
    margin: 0 auto;
    background-color: #000;
    padding: 30px;
    padding-top: 20px;
    font-size: 18px;
}
.helpContent h1 {
    font-size: 24px;
}
.helpContent h2 {
    font-size: 20px;
}
.helpContent p, .helpContent li {
    font-size: 18px;
}
.hidden {
    display: none;
}
.visible {
    display: block;
}
/* ── Splash screen ────────────────────────────────────────────── */
#splash {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    transition: opacity 0.5s ease;
}
#splash.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Background image fills the entire splash */
#splash-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

/* Spinner — centred, shown while loading */
#splash-loading {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}
#splash-loading.hidden {
    opacity: 0;
    pointer-events: none;
}
#splash-spinner {
    width: 52px;
    height: 52px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    animation: splash-spin 0.8s linear infinite;
}

/* Action area — two centered rows above the bottom safe area, hidden until ready */
#splash-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-top: 40px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}
#splash-actions.ready {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Secondary row — info, privacy (matches pause screen small row) */
#splash-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* Main row — level chooser + play (matches pause screen big row) */
#splash-main-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.splash-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
}
.splash-btn img {
    width: 24px;
    height: 24px;
    filter: invert(1);
}
.splash-btn:active { transform: scale(0.90); }

/* Play button — larger, centered below secondary row (matches pause screen big row) */
#splash-play {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.1s;
    padding: 0;
    animation: splash-pulse 2.2s ease-in-out infinite;
    flex-shrink: 0;
}
#splash-play img {
    width: 28px;
    height: 28px;
    filter: invert(1);
    margin-left: 3px; /* optical centre for play triangle */
}
#splash-play:active {
    transform: scale(0.92);
    animation: none;
}

@keyframes splash-spin {
    to { transform: rotate(360deg); }
}
@keyframes splash-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.3); }
    50%       { box-shadow: 0 0 0 14px rgba(255,255,255,0); }
}
/* ── End splash ───────────────────────────────────────────────── */

h1 {
    color: #3CF;
    font-size: 16px;
    font-weight: bold;
}
h2 {
    color: #3CF;
    font-size: 13px;
    font-style: italic;
    font-weight: bold;
}
h3 {
    color: #3CF;
    font-size: 12px;
    font-style: italic;
    font-weight: normal;
    padding-left: 15px;
}
p {
    color: #FFF;
    padding-left: 15px;
}
a, a:hover, a:visited, a:link, a:active {
    color: #99F;
    text-decoration: underline;
}
.close {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #CCC;
}
li {
    margin-left: 30px;
}
