/* === SECURE DEMO VERSION ===
   CSS remains readable for buyers. Security-focused script behavior lives in script.js. */

:root {
    --p1-color: #00A2FF;
    --p1-dark: #0077BA;
    --p2-color: #FF4D4D;
    --p2-dark: #B32A00;
    --chip-color: #F2F2F2;
    --chip-shadow: #999999;
    --bg-color: #232527;
    --stud-color: rgba(0,0,0,0.1);
    --accent: #FFD700;
    --success: #00b06f;
    --danger: #f44336;
    --hud-overlay-edge: 10px;
    --hud-overlay-top: max(10px, calc(env(safe-area-inset-top) + 6px));
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--stud-color) 15%, transparent 16%);
    background-size: 20px 20px;
    font-family: 'Oxanium', sans-serif;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- SPLASH SCREEN --- */
#splash-screen {
    position: fixed;
    inset: 0;
    background-color: #111;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out;
}

.splash-logo { font-size: clamp(3rem, 12vw, 5rem); animation: bounce 1s infinite alternate; }
.splash-art-frame {
    width: min(78vw, 340px);
    aspect-ratio: 3 / 2;
    margin-top: 16px;
    border-radius: 24px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.14);
    box-shadow:
        0 16px 36px rgba(0,0,0,0.42),
        0 0 0 6px rgba(255, 215, 0, 0.08);
    background: rgba(255,255,255,0.04);
}
.splash-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.splash-text {
    font-size: clamp(1.8rem, 7vw, 2.8rem);
    color: var(--accent);
    font-weight: bold;
    margin-top: 20px;
    text-align: center;
    padding: 0 20px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}
.splash-loader {
    margin-top: 30px;
    width: 50px;
    height: 50px;
    border: 5px solid #333;
    border-top: 5px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-20px); } }

/* --- UI CONTAINER --- */
#game-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    background: rgba(0,0,0,0.1);
}

@media (min-width: 501px) {
    #game-container {
        height: 95vh;
        max-height: 900px;
        border: 4px solid #444;
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 0 30px rgba(0,0,0,0.5);
    }
}

/* --- HUD --- */
.hud-panel {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 30, 30, 0.95);
    border-bottom: 2px solid rgba(255,255,255,0.1);
    z-index: 10;
    min-height: 52px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    flex-shrink: 0;
    position: relative;
    transition: background 0.3s;
}

#p2-panel {
    padding-top: max(10px, env(safe-area-inset-top));
    border-bottom: 4px solid rgba(0,0,0,0.3);
}

.hud-bottom {
    border-bottom: none;
    border-top: 4px solid rgba(0,0,0,0.3);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: clamp(0.9rem, 3.5vw, 1.15rem);
    font-weight: 700;
    text-shadow: 2px 2px 0px #000;
    letter-spacing: 0.5px;
    min-width: 0;
}

.avatar {
    width: clamp(28px, 8vw, 35px);
    height: clamp(28px, 8vw, 35px);
    border-radius: 50%;
    border: 2px solid white;
    background-color: #ddd;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.hearts {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.heart {
    font-size: clamp(0.9rem, 3.5vw, 1.2rem);
    filter: drop-shadow(2px 2px 0 #000);
    transition: transform 0.25s;
}
.heart.lost {
    filter: grayscale(1) opacity(0.3);
    transform: scale(0.8);
}
.heart.pulse { animation: heartPulse 0.4s; }
@keyframes heartPulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* Turn indicator arrow */
.turn-arrow {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.4rem;
    color: white;
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.8));
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
#p1-panel .turn-arrow { top: -6px; }
#p2-panel .turn-arrow { bottom: -6px; transform: translateX(-50%) rotate(180deg); }
.hud-panel.turn-highlight .turn-arrow {
    opacity: 1;
    animation: bounceArrow 1s infinite;
}
@keyframes bounceArrow {
    0%,100% { margin-top: 0; }
    50% { margin-top: -4px; }
}

/* --- STATUS BAR --- */
#game-status-bar {
    text-align: center;
    padding: 6px 8px;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    flex-wrap: wrap;
}

#turn-text {
    font-size: clamp(0.9rem, 3.5vw, 1.15rem);
    font-weight: 800;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 1px;
    order: 1;
    flex: 1 1 100%;
    text-align: center;
}

#timer-container {
    flex: 1 1 auto;
    max-width: 180px;
    height: 10px;
    background: #444;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #fff;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    order: 2;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background: #00ff00;
    transition: width 1s linear, background 0.3s;
}

#timer-text {
    font-size: clamp(0.7rem, 2.5vw, 0.85rem);
    color: #ddd;
    font-weight: 600;
    min-width: 28px;
    order: 3;
}

#score-display {
    font-size: clamp(0.8rem, 2.8vw, 1.05rem);
    font-weight: bold;
    color: var(--accent);
    order: 4;
    min-width: 60px;
}

#score-display.score-bump { animation: scoreBump 0.4s; }
@keyframes scoreBump {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.2); color: #fff; }
}

