@font-face {
    font-family: "Orbitron";
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url("../assets/fonts/ui/Orbitron/Orbitron-VariableFont_wght.ttf") format("truetype");
}

:root {
    --ga-bg: #0d1117;
    --ga-text: #e6edf3;
    --ga-card: rgba(13, 17, 23, 0.82);
    --ga-card-border: rgba(148, 163, 184, 0.4);
    --ga-accent: #33a8ff;
    --ga-success: #2ecc71;
    --ga-danger: #ff5f57;
    --ga-warning: #ffcc66;

    /*
     * Device safe-area insets (notch, Dynamic Island, home bar).
     * Requires viewport-fit=cover in the <meta viewport> tag (already set).
     * These are zero in desktop browsers and the Xcode simulator by default;
     * on real devices they reflect actual hardware insets.
     * Apply via calc() wherever UI elements need to avoid hardware cutouts.
     */
    --safe-top:    env(safe-area-inset-top,    0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left,   0px);
    --safe-right:  env(safe-area-inset-right,  0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    background: #000;
    color: var(--ga-text);
    font-family: Orbitron, Arial, sans-serif;
}

#appRoot {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#pixiHost {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#uiHost {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ga-menu-title {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 620px;
    height: 140px;
    pointer-events: none;
    z-index: 5;
    filter: drop-shadow(0 2px 10px rgba(96, 165, 250, 0.18));
}

.ga-menu-title-layer {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-family: Orbitron, Arial, sans-serif;
    font-weight: 800;
    line-height: 1;
    user-select: none;
}

.ga-menu-title-glow-0,
.ga-menu-title-glow-1,
.ga-menu-title-glow-2,
.ga-menu-title-glow-3 {
    font-size: 132px;
    transform-origin: 50% 52%;
}

.ga-menu-title-glow-0 {
    color: #1d4ed8;
    opacity: 0.18;
    animation: gaTitleFloatA 9.6s ease-in-out infinite;
}

.ga-menu-title-glow-1 {
    color: #2563eb;
    opacity: 0.27;
    animation: gaTitleFloatB 10.8s ease-in-out infinite;
}

.ga-menu-title-glow-2 {
    color: #3b82f6;
    opacity: 0.36;
    animation: gaTitleFloatC 8.9s ease-in-out infinite;
}

.ga-menu-title-glow-3 {
    color: #93c5fd;
    opacity: 0.45;
    animation: gaTitleFloatD 11.4s ease-in-out infinite;
}

.ga-menu-title-main {
    font-size: 128px;
    color: transparent;
    background-image: linear-gradient(100deg,
            #f8fbff 0%,
            #dbeafe 18%,
            #bfdbfe 35%,
            #f8fbff 52%,
            #ddd6fe 70%,
            #e0f2fe 100%);
    background-size: 220% 220%;
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow:
        0 0 16px rgba(191, 219, 254, 0.35),
        0 0 24px rgba(59, 130, 246, 0.2);
    animation: gaTitleSpectrum 17s linear infinite;
}

.ga-menu-title-sweep {
    font-size: 128px;
    color: transparent;
    background-image: linear-gradient(110deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.05) 28%,
            rgba(255, 255, 255, 0.95) 48%,
            rgba(255, 255, 255, 0.12) 63%,
            rgba(255, 255, 255, 0) 100%);
    background-size: 240% 100%;
    background-position: -180% 0%;
    -webkit-background-clip: text;
    background-clip: text;
    mix-blend-mode: screen;
    opacity: 0.8;
    animation: gaTitleSweep 7.8s ease-in-out infinite;
}

