/*! HTML5 Boilerplate v6.0.1 | MIT License | https://html5boilerplate.com/ */

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #0b67d8;
    color: #ffffff;
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
    display: none !important;
}

.tabular {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    font-variant-numeric: tabular-nums;
}

/* ==================== SKY-ISLAND ILLUSTRATED BACKDROP ==================== */

.sky-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    background: linear-gradient(180deg, #0b67d8 0%, #33aef9 55%, #9fe4ff 85%, #4cc534 100%);
}

.sky-backdrop-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

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

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

.sky-float-slow {
    animation: floatSlow 7s ease-in-out infinite;
}

.sky-float-med {
    animation: floatMed 5.5s ease-in-out infinite;
}

.sky-float-fast {
    animation: floatMed 4.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .sky-float-slow,
    .sky-float-med,
    .sky-float-fast,
    .mascot-balloon-float {
        animation: none !important;
    }
}

/* ==================== LOBBY SHELL ==================== */

.lobby-shell {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 1520px;
    margin: 0 auto;
    padding: 0 18px 10px;
}

/* ==================== TOP GLOSSY NAVIGATION BAR ==================== */

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 -18px;
    padding: 8px 24px;
    background: linear-gradient(180deg, #0b3a91 0%, #062163 55%, #041645 100%);
    border-bottom: 2px solid rgba(96, 165, 250, 0.55);
    box-shadow: 0 6px 24px rgba(3, 18, 56, 0.48), inset 0 1px 0 rgba(191, 219, 254, 0.35);
    flex-shrink: 0;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-mark {
    width: 40px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.55));
}

.brand-mark-svg {
    width: 100%;
    height: 100%;
}

.brand-wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand-main {
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
}

.brand-sub {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.32em;
    color: #93c5fd;
    margin-top: 2px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav-pill,
.nav-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    min-height: 38px;
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease, color 150ms ease;
}

.nav-link-btn:hover {
    color: #ffffff;
    background: rgba(56, 189, 248, 0.16);
}