/* Combo badge */
#combo-badge {
    position: absolute;
    top: var(--hud-overlay-top);
    right: calc(var(--hud-overlay-edge) + 48px);
    background: linear-gradient(135deg, #ff6b00, #ff0066);
    color: white;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    box-shadow: 0 2px 8px rgba(255,0,102,0.6);
    z-index: 130;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s cubic-bezier(.17,.67,.52,1.5);
    pointer-events: none;
    max-width: calc(100% - 120px);
    white-space: nowrap;
}
#combo-badge.active {
    opacity: 1;
    transform: scale(1);
    animation: comboPulse 0.6s infinite alternate;
}
@keyframes comboPulse {
    from { box-shadow: 0 2px 8px rgba(255,0,102,0.6); }
    to { box-shadow: 0 2px 20px rgba(255,165,0,0.9); }
}

/* --- GAME BOARD --- */
#board-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(6px, 2vw, 12px);
    overflow: hidden;
    min-height: 0;
    position: relative;
}

#grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: clamp(3px, 1.2vmin, 8px);
    width: 100%;
    max-width: min(82vmin, 440px);
    max-height: min(82vmin, 440px);
    aspect-ratio: 1/1;
    background-color: #5D4037;
    background-image: url('assets/table.jpg');
    background-size: cover;
    background-position: center;
    padding: clamp(6px, 2vmin, 12px);
    border-radius: 12px;
    border: clamp(4px, 1.2vmin, 8px) solid #3E2723;
    box-shadow:
        inset 0 0 40px rgba(0,0,0,0.7),
        0 10px 30px rgba(0,0,0,0.8);
}

.chip {
    background-color: var(--chip-color);
    border-radius: 6px;
    border-bottom: clamp(2px, 0.6vmin, 5px) solid var(--chip-shadow);
    cursor: pointer;
    position: relative;
    transition: transform 0.08s, background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 4vmin, 2rem);
    overflow: visible;
}

.chip:active:not(.eaten) {
    transform: translateY(3px);
    border-bottom-width: 2px;
}

.chip-content {
    pointer-events: none;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    overflow: hidden;
    border-radius: inherit;
}

.chip.eaten {
    background-color: #333;
    border-bottom: 2px solid #111;
    transform: translateY(3px);
    cursor: default;
    box-shadow: inset 0 0 5px black;
}
.chip.eaten .chip-content { display: none; }

.chip.bomb-reveal {
    background-color: #ffcccb;
    border-color: #d32f2f;
    animation: popUpSimple 0.4s;
}
.chip.own-bomb-reveal {
    background-color: #FFF3B0;
    border-color: #B29600;
}
.chip.shield-hit { background-color: #B3E5FC; }

.chip.setup-selected {
    background-color: var(--accent);
    border-bottom-color: #B29600;
    animation: bombPlace 0.2s;
}
@keyframes bombPlace {
    0% { transform: scale(0.85); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.chip.radar-hint {
    animation: radarGlow 2s ease-out;
}
@keyframes radarGlow {
    0%,100% { box-shadow: 0 0 0 rgba(0,255,0,0); }
    20%,60% { box-shadow: 0 0 20px rgba(0,255,0,0.9); border-color: #0f0; }
}

@keyframes popUpSimple {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* --- OVERLAYS --- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transition: opacity 0.3s;
    overflow-y: auto;
}

#screen-menu {
    background-color: #2c3e50;
    background-image:
        linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.85)),
        url('assets/menu.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#screen-intermission, #screen-gameover {
    background: rgba(15, 15, 15, 0.98);
}

#screen-instructions {
    background: rgba(15, 15, 15, 0.98);
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
}
.instructions-scroll {
    flex: 1;
    overflow-y: auto;
    padding: max(16px, env(safe-area-inset-top)) 20px 10px;
    text-align: left;
    -webkit-overflow-scrolling: touch;
}
#screen-instructions h1 { text-align: center; margin-top: 0; }
#screen-instructions h2 {
    color: var(--p1-color);
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    margin-top: 16px;
    margin-bottom: 8px;
}
#screen-instructions h3 {
    color: var(--accent);
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    margin-top: 12px;
    margin-bottom: 6px;
}
#screen-instructions ul { padding-left: 20px; line-height: 1.5; }
#screen-instructions li { margin-bottom: 6px; color: #ddd; font-size: clamp(0.9rem, 3vw, 1rem); }
#screen-instructions p { color: #ddd; line-height: 1.5; margin-bottom: 12px; font-size: clamp(0.9rem, 3vw, 1rem); }
.instructions-footer {
    padding: 10px 20px max(10px, env(safe-area-inset-bottom));
    background: rgba(0,0,0,0.8);
    text-align: center;
    flex-shrink: 0;
}

.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

h1 {
    font-size: clamp(1.6rem, 7vw, 2.8rem);
    color: var(--accent);
    text-shadow: 3px 3px 0px #000;
    margin-bottom: 10px;
    line-height: 1.1;
}

.menu-logo {
    width: min(92%, 460px);
    min-height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: 24px;
    border: 2px solid rgba(255,255,255,0.18);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
        radial-gradient(circle at top left, rgba(255, 214, 102, 0.22), transparent 40%),
        rgba(10, 10, 10, 0.38);
    box-shadow:
        0 10px 28px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.18);
}

.menu-logo-mark {
    font-size: clamp(2rem, 8vw, 3.2rem);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
    flex-shrink: 0;
}

.menu-logo-title {
    display: block;
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 0.95;
    color: #FFE5A7;
    text-align: left;
    text-shadow:
        0 3px 0 rgba(112, 32, 0, 0.95),
        0 8px 18px rgba(0,0,0,0.45);
}