@keyframes gaTitleFloatA {
    0% {
        transform: translate(0px, 0px) scale(1);
    }

    22% {
        transform: translate(2px, -1px) scale(1.025);
    }

    47% {
        transform: translate(-2px, 1px) scale(0.995);
    }

    72% {
        transform: translate(3px, 0px) scale(1.03);
    }

    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

@keyframes gaTitleFloatB {
    0% {
        transform: translate(0px, 0px) scale(1);
    }

    25% {
        transform: translate(-2px, 1px) scale(1.02);
    }

    52% {
        transform: translate(2px, -2px) scale(1.01);
    }

    78% {
        transform: translate(-1px, 1px) scale(1.03);
    }

    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

@keyframes gaTitleFloatC {
    0% {
        transform: translate(0px, 0px) scale(1);
    }

    20% {
        transform: translate(1px, -1px) scale(1.018);
    }

    45% {
        transform: translate(-2px, 1px) scale(1.028);
    }

    67% {
        transform: translate(2px, -1px) scale(0.998);
    }

    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

@keyframes gaTitleFloatD {
    0% {
        transform: translate(0px, 0px) scale(1);
    }

    31% {
        transform: translate(-1px, 1px) scale(1.02);
    }

    58% {
        transform: translate(2px, -2px) scale(1.03);
    }

    84% {
        transform: translate(-2px, 0px) scale(1);
    }

    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

@keyframes gaTitleSpectrum {
    0% {
        background-position: 0% 50%;
    }

    25% {
        background-position: 55% 45%;
    }

    50% {
        background-position: 100% 50%;
    }

    75% {
        background-position: 45% 55%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes gaTitleSweep {
    0% {
        background-position: -180% 0%;
        opacity: 0;
    }

    12% {
        opacity: 0.85;
    }

    36% {
        background-position: 240% 0%;
        opacity: 0.35;
    }

    100% {
        background-position: 240% 0%;
        opacity: 0;
    }
}

.ga-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: auto;
}

.ga-screen-menu {
    align-items: flex-start;
    padding-top: calc(168px + var(--safe-top));
}

.ga-screen-menu .ga-card {
    max-height: calc(100vh - 188px - var(--safe-top));
}

/* ── Native iPhone menu screens ────────────────────────────────────────────
 * No OPTRIX headline on iPhone → collapse the 168 px safe-area top padding.
 * All child elements are compacted so the full card fits in ~375–430 px height.
 * ────────────────────────────────────────────────────────────────────────── */
body.native-iphone .ga-screen-menu {
    padding-top: calc(var(--safe-top) + 8px);
    align-items: center;
}

body.native-iphone .ga-screen-menu .ga-card {
    max-height: calc(100vh - var(--safe-top) - 16px);
    width: min(680px, 96vw);
    overflow-y: auto;   /* scroll if feedback message grows the content */
    padding: 10px 14px;
    gap: 6px;
}

body.native-iphone .ga-screen-menu .ga-card .ga-title {
    font-size: 18px;
    margin: 0;
}

body.native-iphone .ga-screen-menu .ga-card .ga-input,
body.native-iphone .ga-screen-menu .ga-card .ga-button,
body.native-iphone .ga-screen-menu .ga-card .ga-select {
    padding: 7px 10px;
    font-size: 12px;
}

body.native-iphone .ga-screen-menu .ga-card .ga-msg {
    margin-top: 0;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.3;
}

/* ── Native iPad menu screens ──────────────────────────────────────────────
 * OPTRIX headline is shown on iPad (168 px padding stays).
 * Mild sizing improvements — the extra screen height gives plenty of room.
 * ────────────────────────────────────────────────────────────────────────── */
body.native-app:not(.native-iphone) .ga-screen-menu .ga-card {
    width: min(560px, 90vw);
    padding: 20px 24px;
    gap: 10px;
}

body.native-app:not(.native-iphone) .ga-screen-menu .ga-card .ga-title {
    font-size: 24px;
}

/* Native (iPhone + iPad): skip-song button stacks below the gear icon */
body.native-app .ga-skip-song {
    left: 14px;
    top: calc(14px + var(--safe-top) + 42px + 8px);
}

.ga-hidden {
    display: none;
}

.ga-card {
    width: min(760px, 95vw);
    max-height: 92vh;
    overflow: hidden;
    border: 1px solid var(--ga-card-border);
    border-radius: 12px;
    background: var(--ga-card);
    backdrop-filter: blur(4px);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ga-level-stats-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* When a stats area is present, fix the card height so the scroll area can grow into it */
.ga-card:has(.ga-level-stats-area) {
    height: calc(100vh - 188px);
}

/* Scroll area fills remaining card space when a stats area is present */
.ga-level-stats-area ~ .ga-card-scroll {
    flex: 1 1 0;
}

/* ── Native two-column selection card (pack & level selection) ─────────────
 * List panel (left, flex 2) | Info + buttons panel (right, flex 1)
 * Applied when isNativeApp() returns true.
 * ────────────────────────────────────────────────────────────────────────── */
.ga-selection-card--native {
    flex-direction: row !important; /* override ga-col which sets column */
    padding: 0;
    overflow: hidden;
    gap: 0;
    width: 96vw;
    max-width: 960px;
}

/* iPhone: fill full available height (no OPTRIX headline) */
body.native-iphone .ga-selection-card--native {
    height: calc(100vh - var(--safe-top) - 16px);
}

/* iPad: fill height below the OPTRIX headline */
body.native-app:not(.native-iphone) .ga-selection-card--native {
    height: calc(100vh - 200px - var(--safe-top));
}

/* List panel — left 2/3, scrollable */
.ga-selection-list-panel {
    flex: 2;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--ga-card-border);
    overflow: hidden;
}

.ga-selection-list-panel .ga-card-scroll {
    flex: 1;
    min-height: 0;
    padding: 10px 12px;
}

/* Info panel — right 1/3 */
.ga-selection-info-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
}

/* Top section: title, subtitle, stats/status — grows to fill space */
.ga-selection-info-top {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.ga-selection-info-top .ga-title {
    font-size: 16px;
    margin: 0;
}

.ga-selection-info-top .ga-subtitle {
    font-size: 11px;
    margin: 0;
    line-height: 1.4;
}

/* Bottom section: buttons pinned to bottom of info panel */
.ga-selection-info-bottom {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-top: 10px;
    border-top: 1px solid var(--ga-card-border);
}

/* Compact items inside native list panel */
body.native-app .ga-selection-list-panel .ga-item {
    padding: 7px 10px;
    font-size: 12px;
}

/* Compact buttons in the info panel */
body.native-app .ga-selection-info-bottom .ga-button {
    padding: 8px 10px;
    font-size: 12px;
}

/* Compact stats row inside info panel */
body.native-app .ga-selection-info-top .ga-status-row {
    font-size: 11px;
    flex-direction: column;
    gap: 2px;
}

body.native-app .ga-selection-info-top .ga-status-row span {
    text-align: left;
    flex: unset;
}

.ga-card-scroll {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 2px;
}

.ga-card-footer {
    position: sticky;
    bottom: 0;
    background: rgba(13, 17, 23, 0.92);
    padding-top: 8px;
    border-top: 1px solid var(--ga-card-border);
    z-index: 2;
}

.ga-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ga-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ga-title {
    font-size: 28px;
    margin: 0 0 8px;
    color: #fff;
}

.ga-subtitle {
    font-size: 14px;
    margin: 0 0 12px;
    opacity: 0.88;
}

.ga-input,
.ga-select,
.ga-button,
.ga-textarea {
    width: 100%;
    border: 1px solid #4b5563;
    background: rgba(17, 24, 39, 0.9);
    color: var(--ga-text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}

.ga-input:-webkit-autofill,
.ga-input:-webkit-autofill:hover,
.ga-input:-webkit-autofill:focus,
.ga-input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--ga-text);
    caret-color: var(--ga-text);
    font-family: Orbitron, Arial, sans-serif !important;
    -webkit-box-shadow: 0 0 0 1000px rgba(17, 24, 39, 0.9) inset;
    box-shadow: 0 0 0 1000px rgba(17, 24, 39, 0.9) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.ga-textarea {
    min-height: 74px;
    resize: vertical;
}

.ga-button {
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease;
}

.ga-button:hover {
    transform: translateY(-1px);
}

.ga-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.ga-button-primary {
    border-color: #1f6feb;
    background: #1f6feb;
    color: #fff;
}

.ga-button-secondary {
    border-color: #6b7280;
}

.ga-button-success {
    border-color: #2ea043;
    background: #2ea043;
    color: #fff;
}

.ga-button-light {
    border-color: #d1d5db;
    background: #ffffff;
    color: #111827;
}

.ga-button-danger {
    border-color: #da3633;
    background: #da3633;
    color: #fff;
}

.ga-tag {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid #6b7280;
}

.ga-tag-stars {
    font-weight: 700;
}

.ga-tag-stars-0 {
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.18);
    color: #fca5a5;
}

.ga-tag-stars-1 {
    border-color: #eab308;
    background: rgba(234, 179, 8, 0.18);
    color: #fde68a;
}

.ga-tag-stars-2 {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

.ga-tag-betatest {
    border-color: #eab308;
    background: rgba(234, 179, 8, 0.18);
    color: #fde68a;
}

.ga-tag-free {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

.ga-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.ga-item {
    border: 1px solid #4b5563;
    border-radius: 8px;
    padding: 10px;
    background: rgba(15, 23, 42, 0.75);
}

.ga-item-selected {
    border-color: var(--ga-accent);
    box-shadow: 0 0 0 1px rgba(51, 168, 255, 0.35) inset;
}

.ga-item-locked {
    opacity: 0.55;
}

.ga-msg {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
}

.ga-msg-info {
    border: 1px solid #2563eb;
    background: rgba(37, 99, 235, 0.15);
}

.ga-msg-success {
    border: 1px solid #16a34a;
    background: rgba(22, 163, 74, 0.15);
}

.ga-msg-error {
    border: 1px solid #dc2626;
    background: rgba(220, 38, 38, 0.15);
}

.ga-field-label {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.ga-play-layout {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1320px;
    height: 900px;
    pointer-events: none;
}

.ga-play-shell-panel {
    position: absolute;
    border-radius: 18px;
    border: 1px solid rgba(201, 220, 242, 0.62);
    background: rgba(13, 17, 23, 0.7);
    box-shadow:
        0 14px 30px rgba(0, 0, 0, 0.34),
        inset 0 0 0 1px rgba(220, 234, 255, 0.08);
    pointer-events: none;
    z-index: 0;
}

.ga-play-sidebar {
    position: absolute;
    right: 0;
    top: 0;
    width: var(--ga-sidebar-width, 320px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
    z-index: 2;
}

.ga-hud-box {
    border-radius: 8px;
    border: 1px solid var(--ga-card-border);
    background: var(--ga-card);
    padding: 12px;
    font-size: 16px;
    line-height: 1.5;
}

.ga-play-sidebar .ga-hud-box {
    background: rgba(13, 17, 23, 0.6);
}

.ga-hud-box-primary {
    font-size: 22px;
    font-weight: 700;
}

.ga-hud-level-name {
    font-size: 28px;
    margin-bottom: 8px;
}

.ga-hud-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 34px;
    line-height: 1.15;
    white-space: nowrap;
}

.ga-hud-label {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.ga-hud-value {
    min-width: 120px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: "JetBrains Mono", "Roboto Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    letter-spacing: 0;
}

.ga-play-controls-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.ga-output-box {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;
}

.ga-output-box::-webkit-scrollbar {
    display: none;
}

.ga-output-content {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 20px;
    line-height: 1.35;
}

.ga-output-description {
    color: #8fd1ff;
}

.ga-output-prompt {
    margin-top: 6px;
    font-size: 26px;
    line-height: 1;
}

.ga-result-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.4);
}

.ga-level-end-text {
    position: absolute;
    z-index: 40;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
    display: grid;
    place-items: center;
}

.ga-level-end-glow-stack {
    position: relative;
    grid-area: 1 / 1;
}

.ga-level-end-glow,
.ga-level-end-main {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: Orbitron, Arial, sans-serif;
    font-weight: 800;
    line-height: 1;
}

.ga-level-end-main {
    position: relative;
    grid-area: 1 / 1;
    left: auto;
    top: auto;
    transform: none;
    font-size: 128px;
    color: #ffffff;
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.35);
}

/* iPhone: scale end-text to fill viewport width minus safe-area clearance + extra margin.
 * Uses max(safe-left, safe-right) so the text clears the notch/island in both
 * landscape orientations.  /7 approximates the Orbitron character width ratio for the
 * 10-character strings ("COMPLETED!" / "GAME OVER!").
 * clamp keeps it small on tiny screens and caps at 128 px on larger ones.
 * !important on the glow rule overrides the inline font-size set by JS. */
body.native-iphone .ga-level-end-main {
    font-size: clamp(30px, calc((100vw - 2 * max(var(--safe-left), var(--safe-right)) - 56px) / 7), 128px);
}

body.native-iphone .ga-level-end-glow {
    font-size: clamp(30px, calc((100vw - 2 * max(var(--safe-left), var(--safe-right)) - 56px) / 7), 128px) !important;
}

.ga-toast-host {
    position: absolute;
    right: 14px;
    top: calc(14px + var(--safe-top));
    display: grid;
    gap: 8px;
    pointer-events: none;
}

.ga-toast {
    pointer-events: auto;
    border: 1px solid #6b7280;
    background: rgba(2, 6, 23, 0.92);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    min-width: 220px;
}

.ga-settings-gear {
    position: absolute;
    left: 14px;
    top: calc(14px + var(--safe-top));
    width: 42px;
    height: 42px;
    border-radius: 999px;
    /* Override Orbitron so the system emoji/symbol font is used for ⚙ and ⏭ */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", system-ui, sans-serif;
    border: 1px solid var(--ga-card-border);
    background: rgba(2, 6, 23, 0.92);
    color: var(--ga-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    z-index: 45;
    pointer-events: auto;
    display: grid;
    place-items: center;
    transition: transform 120ms ease, background-color 120ms ease;
}

.ga-settings-gear:hover {
    transform: translateY(-1px) rotate(10deg);
    background: rgba(15, 23, 42, 0.95);
}

.ga-skip-song {
    position: absolute;
    left: 62px;
    top: calc(14px + var(--safe-top));
    width: 42px;
    height: 42px;
    border-radius: 999px;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", system-ui, sans-serif;
    border: 1px solid var(--ga-card-border);
    background: rgba(2, 6, 23, 0.92);
    color: var(--ga-text);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 45;
    pointer-events: auto;
    display: grid;
    place-items: center;
    transition: transform 120ms ease, background-color 120ms ease;
}

.ga-skip-song:hover {
    transform: translateY(-1px);
    background: rgba(15, 23, 42, 0.95);
}

.ga-settings-overlay {
    position: absolute;
    inset: 0;
    z-index: 70;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.48);
    padding: 16px;
}

.ga-settings-card {
    width: min(760px, 95vw);
    max-height: 92vh;
    overflow-y: auto;
}

/* ── Native (iOS) settings card — only applied when isNativeApp() ──────────
 * Breakpoints (landscape height):
 *   ≤ 499px  → iPhone  (tallest iPhone landscape is iPhone 14 Pro Max @ 430px)
 *   ≥ 500px  → iPad    (iPad Mini landscape starts at 744px)
 * ────────────────────────────────────────────────────────────────────────── */

/* Base: shared by all native form factors */
.ga-settings-card--native {
    overflow: hidden;
}

/* iPhone landscape — compact, card fills nearly full viewport height */
@media screen and (max-height: 499px) {
    .ga-settings-card--native {
        width: min(720px, 96vw);
        /* Use fixed height (not max-height) so the body can flex-grow into it */
        height: calc(100vh - 16px);
        padding: 10px 14px;
        gap: 6px;
    }
    .ga-settings-card--native .ga-title {
        font-size: 16px;
        margin: 0;
    }
    /* Body stretches to fill remaining card height */
    .ga-settings-card--native .ga-settings-body {
        flex: 1;
        min-height: 0;
        align-items: stretch;
        gap: 14px;
    }
    /* Columns stretch to match body height */
    .ga-settings-card--native .ga-settings-col {
        gap: 6px;
        min-height: 0;
    }
    .ga-volume-row .ga-field-label {
        font-size: 10px;
    }
    /* Test output grows to fill all remaining space in the right column */
    .ga-settings-card--native .ga-settings-test-output {
        flex: 1;
        height: auto;
        min-height: 40px;
        margin-top: 0;
        font-size: 11px;
    }
    .ga-settings-card--native .ga-button {
        padding: 7px 10px;
        font-size: 12px;
    }
    .ga-settings-card--native .ga-select {
        padding: 7px 10px;
        font-size: 12px;
    }
    .ga-settings-card--native .ga-field-label {
        font-size: 10px;
    }
}

/* iPad landscape — spacious */
@media screen and (min-height: 500px) {
    .ga-settings-card--native {
        width: min(800px, 88vw);
        max-height: 80vh;
        padding: 20px 24px;
        gap: 12px;
    }
    .ga-settings-card--native .ga-title {
        font-size: 24px;
        margin: 0 0 4px;
    }
    .ga-settings-col {
        gap: 12px;
    }
    .ga-settings-body {
        gap: 24px;
    }
    .ga-volume-row .ga-field-label {
        font-size: 13px;
    }
    .ga-settings-card--native .ga-settings-test-output {
        height: 100px;
        margin-top: 0;
    }
}

/* Two-column body used by native settings layout */
.ga-settings-body {
    display: flex;
    align-items: flex-start;
}

.ga-settings-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Volume slider row: label left, slider right */
.ga-volume-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ga-volume-row .ga-field-label {
    white-space: nowrap;
    margin-top: 0;
    flex-shrink: 0;
}

.ga-volume-slider {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    accent-color: var(--ga-accent);
}

/* Confirm dialog layered on top of the settings overlay */
.ga-confirm-overlay {
    position: absolute;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.ga-confirm-card {
    width: min(400px, 90vw);
    border: 1px solid var(--ga-card-border);
    border-radius: 12px;
    background: var(--ga-card);
    backdrop-filter: blur(6px);
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
}

.ga-confirm-message {
    color: var(--ga-text);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
    text-align: center;
}

/* Test output area in settings overlay — fixed height, Orbitron font */
.ga-settings-test-output {
    margin-top: 10px;
    height: 126px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--ga-card-border);
    background: rgba(13, 17, 23, 0.6);
    padding: 10px 12px;
    font-family: Orbitron, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.ga-settings-test-output::-webkit-scrollbar {
    width: 6px;
}

.ga-settings-test-output::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 3px;
}


.ga-output-line {
    margin-bottom: 4px;
}

.ga-output-line.ga-output-info {
    color: #94a3b8;
}

.ga-output-line.ga-output-success {
    color: #2ecc71;
}

.ga-output-line.ga-output-error {
    color: #ff5f57;
}

.ga-ui-blocker {
    position: absolute;
    inset: 0;
    z-index: 80;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: wait;
}

.ga-ui-blocker-text {
    border: 1px solid var(--ga-card-border);
    border-radius: 8px;
    background: rgba(13, 17, 23, 0.9);
    color: var(--ga-text);
    padding: 10px 14px;
    font-size: 14px;
}

@media (max-width: 820px) {
    .ga-card {
        width: 100%;
        max-height: 95vh;
        padding: 12px;
    }
}

/* DEBUG PANEL — remove for production (see debugPanel.ts) */
.ga-dbg-panel {
    display: none;
    flex-direction: column;
    position: fixed;
    top: 60px;
    right: 12px;
    width: 220px;
    max-height: 70vh;
    background: rgba(10, 14, 20, 0.92);
    border: 1px solid rgba(51, 168, 255, 0.35);
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
    color: #c9d1d9;
    z-index: 99999;
    box-shadow: 0 4px 24px rgba(0,0,0,0.7);
    overflow: hidden;
    user-select: none;
}

.ga-dbg-header {
    padding: 6px 10px;
    background: rgba(33, 168, 255, 0.12);
    border-bottom: 1px solid rgba(51, 168, 255, 0.2);
    cursor: grab;
    font-weight: bold;
    letter-spacing: 0.05em;
    color: #33a8ff;
    flex-shrink: 0;
}

.ga-dbg-header:active {
    cursor: grabbing;
}

.ga-dbg-controls {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.ga-dbg-btn {
    flex: 1;
    padding: 3px 0;
    background: rgba(51, 168, 255, 0.12);
    border: 1px solid rgba(51, 168, 255, 0.3);
    border-radius: 3px;
    color: #c9d1d9;
    font-family: monospace;
    font-size: 11px;
    cursor: pointer;
}

.ga-dbg-btn:hover {
    background: rgba(51, 168, 255, 0.25);
}

.ga-dbg-btn-save {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.35);
}

.ga-dbg-btn-save:hover {
    background: rgba(46, 204, 113, 0.25);
}

.ga-dbg-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.ga-dbg-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 10px;
    cursor: pointer;
}

.ga-dbg-row:hover {
    background: rgba(255,255,255,0.05);
}

.ga-dbg-row input[type="checkbox"] {
    accent-color: #33a8ff;
    cursor: pointer;
    flex-shrink: 0;
}

.ga-dbg-row-unknown {
    font-style: italic;
    color: #8b949e;
}

.ga-dbg-unknown {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 4px 10px 6px;
}

.ga-dbg-unknown-title {
    color: #8b949e;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.ga-dbg-unknown-item {
    font-style: italic;
    color: #6e7681;
    padding: 1px 0;
}
/* END DEBUG PANEL */

/* LEVEL LOADING SCREEN */
.ga-level-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: none;
}

.ga-level-loading-card {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: min(420px, 90vw);
    background: var(--ga-card);
    border: 1px solid var(--ga-card-border);
    border-radius: 14px;
    padding: 28px 32px;
    backdrop-filter: blur(6px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7);
}

.ga-level-loading-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 0.06em;
    color: var(--ga-accent);
    text-align: center;
}

.ga-level-loading-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ga-level-loading-label {
    font-size: 12px;
    letter-spacing: 0.04em;
    color: rgba(230, 237, 243, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ga-level-loading-pct {
    font-size: 12px;
    color: var(--ga-accent);
    font-variant-numeric: tabular-nums;
}

.ga-level-loading-bar-track {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.ga-level-loading-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: var(--ga-accent);
    border-radius: 999px;
    transition: width 120ms ease;
}

/* Indeterminate bar for the setup phase */
.ga-level-loading-bar-track--indet {
    background: rgba(255, 255, 255, 0.08);
}

.ga-level-loading-bar-indet {
    position: absolute;
    top: 0;
    height: 100%;
    width: 38%;
    background: linear-gradient(90deg, transparent, var(--ga-accent), transparent);
    border-radius: 999px;
    animation: ga-level-loading-slide 1.5s ease-in-out infinite;
}

@keyframes ga-level-loading-slide {
    0%   { left: -40%; }
    100% { left: 110%; }
}
/* END LEVEL LOADING SCREEN */

/* GFX LOADING INDICATOR */
.ga-gfx-loader {
    position: fixed;
    bottom: calc(12px + var(--safe-bottom));
    right: 12px;
    font-size: 11px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(2, 6, 23, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 3px 7px;
    z-index: 9999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 400ms ease;
}

.ga-gfx-loader--hidden {
    opacity: 0;
}
/* END GFX LOADING INDICATOR */

/* SFX LOADING INDICATOR */
.ga-sfx-loader {
    position: fixed;
    bottom: calc(12px + var(--safe-bottom));
    left: 12px;
    font-size: 11px;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(2, 6, 23, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 3px 7px;
    z-index: 9999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 400ms ease;
}

.ga-sfx-loader--hidden {
    opacity: 0;
}
/* END SFX LOADING INDICATOR */

/* HOW TO PLAY */
.ga-row--full {
    width: 100%;
}

.ga-button-half {
    flex: 1;
    width: auto;
    min-width: 0;
}

.ga-how-to-play-card {
    max-height: 80vh;
    overflow-y: auto;
}

.ga-how-to-play-list {
    margin: 0;
    padding: 0 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ga-how-to-play-item {
    font-size: 14px;
    line-height: 1.55;
    color: var(--ga-text);
}
/* END HOW TO PLAY */

/* LAST PLAYED LEVEL HIGHLIGHT */
.ga-item-last-played {
    outline: 2px solid #60c8f0;
    outline-offset: -2px;
}

/* STATUS ROW: three-column left/center/right layout */
.ga-status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.ga-status-row span:first-child  { text-align: left; flex: 1; }
.ga-status-row span:nth-child(2) { text-align: center; flex: 1; }
.ga-status-row span:last-child   { text-align: right; flex: 1; }

/* CHUNK PROGRESS BAR */
.ga-chunk-progress-track {
    flex-shrink: 0;
    height: 10px;
    border-radius: 5px;
    /* filled portion driven by --fill-pct and --fill-color CSS vars set from JS */
    background: linear-gradient(
        to right,
        var(--fill-color, #16a34a) var(--fill-pct, 0%),
        rgba(255, 255, 255, 0.12) var(--fill-pct, 0%)
    );
}
/* END CHUNK PROGRESS BAR */

/* ── iPhone landscape play screen ──────────────────────────────────────────
 * The Pixi canvas is CSS-scaled by JS so the tile grid fills the screen height.
 * The DOM sidebar floats to the right of the border frame with safe-area padding.
 * ga-play-layout--iphone overrides the fixed 1320×900 browser play layout.
 * ga-play-sidebar--iphone positions itself via inline styles set from JS.
 * ────────────────────────────────────────────────────────────────────────── */

.ga-play-layout--iphone {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    height: auto !important;
    transform: none;
}

.ga-play-sidebar--iphone {
    /* JS sets left/right/top/bottom as inline styles; override class defaults */
    position: absolute !important;
    width: auto !important;
}

/* Compact HUD fonts for the narrow iPhone sidebar */
body.native-iphone .ga-play-sidebar--iphone {
    gap: 8px; /* tighter spacing between boxes */
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-box {
    padding: 6px 8px;
    /* No outer shell panel on iPhone — raise opacity to match web-app's layered look.
       Web-app: shell rgba(13,17,23,0.7) + hud rgba(13,17,23,0.6) → combined ≈ 0.88 */
    background: rgba(13, 17, 23, 0.88);
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-box-primary {
    font-size: 12px;
    font-weight: 700;
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-level-name {
    font-size: 13px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-row {
    font-size: 15px;
    gap: 5px;
    line-height: 1.2;
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-label {
    font-size: 15px;
}

body.native-iphone .ga-play-sidebar--iphone .ga-hud-value {
    min-width: 60px;
    font-size: 15px;
}

body.native-iphone .ga-play-sidebar--iphone .ga-output-content {
    font-size: 13px;
    line-height: 1.3;
}

body.native-iphone .ga-play-sidebar--iphone .ga-output-prompt {
    font-size: 15px;
}

body.native-iphone .ga-play-sidebar--iphone .ga-play-controls-box {
    gap: 4px;
    /* Keep buttons above the home indicator while the sidebar itself sits flush. */
    padding-bottom: var(--safe-bottom, 0px);
}

body.native-iphone .ga-play-sidebar--iphone .ga-button {
    font-size: 12px;
    padding: 5px 8px;
    min-height: 28px;
}