.nav-pill-active {
    color: #ffffff;
    background: linear-gradient(180deg, #1d8cf8 0%, #0952c7 100%);
    border-color: #7dd3fc;
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.nav-ico {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-account {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.avatar-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 3px;
    background: linear-gradient(180deg, #1a4ea8 0%, #0d2c6e 100%);
    border: 2px solid #60a5fa;
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.35);
}

.avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    display: block;
    border: 2px solid #ffffff;
}

.avatar-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chev-ico {
    width: 14px;
    height: 14px;
}

.login-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    min-height: 40px;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(180deg, #2bd46c 0%, #129146 55%, #0c7435 100%);
    border: 2px solid #86efac;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(5, 46, 22, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.55);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 110ms ease, filter 140ms ease;
}

.login-pill-btn:hover {
    filter: brightness(1.07);
}

.login-pill-btn:active,
.giant-play-btn:active,
.dock-btn:active,
.step-arrow-btn:active {
    transform: translateY(1px);
}

/* ==================== CENTER ARCADE TITLE EMBLEM ==================== */

.title-emblem {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px auto 4px;
    padding: 0 18px;
    max-width: 100%;
    flex-shrink: 0;
    user-select: none;
}

.emblem-text {
    position: relative;
    z-index: 2;
    text-align: center;
    line-height: 0.94;
}

.emblem-line-1 {
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: clamp(44px, 5vw, 72px);
    font-weight: 700;
    color: #fde047;
    text-shadow:
        0 4px 0 #7c2d12,
        0 7px 14px rgba(15, 23, 42, 0.55),
        -2.5px -2.5px 0 #78350f,
        2.5px -2.5px 0 #78350f,
        -2.5px 2.5px 0 #78350f,
        2.5px 2.5px 0 #78350f;
}

.emblem-line-2 {
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: clamp(48px, 5.5vw, 78px);
    font-weight: 700;
    color: #38bdf8;
    margin-top: -4px;
    text-shadow:
        0 4px 0 #1e3a8a,
        0 8px 16px rgba(15, 23, 42, 0.55),
        -2.5px -2.5px 0 #1e3a8a,
        2.5px -2.5px 0 #1e3a8a,
        -2.5px 2.5px 0 #1e3a8a,
        2.5px 2.5px 0 #1e3a8a;
}

.emblem-ribbon {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 28px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: clamp(14px, 1.3vw, 18px);
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #ffffff;
    background: linear-gradient(180deg, #a855f7 0%, #6b21a8 100%);
    border: 2.5px solid #e9d5ff;
    border-radius: 999px;
    box-shadow: 0 5px 14px rgba(59, 7, 100, 0.48);
}

.emblem-balloons {
    position: relative;
    width: 96px;
    height: 84px;
    flex-shrink: 0;
    transform: scale(1.14);
    transform-origin: center;
}

.mini-b {
    position: absolute;
    display: block;
    border-radius: 50% 50% 48% 48%;
    border: 2px solid rgba(255, 255, 255, 0.65);
    box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.22), 0 6px 12px rgba(15, 23, 42, 0.3);
}

.mini-b-yellow {
    width: 34px;
    height: 42px;
    left: 6px;
    top: 16px;
    background: radial-gradient(circle at 30% 30%, #fef08a, #f59e0b);
    transform: rotate(-16deg);
}

.mini-b-pink {
    width: 36px;
    height: 44px;
    left: 36px;
    top: 2px;
    background: radial-gradient(circle at 30% 30%, #f9a8d4, #db2777);
    transform: rotate(-4deg);
}

.mini-b-purple {
    width: 36px;
    height: 44px;
    right: 36px;
    top: 2px;
    background: radial-gradient(circle at 30% 30%, #e9d5ff, #9333ea);
    transform: rotate(6deg);
}

.mini-b-green {
    width: 34px;
    height: 42px;
    right: 6px;
    top: 16px;
    background: radial-gradient(circle at 30% 30%, #86efac, #16a34a);
    transform: rotate(16deg);
}

.mini-star {
    position: absolute;
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.45));
}

.mini-star-green { color: #4ade80; left: 48px; bottom: 8px; }
.mini-star-cyan { color: #38bdf8; right: 48px; bottom: 8px; }
.mini-star-gold { color: #facc15; left: 26px; bottom: 0; font-size: 18px; }
.emblem-balloons-right .mini-star-gold { left: auto; right: 26px; }

/* ==================== MAIN MENU-ONLY DESKTOP HERO GRID ==================== */

body:not(.is-ingame) .lobby-grid {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(240px, 290px) minmax(250px, 320px) minmax(250px, 300px);
    grid-template-rows: auto auto;
    grid-template-areas:
        "info mascot level"
        "info play mode";
    justify-content: center;
    align-content: center;
    column-gap: clamp(20px, 3.6vw, 56px);
    row-gap: 14px;
    padding: 4px 0 8px;
}

body:not(.is-ingame) .lobby-left,
body:not(.is-ingame) .lobby-right {
    display: contents;
}

body:not(.is-ingame) .info-card {
    grid-area: info;
    align-self: center;
}

body:not(.is-ingame) .mascot-wrap {
    grid-area: mascot;
    align-self: end;
    justify-self: center;
    padding-top: 0;
}

body:not(.is-ingame) .giant-play-btn {
    grid-area: play;
    align-self: start;
}

body:not(.is-ingame) .level-select-card {
    grid-area: level;
    align-self: end;
    margin-top: 12px;
}

body:not(.is-ingame) .mode-select-card {
    grid-area: mode;
    align-self: start;
}

/* ==================== GLOSSY BLUE ARCADE CARDS ==================== */

.gloss-card {
    position: relative;
    background: linear-gradient(180deg, rgba(21, 90, 198, 0.94) 0%, rgba(10, 46, 128, 0.96) 100%);
    border: 3px solid #60a5fa;
    border-radius: 20px;
    box-shadow:
        0 10px 28px rgba(4, 21, 66, 0.48),
        inset 0 2px 0 rgba(224, 242, 254, 0.55),
        inset 0 -3px 0 rgba(3, 18, 56, 0.55);
}

/* Left Column */

.lobby-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;
    gap: 6px;
}

.info-card {
    padding: 14px 16px 14px;
}

.info-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1.5px solid rgba(147, 197, 253, 0.32);
}

.gold-star-badge {
    font-size: 24px;
    color: #facc15;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(120, 53, 15, 0.6));
}

.info-card-header h2 {
    margin: 0;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(2, 6, 23, 0.45);
}

.info-card-desc {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.42;
    color: #e0f2fe;
}

.info-feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.info-feature-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(5, 27, 82, 0.65);
    border: 1px solid rgba(125, 211, 252, 0.28);
    border-radius: 10px;
}

.feat-ico {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.feat-ico-bolt { color: #facc15; }
.feat-ico-star { color: #fde047; }
.feat-ico-shield svg { width: 19px; height: 19px; }

.mascot-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-bottom: -10px;
    pointer-events: none;
}

.mascot-svg {
    width: 100%;
    max-width: 220px;
    max-height: 205px;
    height: auto;
    filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.32));
}

.mascot-balloon-float {
    animation: floatSlow 4.2s ease-in-out infinite;
}

/* ==================== CENTER GLOSSY ARCADE CANVAS FRAME (PLAY AREA ONLY) ==================== */

.lobby-center {
    display: none;
    min-width: 0;
    min-height: 0;
    align-items: center;
    justify-content: center;
}

.arcade-frame-outer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    max-width: 820px;
    padding: 10px;
    background: linear-gradient(180deg, #5cc4ff 0%, #1d7df2 45%, #0a46b8 100%);
    border: 3px solid #bae6fd;
    border-radius: 26px;
    box-shadow:
        0 18px 46px rgba(4, 21, 66, 0.56),
        inset 0 2px 0 rgba(255, 255, 255, 0.8),
        inset 0 -4px 0 rgba(7, 36, 102, 0.6);
    gap: 6px;
}

.live-hud-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(6, 26, 78, 0.9);
    border: 1.5px solid rgba(147, 197, 253, 0.45);
    border-radius: 12px;
    font-size: 12px;
    color: #e0f2fe;
    flex-shrink: 0;
}

.live-hud-left {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 0;
}

.live-hud-stats {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.live-hud-item {
    white-space: nowrap;
}

.live-hud-item strong {
    color: #ffffff;
}

.live-hud-lives strong {
    color: #fb7185;
    letter-spacing: 1px;
}

.live-hud-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.mini-hud-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    min-height: 28px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(30, 64, 175, 0.85);
    border: 1px solid rgba(147, 197, 253, 0.5);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.mini-hud-btn:hover {
    background: rgba(37, 99, 235, 0.98);
}

.mini-hud-home {
    background: linear-gradient(180deg, #1d8cf8 0%, #0a4eb8 100%);
    border-color: #93c5fd;
}

.mini-hud-ico {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.active-powers-bar {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    max-width: calc(100% - 16px);
    padding: 5px 12px;
    background: rgba(6, 26, 78, 0.84);
    border: 1.5px solid rgba(147, 197, 253, 0.5);
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.4);
    backdrop-filter: blur(4px);
}

.power-timer {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    font-weight: 700;
}

.power-timer-val {
    font-family: "JetBrains Mono", monospace;
    color: #ffffff;
}

.power-timer-track {
    width: 68px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.power-timer-fill {
    display: block;
    height: 100%;
    border-radius: 3px;
}

.power-timer-floor .power-timer-label { color: #6ee7b7; }
.power-timer-floor .power-timer-fill { background: #10b981; }
.power-timer-wide .power-timer-label { color: #fde047; }
.power-timer-wide .power-timer-fill { background: #f59e0b; }
.power-timer-fire .power-timer-label { color: #fda4af; }
.power-timer-fire .power-timer-fill { background: #f43f5e; }

.canvas-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 18px;
    overflow: hidden;
    border: 3px solid #0b3a8c;
    background: #38bdf8;
    box-shadow: inset 0 3px 12px rgba(2, 6, 23, 0.35);
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    touch-action: none;
}

#game-canvas.is-playing {
    cursor: none;
}

.game-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(4, 20, 62, 0.66);
    backdrop-filter: blur(4px);
    z-index: 10;
}

.overlay-card {
    width: 100%;
    max-width: 440px;
    padding: 24px 24px 20px;
    background: linear-gradient(180deg, #1348a8 0%, #092568 100%);
    border: 2.5px solid #7dd3fc;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.55);
}

.overlay-kicker {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 700;
    color: #fde047;
}

.overlay-title {
    margin: 0 0 8px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
}

.overlay-desc {
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #e0f2fe;
}

.overlay-stats {
    margin: 0 0 16px;
    font-family: "JetBrains Mono", monospace;
    font-size: 13px;
    color: #fde047;
}

.overlay-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.overlay-btn {
    padding: 10px 20px;
    min-height: 42px;
    font-size: 14px;
    font-weight: 700;
    border-radius: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.overlay-btn-primary {
    background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
    border: 2px solid #bbf7d0;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(20, 83, 45, 0.45);
}

.overlay-btn-secondary {
    background: rgba(15, 23, 42, 0.72);
    border: 2px solid #60a5fa;
    color: #ffffff;
}

/* ==================== RIGHT COLUMN: LEVEL, MODE & GIANT PLAY ==================== */

.lobby-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    min-height: 0;
}

.level-select-card {
    padding: 22px 14px 12px;
    margin-top: 10px;
}

.card-tab-badge {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 16px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #451a03;
    background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
    border: 2px solid #fef9c3;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(69, 26, 3, 0.4);
    white-space: nowrap;
}

.tab-ico {
    width: 16px;
    height: 16px;
}

.level-stepper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.step-arrow-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
    border: 2px solid #bae6fd;
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(3, 18, 56, 0.42);
}

.step-arrow-btn svg {
    width: 20px;
    height: 20px;
}

.step-arrow-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.level-display-btn {
    flex: 1 1 auto;
    min-height: 40px;
    padding: 6px 10px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(5, 22, 68, 0.78);
    border: 1.5px solid rgba(125, 211, 252, 0.42);
    border-radius: 12px;
    cursor: pointer;
}

.level-display-btn:hover {
    border-color: #fde047;
}

.level-sub-hint {
    margin: 7px 0 0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #bae6fd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Choose Mode Card */

.mode-select-card {
    padding: 12px 14px 14px;
}

.mode-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.mode-hdr-ico {
    width: 22px;
    height: 22px;
    color: #ffffff;
}

.mode-card-header h2 {
    margin: 0;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: #fde047;
    text-shadow: 0 2px 4px rgba(2, 6, 23, 0.45);
}

.mode-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 12px 8px;
    min-height: 82px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    color: #cbd5e1;
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.72) 0%, rgba(15, 36, 94, 0.85) 100%);
    border: 2px solid rgba(147, 197, 253, 0.42);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 110ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.mode-tile:hover {
    border-color: #93c5fd;
    color: #ffffff;
}

.mode-tile-active {
    color: #ffffff;
    background: linear-gradient(180deg, #4ade80 0%, #16a34a 60%, #15803d 100%);
    border-color: #dcfce7;
    box-shadow: 0 0 18px rgba(74, 222, 128, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.55);
}

.mode-tile-ico {
    width: 28px;
    height: 28px;
}

/* Giant Glossy Green Play Button */

.giant-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 76px;
    padding: 12px 24px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 36px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 3px 0 #14532d, 0 5px 10px rgba(2, 6, 23, 0.45);
    background: linear-gradient(180deg, #a3f757 0%, #38c928 45%, #168a1b 100%);
    border: 4px solid #ecfccb;
    border-radius: 26px;
    box-shadow:
        0 8px 0 #14532d,
        0 14px 28px rgba(4, 21, 66, 0.52),
        inset 0 4px 0 rgba(255, 255, 255, 0.65);
    cursor: pointer;
    transition: transform 110ms ease, filter 140ms ease;
}

.giant-play-btn:hover {
    filter: brightness(1.06);
}

.play-tri {
    font-size: 30px;
    line-height: 1;
}

/* ==================== BOTTOM DOCK (HOME | SCORE BAR | SETTINGS) ==================== */

.bottom-dock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-top: 6px;
    flex-shrink: 0;
}

.dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-width: 138px;
    min-height: 46px;
    padding: 8px 20px;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(4, 21, 66, 0.46), inset 0 2px 0 rgba(255, 255, 255, 0.48);
    transition: transform 110ms ease, filter 140ms ease;
}

.dock-btn:hover {
    filter: brightness(1.08);
}

.dock-btn-home {
    background: linear-gradient(180deg, #1d8cf8 0%, #094db5 100%);
    border: 2.5px solid #93c5fd;
}

.dock-btn-settings {
    background: linear-gradient(180deg, #a855f7 0%, #6b21a8 100%);
    border: 2.5px solid #e9d5ff;
}

.dock-ico {
    width: 22px;
    height: 22px;
}

.score-pill-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 6px 30px;
    min-width: 390px;
    background: linear-gradient(180deg, #1352b8 0%, #07286e 100%);
    border: 3px solid #60a5fa;
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(4, 21, 66, 0.5), inset 0 2px 0 rgba(191, 219, 254, 0.5);
}

.score-pill-half {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trophy-badge,
.star-badge {
    font-size: 26px;
    line-height: 1;
    filter: drop-shadow(0 2px 5px rgba(2, 6, 23, 0.45));
}

.star-badge {
    color: #facc15;
}

.score-pill-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.score-pill-label {
    font-size: 12px;
    font-weight: 700;
    color: #bae6fd;
}

.score-pill-val {
    font-size: 21px;
    font-weight: 700;
    color: #fde047;
}

.score-pill-divider {
    width: 2px;
    height: 34px;
    background: rgba(147, 197, 253, 0.32);
}

/* ==================== FOCUS STATES ==================== */

button:focus-visible,
input:focus-visible {
    outline: 3px solid #fde047;
    outline-offset: 2px;
}

/* ==================== MODALS ==================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 10, 34, 0.78);
    backdrop-filter: blur(5px);
}

.modal-panel {
    width: 100%;
    max-width: 640px;
    max-height: 88vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #102a63 0%, #09183e 100%);
    color: #e2e8f0;
    border: 2.5px solid #60a5fa;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-panel-wide {
    max-width: 860px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid rgba(147, 197, 253, 0.25);
}

.modal-header h2 {
    margin: 0;
    font-family: "Fredoka", system-ui, sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
}

.modal-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: #bae6fd;
}

.modal-close {
    padding: 7px 14px;
    min-height: 36px;
    background: rgba(30, 58, 138, 0.85);
    color: #ffffff;
    border: 1.5px solid #60a5fa;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

.modal-panel h3 {
    margin: 14px 0 6px;
    font-size: 14px;
    font-weight: 700;
    color: #fde047;
}

.modal-panel p,
.modal-panel li {
    font-size: 13px;
    line-height: 1.55;
    color: #e0f2fe;
}

.modal-panel a {
    color: #7dd3fc;
    text-decoration: underline;
}

.modal-panel pre {
    white-space: pre-wrap;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 11px;
    line-height: 1.48;
    background: rgba(2, 6, 23, 0.72);
    color: #cbd5e1;
    border: 1px solid rgba(147, 197, 253, 0.25);
    border-radius: 10px;
    padding: 12px;
    margin: 10px 0;
}

/* 50-Level Grid */

.level-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.level-world-heading {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #fde047;
}

.level-cards-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.level-card-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 10px;
    min-height: 58px;
    background: rgba(15, 42, 104, 0.85);
    border: 1.5px solid rgba(125, 211, 252, 0.35);
    border-radius: 10px;
    color: #ffffff;
    text-align: left;
    cursor: pointer;
    transition: transform 100ms ease, border-color 140ms ease;
}

.level-card-btn:hover {
    border-color: #fde047;
    transform: translateY(-1px);
}

.level-card-btn.is-current {
    border-color: #38bdf8;
    background: rgba(14, 165, 233, 0.3);
}

.level-card-btn.is-cleared {
    border-color: #4ade80;
}

.level-card-num {
    font-family: "JetBrains Mono", monospace;
    font-size: 12px;
    font-weight: 700;
    color: #fde047;
}

.level-card-name {
    font-size: 12px;
    font-weight: 600;
    color: #e0f2fe;
    line-height: 1.25;
}

.level-card-btn.is-locked {
    background: rgba(8, 22, 58, 0.7);
    border-color: rgba(100, 116, 139, 0.38);
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.65;
}

.level-card-btn.is-locked:hover {
    border-color: rgba(100, 116, 139, 0.38);
    transform: none;
}

.level-card-num-locked {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #94a3b8;
}

.level-card-btn.is-locked .level-card-name {
    color: #64748b;
}

.lock-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* Settings, Board Skins, Login & Leaderboard */

.settings-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 14px;
    background: rgba(6, 24, 68, 0.72);
    border: 1px solid rgba(147, 197, 253, 0.25);
    border-radius: 12px;
}

.settings-row-stack {
    flex-direction: column;
    align-items: stretch;
}

.settings-sub {
    margin: 2px 0 0;
    font-size: 12px;
    color: #93c5fd;
}

.hud-btn {
    padding: 8px 14px;
    min-height: 36px;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    background: #1d4ed8;
    border: 1.5px solid #60a5fa;
    border-radius: 9px;
    cursor: pointer;
    white-space: nowrap;
}

.hud-btn-danger {
    background: #be123c;
    border-color: #fda4af;
}

.board-skin-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.board-skin-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 6px;
    background: rgba(15, 42, 104, 0.8);
    border: 2px solid rgba(147, 197, 253, 0.35);
    border-radius: 10px;
    color: #e0f2fe;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.board-skin-btn.is-active {
    border-color: #fde047;
    background: rgba(29, 78, 216, 0.55);
    color: #ffffff;
}

.skin-swatch {
    width: 56px;
    height: 14px;
    border-radius: 999px;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
}

.skin-turbo   { background: linear-gradient(90deg, #e2e8f0, #f97316, #facc15, #f97316, #e2e8f0); }
.skin-royal   { background: linear-gradient(90deg, #fde047, #6366f1, #f43f5e, #6366f1, #fde047); }
.skin-cyber   { background: linear-gradient(90deg, #06b6d4, #0f172a, #38bdf8, #0f172a, #06b6d4); }
.skin-party   { background: linear-gradient(90deg, #f43f5e, #facc15, #22c55e, #38bdf8, #a855f7); }
.skin-dragon  { background: linear-gradient(90deg, #fde047, #10b981, #047857, #10b981, #fde047); }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-label {
    font-size: 13px;
    font-weight: 700;
    color: #bae6fd;
}

.form-input {
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(2, 6, 23, 0.65);
    border: 2px solid #60a5fa;
    border-radius: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(6, 24, 68, 0.78);
    border: 1px solid rgba(147, 197, 253, 0.28);
    border-radius: 10px;
    font-size: 13px;
}

.lb-rank {
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
    color: #fde047;
    margin-right: 10px;
}

.lb-score {
    font-family: "JetBrains Mono", monospace;
    font-weight: 700;
    color: #4ade80;
}

/* ==================== FULL PLAY AREA MODE (IN-GAME) ==================== */

html:has(body.is-ingame),
body.is-ingame {
    height: 100dvh;
    overflow: hidden;
}

body.is-ingame .top-nav,
body.is-ingame .title-emblem,
body.is-ingame .lobby-left,
body.is-ingame .lobby-right,
body.is-ingame .bottom-dock {
    display: none !important;
}

body.is-ingame .lobby-shell {
    max-width: none;
    width: 100%;
    height: 100dvh;
    min-height: 0;
    padding: 8px;
}

body.is-ingame .lobby-grid {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    gap: 0;
    justify-content: stretch;
    align-items: stretch;
}

body.is-ingame .lobby-center {
    display: flex !important;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
}

body.is-ingame .arcade-frame-outer {
    width: min(100%, calc((100dvh - 68px) * 900 / 680 + 24px));
    height: 100%;
    max-width: 100%;
    padding: 8px;
    border-radius: 20px;
    gap: 6px;
}

body.is-ingame .canvas-stage {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 14px;
}

body.is-ingame #game-canvas {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

/* ==================== RESPONSIVE (SINGLE-SCREEN TABLET & MOBILE) ==================== */

/* Compact 3-column single-screen layout for Tablet Landscape & shorter laptops */
@media (max-width: 1260px), (max-height: 780px) {
    html,
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .lobby-shell {
        height: 100dvh;
        padding: 0 12px 6px;
    }

    .top-nav {
        margin: 0 -12px;
        padding: 5px 14px;
        gap: 10px;
    }

    .brand-mark {
        width: 32px;
        height: 26px;
    }

    .brand-main {
        font-size: 15px;
    }

    .brand-sub {
        font-size: 8px;
        letter-spacing: 0.24em;
    }

    .nav-links {
        gap: 6px;
    }

    .nav-pill,
    .nav-link-btn {
        padding: 5px 12px;
        min-height: 30px;
        font-size: 12px;
        gap: 5px;
    }

    .nav-ico {
        width: 15px;
        height: 15px;
    }

    .avatar-chip {
        padding: 2px 6px 2px 2px;
    }

    .avatar-circle {
        width: 28px;
        height: 28px;
    }

    .login-pill-btn {
        padding: 5px 12px;
        min-height: 32px;
        font-size: 12px;
        gap: 6px;
    }

    .title-emblem {
        margin: 4px auto 2px;
        padding: 0 10px;
        gap: 6px;
    }

    .emblem-line-1 {
        font-size: clamp(32px, 4.4vw, 52px);
    }

    .emblem-line-2 {
        font-size: clamp(35px, 4.8vw, 56px);
    }

    .emblem-ribbon {
        margin-top: 4px;
        padding: 3px 20px;
        font-size: 13px;
    }

    .emblem-balloons {
        width: 78px;
        height: 68px;
        transform: scale(0.92);
        transform-origin: center;
    }

    body:not(.is-ingame) .lobby-grid {
        grid-template-columns: minmax(200px, 245px) minmax(210px, 270px) minmax(210px, 255px);
        column-gap: clamp(14px, 2.8vw, 36px);
        row-gap: 10px;
        padding: 2px 0 4px;
    }

    .info-card {
        padding: 10px 12px 9px;
        border-width: 2px;
        border-radius: 15px;
    }

    .info-card-header {
        margin-bottom: 5px;
        gap: 6px;
    }

    .info-card-header h2 {
        font-size: 15px;
    }

    .info-card-copy {
        font-size: 11px;
        line-height: 1.35;
        margin-bottom: 6px;
    }

    .info-feature-list {
        gap: 5px;
    }

    .info-feature-row {
        padding: 4px 7px;
        font-size: 11px;
        gap: 6px;
    }

    .feat-badge {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }

    .mascot-svg {
        max-width: 155px;
        max-height: 140px;
    }

    .arcade-frame-outer {
        padding: 7px;
        border-radius: 18px;
    }

    .lobby-right {
        gap: 8px;
    }

    .level-select-card {
        padding: 14px 10px 8px;
        margin-top: 6px;
        border-width: 2px;
        border-radius: 15px;
    }

    .card-tab-badge {
        top: -12px;
        padding: 3px 11px;
        font-size: 12px;
        border-radius: 9px;
    }

    .tab-ico {
        width: 13px;
        height: 13px;
    }

    .step-arrow-btn {
        width: 30px;
        height: 30px;
    }

    .step-arrow-btn svg {
        width: 16px;
        height: 16px;
    }

    .level-display-btn {
        min-height: 32px;
        padding: 4px 6px;
        font-size: 15px;
        border-radius: 10px;
    }

    .level-sub-hint {
        margin-top: 4px;
        font-size: 10.5px;
    }

    .mode-select-card {
        padding: 8px 10px 9px;
        border-width: 2px;
        border-radius: 15px;
    }

    .mode-card-header {
        margin-bottom: 6px;
        gap: 5px;
    }

    .mode-hdr-ico {
        width: 16px;
        height: 16px;
    }

    .mode-card-header h2 {
        font-size: 13.5px;
    }

    .mode-buttons-grid {
        gap: 6px;
    }

    .mode-tile {
        min-height: 54px;
        padding: 6px 4px;
        gap: 3px;
        font-size: 11px;
        border-radius: 11px;
    }

    .mode-tile-ico {
        width: 20px;
        height: 20px;
    }

    .giant-play-btn {
        min-height: 52px;
        padding: 8px 16px;
        gap: 8px;
        font-size: 25px;
        border-width: 3px;
        border-radius: 20px;
        box-shadow:
            0 5px 0 #14532d,
            0 10px 20px rgba(4, 21, 66, 0.45),
            inset 0 3px 0 rgba(255, 255, 255, 0.65);
    }

    .play-tri {
        font-size: 21px;
    }

    .bottom-dock {
        padding-top: 4px;
        gap: 10px;
    }

    .dock-btn {
        min-width: 102px;
        min-height: 36px;
        padding: 5px 14px;
        font-size: 13.5px;
        gap: 6px;
        border-width: 2px;
    }

    .dock-ico {
        width: 17px;
        height: 17px;
    }

    .score-pill-bar {
        min-width: 0;
        padding: 4px 18px;
        gap: 16px;
        border-width: 2px;
    }

    .score-pill-half {
        gap: 7px;
    }

    .trophy-badge,
    .star-badge {
        font-size: 19px;
    }

    .score-pill-label {
        font-size: 10px;
    }

    .score-pill-val {
        font-size: 16px;
    }

    .score-pill-divider {
        height: 24px;
    }
}

/* Single-Screen Vertical Layout for Mobile & Portrait Tablets (Play at top, zero bottom scroll) */
@media (max-width: 960px), (max-width: 1080px) and (orientation: portrait) {
    html,
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .lobby-shell {
        height: 100dvh;
        min-height: 0;
        padding: 0 10px 8px;
        gap: 4px;
        overflow: hidden;
    }

    .top-nav {
        flex-wrap: wrap;
        margin: 0 -10px;
        padding: 5px 10px;
        gap: 5px 8px;
        justify-content: space-between;
    }

    .brand-mark {
        width: 28px;
        height: 22px;
    }

    .brand-main {
        font-size: 14px;
    }

    .brand-sub {
        font-size: 7.5px;
        letter-spacing: 0.2em;
    }

    .nav-account {
        gap: 5px;
    }

    .avatar-circle {
        width: 25px;
        height: 25px;
    }

    .login-pill-btn {
        padding: 4px 10px;
        min-height: 28px;
        font-size: 11px;
        gap: 5px;
    }

    .nav-links {
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }

    .nav-pill,
    .nav-link-btn {
        padding: 4px 10px;
        min-height: 26px;
        font-size: 11px;
        gap: 4px;
    }

    .nav-ico {
        width: 13px;
        height: 13px;
    }

    /* Big Responsive Title Emblem that fits cleanly on every mobile & tablet screen */
    .title-emblem {
        margin: 6px auto 2px;
        padding: 0 4px;
        gap: 4px;
    }

    .emblem-line-1 {
        font-size: clamp(30px, 9.2vw, 54px);
        text-shadow:
            0 3px 0 #7c2d12,
            0 5px 10px rgba(15, 23, 42, 0.5),
            -2px -2px 0 #78350f,
            2px -2px 0 #78350f,
            -2px 2px 0 #78350f,
            2px 2px 0 #78350f;
    }

    .emblem-line-2 {
        font-size: clamp(33px, 10vw, 60px);
        margin-top: -3px;
        text-shadow:
            0 3px 0 #1e3a8a,
            0 5px 10px rgba(15, 23, 42, 0.5),
            -2px -2px 0 #1e3a8a,
            2px -2px 0 #1e3a8a,
            -2px 2px 0 #1e3a8a,
            2px 2px 0 #1e3a8a;
    }

    .emblem-ribbon {
        margin-top: 4px;
        padding: 3px 16px;
        font-size: clamp(11px, 3vw, 15px);
        border-width: 2px;
    }

    .emblem-balloons {
        width: clamp(50px, 13vw, 84px);
        height: clamp(46px, 12vw, 74px);
        transform: scale(0.76);
        transform-origin: center;
    }

    /* Menu-Only Vertical Dashboard: Play button FIRST at top, Level + Mode side-by-side */
    body:not(.is-ingame) .lobby-grid {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 10px;
        max-width: 500px;
        width: 100%;
        margin: 0 auto;
        padding: 4px 0;
    }

    body:not(.is-ingame) .lobby-left,
    body:not(.is-ingame) .mascot-wrap {
        display: none;
    }

    body:not(.is-ingame) .lobby-right {
        order: -1;
        flex-shrink: 0;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 9px;
        align-items: stretch;
    }

    body:not(.is-ingame) .giant-play-btn,
    body:not(.is-ingame) .level-select-card,
    body:not(.is-ingame) .mode-select-card {
        grid-area: auto;
        align-self: stretch;
    }

    .giant-play-btn {
        order: -1;
        grid-column: 1 / -1;
        min-height: 50px;
        padding: 8px 18px;
        gap: 8px;
        font-size: 24px;
        border-width: 3px;
        border-radius: 18px;
        box-shadow:
            0 5px 0 #14532d,
            0 8px 18px rgba(4, 21, 66, 0.48),
            inset 0 3px 0 rgba(255, 255, 255, 0.65);
    }

    .play-tri {
        font-size: 20px;
    }

    .level-select-card {
        min-width: 0;
        margin-top: 6px;
        padding: 14px 10px 8px;
        border-width: 2px;
        border-radius: 14px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .card-tab-badge {
        top: -11px;
        padding: 2px 10px;
        font-size: 11px;
        border-width: 1.5px;
        border-radius: 8px;
        gap: 4px;
    }

    .tab-ico {
        width: 11px;
        height: 11px;
    }

    .level-stepper {
        gap: 5px;
    }

    .step-arrow-btn {
        width: 28px;
        height: 28px;
        border-width: 1.5px;
    }

    .step-arrow-btn svg {
        width: 15px;
        height: 15px;
    }

    .level-display-btn {
        min-width: 0;
        min-height: 30px;
        padding: 3px 5px;
        font-size: 14px;
        border-radius: 8px;
        white-space: nowrap;
    }

    .level-sub-hint {
        margin-top: 4px;
        font-size: 10px;
    }

    .mode-select-card {
        min-width: 0;
        margin-top: 6px;
        padding: 8px 8px 8px;
        border-width: 2px;
        border-radius: 14px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .mode-card-header {
        gap: 4px;
        margin-bottom: 5px;
    }

    .mode-hdr-ico {
        width: 14px;
        height: 14px;
    }

    .mode-card-header h2 {
        font-size: 12px;
    }

    .mode-buttons-grid {
        gap: 6px;
    }

    .mode-tile {
        min-height: 44px;
        padding: 4px 4px;
        gap: 2px;
        font-size: 10px;
        border-width: 1.5px;
        border-radius: 10px;
    }

    .mode-tile-ico {
        width: 17px;
        height: 17px;
    }

    /* Clean Compact Non-Overlapping Bottom Dock */
    .bottom-dock {
        gap: 6px;
        padding-top: 2px;
        flex-shrink: 0;
    }

    .dock-btn {
        min-width: 0;
        min-height: 36px;
        padding: 4px 10px;
        gap: 5px;
        font-size: 12px;
        border-width: 2px;
        flex-shrink: 0;
    }

    .dock-ico {
        width: 15px;
        height: 15px;
        flex-shrink: 0;
    }

    .score-pill-bar {
        min-width: 0;
        flex: 1 1 auto;
        padding: 4px 10px;
        gap: 8px;
        border-width: 2px;
        overflow: hidden;
    }

    .score-pill-half {
        gap: 5px;
        min-width: 0;
    }

    .trophy-badge,
    .star-badge {
        font-size: 15px;
        flex-shrink: 0;
    }

    .score-pill-label {
        font-size: 9px;
        white-space: nowrap;
    }

    .score-pill-val {
        font-size: 13.5px;
    }

    .score-pill-divider {
        width: 1.5px;
        height: 20px;
        flex-shrink: 0;
    }

    .level-cards-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .board-skin-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Full Play Area mobile/tablet polish */
    body.is-ingame .lobby-shell {
        padding: 4px;
        height: 100dvh;
        min-height: 0;
        gap: 0;
    }

    body.is-ingame .arcade-frame-outer {
        width: 100%;
        padding: 5px;
        border-radius: 14px;
        gap: 5px;
    }

    body.is-ingame .live-hud-strip {
        padding: 5px 8px;
        gap: 5px 8px;
        border-radius: 10px;
        font-size: 11px;
    }

    body.is-ingame .live-hud-world-wrap {
        display: none;
    }

    body.is-ingame .live-hud-actions {
        width: 100%;
        justify-content: flex-end;
    }

    body.is-ingame .mini-hud-btn {
        padding: 3px 8px;
        min-height: 26px;
        font-size: 11px;
    }

    body.is-ingame .canvas-stage {
        aspect-ratio: auto;
        max-height: none;
        border-radius: 10px;
    }
}

/* Stack nav links neatly on row 2 only when screen is narrow (< 680px) */
@media (max-width: 680px) {
    .nav-links {
        width: 100%;
        order: 3;
    }
}

@media (max-width: 390px) {
    .emblem-balloons {
        width: 48px;
        height: 44px;
        transform: scale(0.62);
    }

    .dock-btn {
        padding: 4px 8px;
        font-size: 11px;
        gap: 4px;
    }

    .score-pill-bar {
        padding: 4px 8px;
        gap: 6px;
    }

    .score-pill-label {
        font-size: 8.5px;
    }

    .score-pill-val {
        font-size: 12.5px;
    }
}

@media (max-width: 355px) {
    .dock-btn span {
        display: none;
    }

    .dock-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }
}

/* Safety fallback for ultra-short horizontal screens (e.g. phone rotated sideways) */
@media (max-height: 500px) {
    html:not(:has(body.is-ingame)),
    body:not(.is-ingame) {
        height: auto;
        overflow-y: auto;
    }

    body:not(.is-ingame) .lobby-shell {
        height: auto;
        overflow: visible;
    }

    body:not(.is-ingame) .canvas-stage {
        min-height: 180px;
    }
}