.menu-hero-card {
    width: min(92%, 360px);
    aspect-ratio: 3 / 2;
    margin-bottom: 14px;
    border-radius: 22px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.18);
    background: rgba(8, 8, 8, 0.34);
    box-shadow:
        0 12px 28px rgba(0,0,0,0.36),
        inset 0 1px 0 rgba(255,255,255,0.14);
}

.menu-hero-art {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

p {
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    color: #ccc;
    margin-bottom: 16px;
    max-width: 400px;
    line-height: 1.4;
}

/* Menu button grid */
.menu-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 18px;
}
.menu-buttons .btn-3d {
    margin: 0;
    padding: 12px 8px;
    font-size: clamp(0.85rem, 3vw, 1.05rem);
    width: 100%;
}

/* --- THEME SELECTOR --- */
.theme-container {
    margin-top: 8px;
    background: rgba(0,0,0,0.55);
    padding: 12px;
    border-radius: 14px;
    border: 2px solid #555;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    max-height: 32vh;
}
.theme-title {
    color: #fff;
    margin-bottom: 8px;
    font-size: clamp(0.8rem, 3vw, 1rem);
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}
.theme-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    padding: 2px;
}
.theme-btn {
    font-size: 1.4rem;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: none;
    background: #444;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    border-bottom: 4px solid #222;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.theme-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.theme-btn.selected {
    background: var(--p1-color);
    border-bottom-color: var(--p1-dark);
    box-shadow: 0 0 10px var(--p1-color);
    transform: scale(1.1);
}

/* --- BUTTONS --- */
.btn-3d {
    background-color: var(--success);
    color: white;
    font-family: 'Oxanium', sans-serif;
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 700;
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    border-bottom: 5px solid #007a4d;
    cursor: pointer;
    transition: all 0.1s;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
    margin: 6px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    white-space: nowrap;
    min-height: 44px;
}
.btn-3d:active { transform: translateY(3px); border-bottom-width: 2px; }

.btn-3d-large {
    width: 100%;
    padding: 14px 12px;
    border-radius: 12px;
    border: none;
    border-bottom: 5px solid rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.1s;
    color: white;
    font-family: 'Oxanium', sans-serif;
    font-weight: bold;
    text-transform: uppercase;
    min-height: 56px;
}
.btn-3d-large:active { transform: translateY(3px); border-bottom-width: 2px; }

/* Difficulty grid */
.difficulty-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-width: 320px;
    width: 100%;
    margin: 0 auto;
}

/* Settings card */
.settings-card {
    max-width: 360px;
    width: 100%;
    margin: 0 auto;
    text-align: left;
    background: rgba(255,255,255,0.05);
    padding: 16px;
    border-radius: 12px;
}
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 10px;
    background: rgba(255,255,255,0.08);
    border-radius: 6px;
    gap: 10px;
    flex-wrap: wrap;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-row label { font-size: clamp(0.95rem, 3.5vw, 1.1rem); }

/* Stats */
.stats-card {
    max-width: 360px;
    width: 100%;
    margin: 0 auto;
    background: rgba(255,255,255,0.08);
    padding: 16px;
    border-radius: 12px;
}
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.stat-tile {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}
.stat-label { font-size: clamp(0.7rem, 2.5vw, 0.85rem); color: #aaa; margin-bottom: 4px; }
.stat-value { font-size: clamp(1.3rem, 5vw, 2rem); font-weight: bold; }

#screen-difficulty, #screen-settings, #screen-stats, #screen-info {
    background: rgba(15, 15, 15, 0.98);
}

.btn-toggle {
    min-width: 60px;
    padding: 6px 14px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    color: white;
    font-weight: bold;
    font-family: 'Oxanium', sans-serif;
    height: 32px;
}

/* Quick sound mute button in HUD */
#sound-quick {
    position: absolute;
    top: var(--hud-overlay-top);
    left: var(--hud-overlay-edge);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    z-index: 130;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.1s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}
#sound-quick:active { transform: scale(0.9); }

/* Quick reset button */
#reset-quick {
    position: absolute;
    top: var(--hud-overlay-top);
    right: var(--hud-overlay-edge);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    cursor: pointer;
    font-size: 1rem;
    z-index: 130;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.1s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.35);
}
#reset-quick:active { transform: scale(0.9); }

.setup-indicator {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    padding: 10px 18px;
    border-radius: 20px;
    font-weight: bold;
    border: 2px solid white;
    z-index: 50;
    pointer-events: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    font-size: clamp(0.85rem, 3.5vw, 1.05rem);
    text-align: center;
    max-width: 90%;
    white-space: nowrap;
}

/* --- ANIMATIONS --- */
@keyframes shake {
    0%,100% { transform: translate(0, 0) rotate(0); }
    20% { transform: translate(-4px, 2px) rotate(-1deg); }
    40% { transform: translate(4px, -2px) rotate(1deg); }
    60% { transform: translate(-3px, 1px) rotate(-1deg); }
    80% { transform: translate(3px, -1px) rotate(1deg); }
}
.shaking { animation: shake 0.5s; }

.explosion-text {
    position: absolute;
    font-size: clamp(1.4rem, 5vw, 2.5rem);
    font-weight: bold;
    color: red;
    text-shadow: 2px 2px 0 yellow, -1px -1px 0 #000;
    pointer-events: none;
    animation: popUp 1.1s forwards;
    z-index: 60;
    white-space: nowrap;
}
@keyframes popUp {
    0% { transform: scale(0) translateY(0); opacity: 0; }
    25% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1.8) translateY(-60px); opacity: 0; }
}

/* Score float (+10 / +30 etc) */
.score-float {
    position: absolute;
    font-size: clamp(1rem, 3.5vw, 1.4rem);
    font-weight: bold;
    color: var(--accent);
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    animation: scoreFloat 0.9s forwards;
    z-index: 60;
    white-space: nowrap;
}
@keyframes scoreFloat {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    30% { transform: translateY(-10px) scale(1.1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1); opacity: 0; }
}

.turn-highlight {
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.2);
    border-color: white;
    background: rgba(40, 40, 40, 0.95);
}

/* Particles */
.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 55;
    animation: particleFly 0.8s forwards;
}
@keyframes particleFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--px), var(--py)) scale(0); opacity: 0; }
}

/* Confetti on win */
.confetti {
    position: absolute;
    width: 10px;
    height: 14px;
    top: -20px;
    pointer-events: none;
    z-index: 110;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    to { transform: translateY(110vh) rotate(720deg); }
}

/* Achievement toast */
#achievement-toast {
    position: fixed;
    top: max(18px, calc(env(safe-area-inset-top) + 12px));
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: linear-gradient(135deg, #FFD700, #FF9800);
    color: #1a1a1a;
    padding: 12px 20px;
    border-radius: 30px;
    font-weight: bold;
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.6);
    z-index: 260;
    transition: transform 0.5s cubic-bezier(.17,.67,.52,1.5);
    max-width: 90%;
    font-size: clamp(0.85rem, 3vw, 1rem);
    display: flex;
    align-items: center;
    gap: 8px;
}
#achievement-toast.show {
    transform: translateX(-50%) translateY(0);
}
#achievement-toast .trophy { font-size: 1.4rem; }

/* --- RESPONSIVE TWEAKS --- */

/* Tiny phones (iPhone SE ~320px) */
@media (max-width: 360px) {
    .player-info { gap: 6px; font-size: 0.85rem; }
    .avatar { width: 26px; height: 26px; border-width: 2px; }
    .heart { font-size: 0.9rem; }
    .hud-panel { min-height: 46px; padding: 6px 8px; }
    .menu-buttons { grid-template-columns: 1fr 1fr; gap: 8px; }
    .menu-buttons .btn-3d { padding: 10px 6px; font-size: 0.85rem; }
    h1 { font-size: 1.4rem; }
    .theme-container { max-height: 26vh; padding: 8px; }
    .theme-btn { width: 38px; height: 38px; font-size: 1.2rem; }
}

/* Short viewports (landscape phones) */
@media (max-height: 600px) {
    .hud-panel { min-height: 44px; padding: 4px 10px; }
    .menu-logo { margin-bottom: 8px; min-height: 72px; padding: 10px 14px; }
    p { margin-bottom: 8px; }
    h1 { font-size: 1.4rem; margin-bottom: 4px; }
    .btn-3d { padding: 8px 20px; margin: 4px; min-height: 38px; }
    .theme-container { margin-top: 6px; max-height: 28vh; padding: 8px; }
    #board-area { padding: 4px; }
    .splash-loader { margin-top: 14px; width: 36px; height: 36px; }
    .splash-logo { margin-bottom: 4px; }
}

/* Landscape orientation: side-by-side layout */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container { max-width: 900px; }
    .hud-panel { min-height: 40px; }
    #turn-text { flex: 1 1 auto; }
    #game-status-bar { padding: 4px 8px; }
    #board-area { padding: 4px; }
    #grid { max-width: min(70vmin, 360px); max-height: min(70vmin, 360px); }
    .menu-buttons { grid-template-columns: repeat(4, minmax(110px, 1fr)); max-width: 600px; }
    .theme-container { max-height: 45vh; }
}

/* Very large screens */
@media (min-width: 900px) {
    #game-container { max-width: 560px; }
}

@media (min-width: 501px) {
    :root {
        --hud-overlay-edge: 16px;
        --hud-overlay-top: max(16px, calc(env(safe-area-inset-top) + 10px));
    }
}


/* Branding and info panel */
.ndx-signature {
    margin: -8px 0 14px;
    color: #ffe8a3;
    font-size: clamp(0.78rem, 2.8vw, 0.95rem);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.ndx-signature a {
    color: #fff;
    text-decoration: none;
    border-bottom: 2px solid rgba(255, 215, 0, 0.75);
}
.ndx-signature-large {
    margin: 0 0 16px;
    font-size: clamp(1rem, 4vw, 1.25rem);
}
.ndx-info-card {
    width: min(92vw, 440px);
    max-height: 70vh;
    overflow-y: auto;
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(40, 28, 12, 0.95), rgba(12, 12, 12, 0.96));
    border: 2px solid rgba(255, 183, 0, 0.5);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
}
.ndx-info-lead {
    margin: 0 auto 14px;
    color: #f7f1de;
}
.ndx-link-grid {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}
.ndx-link-pill {
    display: block;
    padding: 11px 12px;
    border-radius: 12px;
    color: #111;
    background: linear-gradient(180deg, #fff3c4, #ffc928);
    text-decoration: none;
    font-weight: 800;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.ndx-legal {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: #d7d7d7;
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: left;
}
.ndx-legal strong {
    color: #ffd34d;
    margin-top: 6px;
}
.ndx-danger {
    background: linear-gradient(180deg, #ff4f4f, #c41414) !important;
    border-bottom-color: #780909 !important;
    color: #fff !important;
}
.ndx-danger-note {
    border: 1px solid rgba(255, 80, 80, 0.45);
}


/* Nandax sticker-pack theme pass */
:root {
    --ndx-ink: #070711;
    --ndx-panel: rgba(9, 10, 20, 0.94);
    --ndx-panel-soft: rgba(255, 255, 255, 0.075);
    --ndx-sun: #ffd20a;
    --ndx-pop: #ff2f9d;
    --ndx-sky: #16b8ff;
    --ndx-mint: #00c987;
    --ndx-orange: #ff8a00;
    --ndx-danger: #ff315a;
    --p1-color: var(--ndx-sky);
    --p1-dark: #006cb2;
    --p2-color: var(--ndx-danger);
    --p2-dark: #9d0e2f;
    --accent: var(--ndx-sun);
    --success: var(--ndx-mint);
    --danger: var(--ndx-danger);
    --bg-color: var(--ndx-ink);
    --stud-color: rgba(255, 255, 255, 0.035);
}

body.ndx-boom-bites {
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 47, 157, 0.28), transparent 30%),
        radial-gradient(circle at 90% 10%, rgba(22, 184, 255, 0.25), transparent 32%),
        radial-gradient(circle at 50% 92%, rgba(255, 210, 10, 0.16), transparent 38%),
        var(--ndx-ink);
}

body.ndx-boom-bites::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: url("assets/nandax-sticker-pack.png");
    background-size: min(1300px, 180vw) auto;
    background-position: center;
    opacity: 0.055;
    filter: saturate(1.25);
}

#game-container {
    z-index: 1;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.05), transparent 24%),
        rgba(4, 5, 12, 0.56);
}

.overlay {
    position: fixed;
    inset: auto;
    top: 0;
    left: 50%;
    width: min(100vw, 500px);
    height: 100dvh;
    transform: translateX(-50%);
    background-clip: padding-box;
}

#screen-menu,
#screen-instructions,
#screen-difficulty,
#screen-settings,
#screen-stats,
#screen-info,
#screen-intermission,
#screen-gameover {
    background:
        linear-gradient(180deg, rgba(6, 8, 18, 0.92), rgba(5, 5, 10, 0.98)),
        radial-gradient(circle at 18% 18%, rgba(255, 47, 157, 0.22), transparent 34%),
        radial-gradient(circle at 82% 12%, rgba(22, 184, 255, 0.2), transparent 32%);
}

#screen-instructions {
    align-items: center;
    justify-content: flex-start;
}

.instructions-scroll {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: max(18px, env(safe-area-inset-top)) 22px 16px;
    text-align: left;
}

#screen-instructions h1 {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 auto 12px;
    padding: 10px 0 12px;
    background: linear-gradient(180deg, rgba(7, 7, 17, 0.98), rgba(7, 7, 17, 0.72));
}

.instructions-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    background: linear-gradient(180deg, rgba(5,5,10,0), rgba(5,5,10,0.94) 32%);
}

.menu-hero-card,
.splash-art-frame {
    background: #fff;
    border-color: rgba(255, 255, 255, 0.75);
}

.menu-hero-art,
.splash-art {
    object-fit: contain;
    background: #fff;
}

#sound-quick,
#reset-quick {
    top: auto;
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 10px));
    width: 42px;
    height: 42px;
    border-color: rgba(255, 255, 255, 0.45);
    background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(0,0,0,0.76));
    backdrop-filter: blur(8px);
}

#sound-quick { left: max(14px, calc(env(safe-area-inset-left) + 12px)); }
#reset-quick { right: max(14px, calc(env(safe-area-inset-right) + 12px)); }

.ndx-sticker-face {
    display: block;
    width: 86%;
    height: 86%;
    background-repeat: no-repeat;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.32));
}

.theme-btn.ndx-sticker-theme {
    background-repeat: no-repeat;
    background-color: #fff;
    border: 3px solid var(--ndx-sun);
}

.ndx-signature {
    margin: -8px 0 14px;
    color: #ffe8a3;
    font-size: clamp(0.78rem, 2.8vw, 0.95rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.ndx-signature a {
    color: #fff;
    text-decoration: none;
    border-bottom: 2px solid rgba(255, 210, 10, 0.85);
}

.ndx-signature-large {
    margin: 0 0 16px;
    font-size: clamp(1rem, 4vw, 1.25rem);
}

.ndx-info-card {
    width: min(92vw, 440px);
    max-height: 70vh;
    overflow-y: auto;
    padding: 18px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(14, 18, 34, 0.96), rgba(7, 7, 16, 0.98));
    border: 2px solid rgba(255, 210, 10, 0.5);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
}

.ndx-info-lead {
    margin: 0 auto 14px;
    color: #f7f1de;
}

.ndx-link-grid {
    display: grid;
    gap: 10px;
    margin: 16px 0;
}

.ndx-link-pill {
    display: block;
    padding: 11px 12px;
    border-radius: 14px;
    color: #101018;
    background: linear-gradient(180deg, #fff4c7, #ffd20a);
    text-decoration: none;
    font-weight: 800;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.ndx-legal {
    display: grid;
    gap: 6px;
    margin-top: 16px;
    color: #d7d7d7;
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: left;
}

.ndx-legal strong {
    color: var(--ndx-sun);
    margin-top: 6px;
}

.ndx-danger {
    background: linear-gradient(180deg, #ff5576, #c4143a) !important;
    border-bottom-color: #78091f !important;
    color: #fff !important;
}

.ndx-danger-note {
    border: 1px solid rgba(255, 80, 112, 0.45);
}

.ndx-dialog {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(6px);
}

.ndx-dialog-card {
    width: min(92vw, 390px);
    padding: 20px;
    border-radius: 24px;
    border: 2px solid rgba(255, 255, 255, 0.16);
    background:
        radial-gradient(circle at top right, rgba(22, 184, 255, 0.22), transparent 36%),
        linear-gradient(180deg, rgba(18, 22, 40, 0.98), rgba(8, 8, 16, 0.98));
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.56);
    text-align: center;
}

.ndx-dialog[data-tone="danger"] .ndx-dialog-card { border-color: rgba(255, 49, 90, 0.55); }
.ndx-dialog[data-tone="success"] .ndx-dialog-card { border-color: rgba(0, 201, 135, 0.6); }
.ndx-dialog[data-tone="warning"] .ndx-dialog-card { border-color: rgba(255, 210, 10, 0.58); }

.ndx-dialog-kicker {
    color: var(--ndx-sun);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.ndx-dialog h2 {
    margin: 0 0 10px;
    color: #fff;
    text-shadow: 0 3px 0 #000;
}

.ndx-dialog p {
    margin: 0 auto 18px;
    color: #e9e9f4;
}

.ndx-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ndx-dialog-cancel {
    background: linear-gradient(180deg, #747985, #3f424b) !important;
    border-bottom-color: #22252c !important;
}

.ndx-dialog-confirm {
    background: linear-gradient(180deg, var(--ndx-mint), #008b62) !important;
    border-bottom-color: #005e43 !important;
}


/* Nandax feedback alignment fixes */
body.ndx-boom-bites::before {
    display: none;
}

.menu-hero-card,
.splash-art-frame {
    background: rgba(8, 8, 8, 0.34);
    border-color: rgba(255,255,255,0.18);
}

.menu-hero-art,
.splash-art {
    object-fit: cover;
    background: transparent;
}

#board-area {
    flex-direction: column;
    gap: clamp(5px, 1.6vmin, 10px);
}

#grid {
    max-height: min(74vmin, 410px);
}

#combo-badge {
    position: static;
    align-self: center;
    min-height: 30px;
    max-width: min(92%, 360px);
    margin: 0;
    transform: translateY(4px) scale(0.92);
    visibility: hidden;
}

#combo-badge.active {
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ndx-board-control-rail {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: clamp(2px, 1.2vmin, 8px);
    pointer-events: auto;
}

#sound-quick,
#reset-quick {
    position: static !important;
    inset: auto !important;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border-color: rgba(255, 255, 255, 0.45);
    background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(0,0,0,0.76));
    backdrop-filter: blur(8px);
}

#screen-instructions {
    align-items: center;
}

.instructions-scroll {
    width: min(100%, 460px);
    align-self: center;
}


/* Modern Nandax gaming typography and sticker-only theme grid */
body {
    font-family: 'Oxanium', sans-serif;
}

h1,
.splash-text,
.menu-logo-title,
.btn-3d,
.btn-3d-large,
.theme-title,
#turn-text,
#score-display,
.player-info,
#achievement-toast {
    font-family: 'Bungee', 'Oxanium', sans-serif;
    letter-spacing: 0.02em;
}

p,
li,
.settings-row,
.stat-label,
.stat-value,
.ndx-dialog p,
.ndx-info-card,
.copyright-block,
.ndx-legal {
    font-family: 'Oxanium', sans-serif;
}

.theme-container {
    max-height: 34vh;
    border-color: rgba(255, 210, 10, 0.42);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.025)),
        rgba(7, 8, 18, 0.72);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(48px, 1fr));
    justify-items: center;
    gap: 10px;
}

.theme-btn {
    width: clamp(48px, 11vw, 62px);
    height: clamp(48px, 11vw, 62px);
    background-repeat: no-repeat;
    background-color: #fff7e6;
    border: 3px solid rgba(3, 4, 12, 0.92);
    border-bottom: 6px solid rgba(3, 4, 12, 0.92);
    border-radius: 17px;
    box-shadow:
        0 8px 0 rgba(0,0,0,0.3),
        0 10px 20px rgba(0,0,0,0.35);
}

.theme-btn.ndx-sticker-theme {
    background-repeat: no-repeat;
    background-color: #fff7e6;
    border-color: #080811;
}

.theme-btn.selected {
    background-color: #fff;
    border-color: var(--ndx-sun);
    border-bottom-color: #b97700;
    box-shadow:
        0 0 0 3px rgba(255, 47, 157, 0.65),
        0 0 18px rgba(255, 210, 10, 0.85),
        0 8px 0 rgba(0,0,0,0.26);
    transform: translateY(-2px) scale(1.05);
}

.ndx-sticker-face {
    display: block;
    width: 96%;
    height: 96%;
    background-repeat: no-repeat;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.32));
}

.chip-content .ndx-sticker-face {
    width: 94%;
    height: 94%;
}

@media (max-width: 360px) {
    .theme-grid {
        grid-template-columns: repeat(4, minmax(42px, 1fr));
        gap: 8px;
    }

    .theme-btn {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }
}


/* Sleek compact menu pass */
.menu-logo {
    width: min(82%, 340px);
    min-height: 54px;
    gap: 8px;
    padding: 8px 14px;
    margin-bottom: 8px;
    border-radius: 20px;
}

.menu-logo-mark {
    font-size: clamp(1.05rem, 4.6vw, 1.55rem);
}

.menu-logo-title {
    font-size: clamp(1.15rem, 5.3vw, 1.72rem);
    line-height: 0.92;
    letter-spacing: 0.06em;
    text-shadow:
        0 2px 0 rgba(112, 32, 0, 0.95),
        0 5px 10px rgba(0,0,0,0.42);
}

.menu-hero-card {
    width: min(72%, 300px);
    aspect-ratio: 5 / 1;
    margin-bottom: 10px;
    border-radius: 18px;
}

#screen-menu > p:not(.ndx-signature) {
    margin: 2px 0 6px;
    font-size: clamp(0.84rem, 2.8vw, 1rem);
}

.ndx-signature {
    margin: 0 0 10px;
    font-size: clamp(0.62rem, 2.25vw, 0.78rem);
    letter-spacing: 0.08em;
}

.menu-buttons {
    max-width: 300px;
    gap: 8px;
    margin-bottom: 10px;
}

.menu-buttons .btn-3d,
.btn-3d {
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 12px;
    border-bottom-width: 4px;
    font-size: clamp(0.68rem, 2.65vw, 0.9rem);
    box-shadow: 0 5px 12px rgba(0,0,0,0.26);
}

.btn-3d-large {
    min-height: 44px;
    padding: 10px 12px;
    font-size: clamp(0.74rem, 2.8vw, 0.95rem);
}

.theme-container {
    width: min(88%, 350px);
    max-height: none;
    padding: 9px 10px 10px;
    border-radius: 18px;
    margin-top: 8px;
}

.theme-title {
    margin-bottom: 7px;
    font-size: clamp(0.66rem, 2.4vw, 0.82rem);
    letter-spacing: 0.09em;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 8px;
    overflow: hidden;
    max-height: none;
}

.theme-btn,
.theme-btn.ndx-sticker-theme {
    width: clamp(42px, 9vw, 54px);
    height: clamp(42px, 9vw, 54px);
    border-radius: 14px;
    border-width: 2px;
    border-bottom-width: 5px;
    box-shadow:
        0 5px 0 rgba(0,0,0,0.3),
        0 8px 14px rgba(0,0,0,0.24);
}

.theme-btn.selected {
    transform: translateY(-1px) scale(1.04);
    box-shadow:
        0 0 0 2px rgba(255, 47, 157, 0.62),
        0 0 12px rgba(255, 210, 10, 0.72),
        0 5px 0 rgba(0,0,0,0.22);
}

h1 {
    font-size: clamp(1rem, 3.6vw, 1.4rem);
}

.splash-text {
    font-size: clamp(1.15rem, 5vw, 1.65rem);
}

#screen-difficulty h1,
#screen-settings h1,
#screen-stats h1,
#screen-info h1,
#screen-instructions h1,
#winner-text {
    font-size: clamp(1.05rem, 4vw, 1.5rem);
}

.hud-panel {
    min-height: 46px;
    padding: 6px 10px;
}

.player-info {
    font-size: clamp(0.72rem, 2.75vw, 0.9rem);
}

#turn-text {
    font-size: clamp(0.72rem, 2.75vw, 0.92rem);
}

#score-display {
    font-size: clamp(0.68rem, 2.5vw, 0.86rem);
}

#combo-badge {
    min-height: 26px;
    padding: 4px 10px;
    font-size: clamp(0.62rem, 2.3vw, 0.78rem);
}

@media (max-height: 720px) {
    .menu-logo {
        min-height: 46px;
        margin-bottom: 6px;
    }

    .menu-hero-card {
        width: min(64%, 270px);
        margin-bottom: 7px;
    }

    .menu-buttons {
        gap: 7px;
        margin-bottom: 8px;
    }

    .theme-container {
        padding: 8px;
        margin-top: 6px;
    }

    .theme-btn,
    .theme-btn.ndx-sticker-theme {
        width: 42px;
        height: 42px;
    }
}

/* Final compact Nandax menu density pass */
#screen-menu {
    justify-content: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
}

#screen-menu .menu-logo {
    width: min(74%, 260px);
    min-height: 42px;
    gap: 6px;
    padding: 6px 11px;
    margin: 0 0 6px;
    border-radius: 17px;
}

#screen-menu .menu-logo-mark {
    font-size: clamp(0.72rem, 3.1vw, 1rem);
}

#screen-menu .menu-logo-title {
    font-size: clamp(0.86rem, 3.8vw, 1.16rem) !important;
    letter-spacing: 0.05em;
    line-height: 0.9;
}

#screen-menu .menu-hero-card {
    width: min(66%, 238px);
    margin-bottom: 7px;
    border-radius: 15px;
}

#screen-menu > p:not(.ndx-signature) {
    font-size: clamp(0.72rem, 2.45vw, 0.88rem);
    margin: 1px 0 4px;
}

#screen-menu .ndx-signature {
    margin-bottom: 7px;
    font-size: clamp(0.52rem, 1.9vw, 0.66rem);
}

#screen-menu .menu-buttons {
    max-width: 270px;
    gap: 7px;
    margin-bottom: 8px;
}

#screen-menu .menu-buttons .btn-3d {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 11px;
    font-size: clamp(0.58rem, 2.25vw, 0.78rem);
}

#screen-menu .theme-container {
    width: min(78%, 286px);
    padding: 7px 9px 8px;
    margin-top: 6px;
    border-radius: 16px;
}

#screen-menu .theme-title {
    margin-bottom: 6px;
    font-size: clamp(0.54rem, 2vw, 0.68rem);
}

#screen-menu .theme-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, 40px);
    gap: 6px;
    max-height: 86px;
    overflow: hidden;
    place-items: center;
}

#screen-menu .theme-btn,
#screen-menu .theme-btn.ndx-sticker-theme {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border-bottom-width: 4px;
}

#screen-difficulty .btn-3d-large {
    padding: 12px !important;
}

#screen-difficulty .btn-3d-large > div:first-child {
    font-size: 0.88rem !important;
}

#screen-difficulty .btn-3d-large > div:last-child {
    font-size: 0.68rem !important;
}

#screen-stats [id^="stat-"] {
    font-size: 1.1rem !important;
}

@media (max-height: 700px) {
    #screen-menu .menu-logo {
        min-height: 38px;
        padding: 5px 10px;
    }

    #screen-menu .menu-hero-card {
        width: min(58%, 220px);
    }

    #screen-menu .theme-container {
        width: min(76%, 270px);
    }

    #screen-menu .theme-grid {
        grid-template-rows: repeat(2, 36px);
        max-height: 78px;
    }

    #screen-menu .theme-btn,
    #screen-menu .theme-btn.ndx-sticker-theme {
        width: 36px;
        height: 36px;
    }
}

/* Menu face recovery pass */
#screen-menu {
    justify-content: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
}

#screen-menu .menu-logo {
    width: min(92%, 420px);
    min-height: auto;
    padding: 0;
    margin: 0 0 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

#screen-menu .menu-logo-mark {
    display: none;
}

#screen-menu .menu-logo-title {
    display: block;
    white-space: nowrap;
    font-size: clamp(1.35rem, 6.2vw, 2.05rem) !important;
    line-height: 1;
    letter-spacing: 0.055em;
    color: #FFE6A3;
    text-shadow:
        0 2px 0 #612100,
        0 5px 0 rgba(0,0,0,0.55),
        0 0 20px rgba(255, 185, 35, 0.44);
}

#screen-menu .menu-hero-card {
    width: min(84%, 360px);
    aspect-ratio: 3 / 2;
    max-height: 190px;
    margin: 0 0 12px;
    padding: 7px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(0,0,0,0.28));
    border: 1px solid rgba(255, 210, 70, 0.34);
    box-shadow:
        0 10px 24px rgba(0,0,0,0.35),
        inset 0 0 0 1px rgba(255,255,255,0.08);
}

#screen-menu .menu-hero-art {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    border-radius: 14px;
}

#screen-menu > p:not(.ndx-signature) {
    margin: 0 0 6px;
    font-size: clamp(0.9rem, 3.1vw, 1.08rem);
}

#screen-menu .ndx-signature {
    margin: 0 0 12px;
    font-size: clamp(0.62rem, 2.2vw, 0.78rem);
}

#screen-menu .menu-buttons {
    max-width: 340px;
    gap: 10px;
    margin-bottom: 14px;
}

#screen-menu .menu-buttons .btn-3d {
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 14px;
    border-bottom-width: 5px;
    font-size: clamp(0.72rem, 2.8vw, 0.96rem);
}

#screen-menu .menu-buttons .btn-3d[style*="grid-column"] {
    min-height: 48px;
}

#screen-menu .theme-container {
    width: min(86%, 360px);
    padding: 10px 12px 12px;
    margin-top: 0;
    border-radius: 20px;
}

#screen-menu .theme-title {
    margin-bottom: 8px;
    font-size: clamp(0.66rem, 2.35vw, 0.82rem);
}

#screen-menu .theme-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, 48px);
    gap: 9px;
    max-height: 105px;
    overflow: hidden;
    place-items: center;
}

#screen-menu .theme-btn,
#screen-menu .theme-btn.ndx-sticker-theme {
    width: 48px;
    height: 48px;
    border-radius: 14px;
}

@media (max-height: 760px) {
    #screen-menu {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    #screen-menu .menu-hero-card {
        width: min(74%, 310px);
        max-height: 150px;
        margin-bottom: 9px;
    }

    #screen-menu .menu-buttons {
        gap: 8px;
        margin-bottom: 10px;
    }

    #screen-menu .menu-buttons .btn-3d {
        min-height: 39px;
        padding: 8px 14px;
    }

    #screen-menu .theme-grid {
        grid-template-rows: repeat(2, 42px);
        max-height: 91px;
        gap: 7px;
    }

    #screen-menu .theme-btn,
    #screen-menu .theme-btn.ndx-sticker-theme {
        width: 42px;
        height: 42px;
    }
}
