/* ===================================================
   CLUSTERCORE — PREMIUM VISUAL OVERHAUL
   =================================================== */

:root {
    --cell-size: 60px;
    --grid-cols: 7;
    --grid-rows: 9;

    /* REFINED PALETTE */
    --color-bg-deep:   #07081a;
    --color-bg-mid:    #0d0f26;
    --color-bg-panel:  #121432;
    --color-accent:    #5b9eff;
    --color-accent-2:  #7b6eff;
    --color-teal:      #4de8d1;
    --color-danger:    #ff4262;
    --color-gold:      #ffcc44;
    --color-glow:      rgba(91, 158, 255, 0.55);

    /* AMBIENT */
    --ambient-1: #060714;
    --ambient-2: #0d1236;
    --ambient-3: #0a0d22;

    /* MOBILE */
    --mobile-bottom-nav-height: 78px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background-color: var(--color-bg-deep);
    font-family: 'Poppins', sans-serif;
    color: white;
    touch-action: manipulation;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* ===================================================
   ANIMATED GRID BACKGROUND
   =================================================== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(91, 158, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(91, 158, 255, 0.045) 1px, transparent 1px);
    background-size: 48px 48px;
    z-index: 0;
    pointer-events: none;
}

/* Radial ambient glow */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 60% at 50% 0%, rgba(91, 158, 255, 0.14) 0%, transparent 70%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(123, 110, 255, 0.1) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 0% 80%, rgba(77, 232, 209, 0.07) 0%, transparent 55%);
    z-index: 0;
    pointer-events: none;
    animation: ambientPulse 8s ease-in-out infinite alternate;
}

@keyframes ambientPulse {
    0%   { opacity: 0.65; filter: hue-rotate(0deg); }
    50%  { opacity: 1;    filter: hue-rotate(8deg); }
    100% { opacity: 0.7;  filter: hue-rotate(-4deg); }
}

/* ===================================================
   MICRO-INTERACTION ANIMATIONS
   =================================================== */

/* Piece landing bounce */
@keyframes pieceLand {
    0%   { transform: scaleX(1)   scaleY(1); }
    25%  { transform: scaleX(1.12) scaleY(0.86); }
    50%  { transform: scaleX(0.94) scaleY(1.08); }
    70%  { transform: scaleX(1.04) scaleY(0.97); }
    100% { transform: scaleX(1)   scaleY(1); }
}
.piece-land { animation: pieceLand 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

/* Score number flash */
@keyframes scoreFlash {
    0%   { transform: scale(1);    color: inherit; }
    40%  { transform: scale(1.35); color: var(--color-gold); text-shadow: 0 0 18px var(--color-gold); }
    100% { transform: scale(1);    color: inherit; text-shadow: none; }
}
.score-flash { animation: scoreFlash 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Nav item bounce when selected */
@keyframes navBounce {
    0%   { transform: translateY(0); }
    40%  { transform: translateY(-5px); }
    70%  { transform: translateY(1px); }
    100% { transform: translateY(0); }
}
.nav-bounce { animation: navBounce 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Screen entrance slide up */
@keyframes screenSlideUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}
.screen-enter { animation: screenSlideUp 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* Button press ripple */
@keyframes btnClick {
    0%   { box-shadow: 0 0 0 0 rgba(91,158,255,0.55); }
    60%  { box-shadow: 0 0 0 14px rgba(91,158,255,0); }
    100% { box-shadow: 0 0 0 0 rgba(91,158,255,0); }
}
.menu-btn:active, .btn-start:active {
    animation: btnClick 0.4s ease-out;
    transform: scale(0.96);
}

/* Game-over modal cinematic entrance */
@keyframes gameOverDrop {
    from { opacity: 0; transform: translateY(-30px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.gameover-modal:not(.hidden) {
    animation: gameOverDrop 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Combo chain pulse on board */
@keyframes comboPulse {
    0%   { box-shadow: 0 0 0 0 rgba(77, 232, 209, 0.6); }
    70%  { box-shadow: 0 0 0 16px rgba(77, 232, 209, 0); }
    100% { box-shadow: 0 0 0 0  rgba(77, 232, 209, 0); }
}
.board-container { border-radius: 12px; }
.board-container.combo-pulse {
    animation: comboPulse 0.5s ease-out;
}

/* ===================================================
   LAYOUT ROOT
   =================================================== */
#app-root {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
    overflow: hidden;
    padding: 12px;
}

.hidden {
    display: none !important;
}

/* ===================================================
   SCREENS (MENU, HELP, NEWS, SETTINGS)
   =================================================== */
.screen {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg-deep);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Changed from center to allow scrolling from top */
    padding: 24px 20px 120px; /* Added more bottom padding for mobile */
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.25s ease;
}

.screen.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

/* ===================================================
   MAIN MENU — LOGO
   =================================================== */
.menu-logo {
    width: clamp(180px, 35vw, 300px);
    max-height: 22vh; /* Cap logo height to prevent cutoff */
    object-fit: contain;
    margin-bottom: 32px;
    filter:
        drop-shadow(0 0 24px rgba(91, 158, 255, 0.55))
        drop-shadow(0 0 60px rgba(123, 110, 255, 0.25));
    animation: logoFloat 3.6s ease-in-out infinite, logoGlowPulse 3.6s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-10px); }
}

@keyframes logoGlowPulse {
    0%, 100% {
        filter:
            drop-shadow(0 0 20px rgba(91, 158, 255, 0.45))
            drop-shadow(0 0 50px rgba(123, 110, 255, 0.2));
    }
    50% {
        filter:
            drop-shadow(0 0 32px rgba(91, 158, 255, 0.75))
            drop-shadow(0 0 70px rgba(123, 110, 255, 0.35));
    }
}

/* ===================================================
   MODE CARDS
   =================================================== */
.mode-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Responsive grid */
    gap: 14px;
    max-width: 560px;
    width: 100%;
    margin-bottom: 30px;
}

.mode-card--new {
    border-color: rgba(255, 93, 162, 0.5);
    background: linear-gradient(145deg, rgba(255,93,162,0.08), rgba(91,158,255,0.04));
    grid-column: 1 / -1;
}

.mode-badge-new {
    display: inline-block;
    background: #FF5DA2;
    color: #fff;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.1em;
    padding: 1px 5px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 4px;
    text-transform: uppercase;
}

.mode-card {
    position: relative;
    background: linear-gradient(145deg,
        rgba(255,255,255,0.055) 0%,
        rgba(91,158,255,0.04) 100%);
    border: 1px solid rgba(91, 158, 255, 0.22);
    border-radius: 20px;
    padding: 24px 18px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.3s ease,
                box-shadow 0.3s ease;
}

/* Shine sweep on hover */
.mode-card::before {
    content: '';
    position: absolute;
    top: -60%;
    left: -60%;
    width: 60%;
    height: 200%;
    background: linear-gradient(120deg,
        transparent 0%,
        rgba(255,255,255,0.07) 50%,
        transparent 100%);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}

.mode-card:hover::before {
    left: 130%;
}

/* Accent line at top */
.mode-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg,
        transparent,
        var(--color-accent),
        transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 2px;
}

.mode-card:hover::after {
    opacity: 1;
}

.mode-card:hover {
    transform: translateY(-6px) scale(1.025);
    border-color: rgba(91, 158, 255, 0.7);
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(91, 158, 255, 0.18) inset,
        0 0 24px rgba(91, 158, 255, 0.2);
}

.mode-card:active {
    transform: translateY(-2px) scale(0.99);
}

.mode-icon {
    font-size: 34px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(91, 158, 255, 0.1);
    border: 1px solid rgba(91, 158, 255, 0.2);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.mode-card:hover .mode-icon {
    background: rgba(91, 158, 255, 0.18);
    box-shadow: 0 0 16px rgba(91, 158, 255, 0.25);
}

.mode-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: #e8f0ff;
    letter-spacing: 0.03em;
}

.mode-card p {
    font-size: 11px;
    color: rgba(180, 200, 255, 0.7);
    margin: 0;
    line-height: 1.45;
}

/* ===================================================
   GAME BOARD LAYOUT
   =================================================== */
.game-layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    max-width: min(100%, 1280px);
    margin: 0 auto;
    flex: 0 1 auto;
}

/* Game Board Container */
.board-container {
    position: relative;
    padding: 4px;
    background: rgba(91, 158, 255, 0.04);
    backdrop-filter: blur(12px);
    border-radius: 6px;
    border: 1.8px solid var(--board-glow, rgba(91, 158, 255, 0.45));
    box-shadow:
        0 0 0 1px rgba(91, 158, 255, 0.08) inset,
        0 0 40px var(--board-glow, rgba(91, 158, 255, 0.22)),
        0 0 100px rgba(91, 158, 255, 0.08),
        0 24px 64px rgba(0, 0, 0, 0.65);
    transition: border-color 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes boardPulse {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(91, 158, 255, 0.08) inset,
            0 0 32px rgba(91, 158, 255, 0.22),
            0 0 80px rgba(91, 158, 255, 0.08),
            0 24px 48px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(91, 158, 255, 0.12) inset,
            0 0 48px rgba(91, 158, 255, 0.38),
            0 0 100px rgba(91, 158, 255, 0.14),
            0 24px 48px rgba(0, 0, 0, 0.5);
    }
}

canvas, #phaser-game-container {
    display: block;
    border-radius: 0;
    background: rgba(7, 8, 26, 0.95);
}

#phaser-game-container canvas {
    border-radius: 0;
}

/* ===================================================
   SIDE PANEL
   =================================================== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 185px;
}

/* Panel Box */
.panel-box {
    background: linear-gradient(160deg,
        rgba(255,255,255,0.055) 0%,
        rgba(91,158,255,0.030) 100%);
    padding: 12px;
    border-radius: 14px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(91, 158, 255, 0.18);
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: border-color 0.2s ease;
}

.panel-title {
    font-size: 10px;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 6px;
    font-weight: 700;
    opacity: 0.85;
}

/* Score / Level values */
.score-val {
    font-family: 'Fredoka One', cursive;
    font-size: 26px;
    color: #fff;
    text-shadow: 0 0 14px rgba(91, 158, 255, 0.4);
}

.stats-combined .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: end;
}

.stats-combined .stat-cell {
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 8px 6px 10px;
}

.stats-combined #score-display,
.stats-combined #level-display {
    font-size: 32px;
    line-height: 1;
}

.stats-combined .level-bar-container {
    margin-top: 6px;
}

.compact-box {
    min-height: 108px;
}

/* Diamond Reroll Button */
.diamond-action-btn {
    margin-top: 8px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(77, 232, 209, 0.4);
    background: linear-gradient(180deg,
        rgba(77, 232, 209, 0.15) 0%,
        rgba(77, 232, 209, 0.07) 100%);
    color: #c4f5ee;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.diamond-action-meta {
    display: block;
    margin-top: 2px;
    font-size: 9px;
    line-height: 1.2;
    letter-spacing: 0.05em;
    text-transform: none;
    opacity: 0.72;
}

.diamond-action-btn:hover:not(.disabled) {
    transform: translateY(-1px);
    background: linear-gradient(180deg,
        rgba(77, 232, 209, 0.25) 0%,
        rgba(77, 232, 209, 0.12) 100%);
    box-shadow: 0 0 14px rgba(77, 232, 209, 0.3);
}

.diamond-action-btn.disabled,
.diamond-action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Level Progress Bar */
.level-bar-container {
    width: 100%;
    height: 5px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.level-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-teal));
    transition: width 0.35s ease-out;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(91, 158, 255, 0.5);
}

/* Side Logo */
.side-logo-container {
    width: 100%;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    border-radius: 12px;
    overflow: hidden;
}

.side-logo-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.45);
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

/* In-game logo shown above the board */
#game-logo.side-logo-container {
    height: 56px;
    width: auto;
    max-width: 220px;
    margin-bottom: 0;
    border-radius: 0;
    overflow: visible;
    flex-shrink: 0;
}

#game-logo.side-logo-container img {
    transform: none;
    width: auto;
    height: 100%;
    max-height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(49, 217, 255, 0.35));
}

/* ===================================================
   CONTROLS FOOTER
   =================================================== */
.controls-footer {
    width: min(100%, 980px);
    margin: 2px auto 0;
}

.controls-footer .tutorial-content {
    display: grid;
    grid-template-columns: 1fr auto 1.1fr;
    gap: 14px;
    align-items: stretch;
}

.controls-footer .separator {
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.1), transparent);
}

.tutorial-content {
    text-align: left;
    font-size: 10px;
    color: #ccc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    padding-right: 0;
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    align-content: start;
}

.ctrl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.025);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ctrl-item span {
    font-size: 8px;
    letter-spacing: 0.5px;
    opacity: 0.6;
}

.keys {
    display: flex;
    gap: 2px;
}

.key {
    background: rgba(91,158,255,0.12);
    border: 1px solid rgba(91,158,255,0.25);
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: bold;
    color: #c0d4ff;
    font-size: 9px;
    min-width: 18px;
    text-align: center;
}

.separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.block-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    align-content: start;
}

.block-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.04);
}

.block-item span:last-child {
    font-size: 9px;
    letter-spacing: 0.3px;
    opacity: 0.75;
}

.b-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
    filter: drop-shadow(0 0 3px currentColor);
}

/* ===================================================
   OVERLAY (PAUSE / GAME OVER)
   =================================================== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 8, 26, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Pause overlay death line */
.death-line-glow {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    box-shadow: 0 0 18px var(--color-danger), 0 0 4px var(--color-danger);
    background: var(--color-danger);
    z-index: 10;
    opacity: 0.85;
    pointer-events: none;
}

/* ===================================================
   GAME OVER MODAL
   =================================================== */
.gameover-modal {
    width: min(92%, 360px);
    padding: 24px 22px 20px;
    border-radius: 20px;
    border: 1px solid rgba(91, 158, 255, 0.25);
    background: linear-gradient(160deg,
        rgba(13, 15, 38, 0.97) 0%,
        rgba(7, 8, 26, 0.97) 100%);
    box-shadow:
        0 24px 56px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255,255,255,0.06) inset,
        0 0 40px rgba(91, 158, 255, 0.1);
    text-align: center;
    animation: modalSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.gameover-modal.hidden {
    display: none !important;
}

.gameover-title {
    font-family: 'Fredoka One', cursive;
    font-size: 32px;
    letter-spacing: 0.05em;
    color: var(--color-danger);
    text-shadow: 0 0 20px rgba(255, 66, 98, 0.5);
    margin-bottom: 10px;
}

.gameover-score {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.gameover-level {
    font-size: 12px;
    color: rgba(160, 190, 255, 0.8);
    margin-bottom: 16px;
}

.gameover-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gameover-actions .btn-start {
    margin-top: 0;
    padding: 11px 14px;
    font-size: 13px;
}

.gameover-secondary {
    background: transparent !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    box-shadow: none !important;
    color: rgba(255,255,255,0.8) !important;
}

/* ===================================================
   BUTTONS
   =================================================== */
.btn-start {
    margin-top: 12px;
    padding: 13px 28px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 4px 16px rgba(91, 158, 255, 0.4),
        0 0 0 1px rgba(255,255,255,0.08) inset;
    letter-spacing: 0.03em;
}

.btn-start:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 8px 24px rgba(91, 158, 255, 0.6),
        0 0 0 1px rgba(255,255,255,0.12) inset;
}

.btn-start:active {
    transform: translateY(0) scale(0.98);
}

.menu-btn {
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(91, 158, 255, 0.4);
    letter-spacing: 0.03em;
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(91, 158, 255, 0.6);
}

.menu-btn:active {
    transform: translateY(0);
}

/* Pause Button */
.btn-settings {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(91, 158, 255, 0.12);
    border: 1px solid rgba(91, 158, 255, 0.3);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    z-index: 40;
    transition: all 0.2s ease;
}

.btn-settings:hover {
    background: rgba(91, 158, 255, 0.25);
    color: #fff;
    border-color: rgba(91, 158, 255, 0.6);
}

#btn-pause {
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    font-size: 17px !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================================
   BOTTOM NAVIGATION
   =================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 68px;
    background: linear-gradient(0deg,
        rgba(7, 8, 26, 0.98) 0%,
        rgba(13, 15, 38, 0.96) 100%);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid rgba(91, 158, 255, 0.15);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Subtle top glow line on nav */
.bottom-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(91, 158, 255, 0.4),
        rgba(77, 232, 209, 0.3),
        rgba(91, 158, 255, 0.4),
        transparent);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(140, 160, 200, 0.6);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    flex: 1;
    height: 100%;
    gap: 3px;
}

.nav-item.active {
    color: var(--color-accent);
}

.nav-item:hover {
    color: var(--color-accent);
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 20px;
    line-height: 1;
    transition: filter 0.2s ease;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    filter: drop-shadow(0 0 6px var(--color-accent));
}

.nav-label {
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ===================================================
   MISSION HUD / TIME ATTACK HUD
   =================================================== */
.mission-hud {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg,
        rgba(13, 15, 38, 0.88) 0%,
        rgba(7, 8, 26, 0.92) 100%);
    padding: 7px 18px;
    border-radius: 24px;
    border: 1px solid rgba(91, 158, 255, 0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 10;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.3), 0 0 20px rgba(91,158,255,0.1);
}

.mission-hud-text {
    font-size: 12px;
    font-weight: 600;
    color: #c0d4ff;
}

.time-attack-hud {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
}

.timer-display {
    font-family: 'Fredoka One', cursive;
    font-size: 36px;
    color: var(--color-gold);
    text-shadow: 0 0 20px rgba(255, 204, 68, 0.7);
    min-width: 72px;
    text-align: center;
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.85; }
}

/* ===================================================
   MISSION GRID (CHALLENGE SELECT)
   =================================================== */
.mission-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    max-width: 820px;
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.mission-card {
    background: linear-gradient(145deg,
        rgba(255,255,255,0.045) 0%,
        rgba(91,158,255,0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
    text-align: left;
    position: relative;
    backdrop-filter: blur(6px);
}

.mission-card:hover {
    background: rgba(91, 158, 255, 0.1);
    border-color: rgba(91, 158, 255, 0.4);
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 16px rgba(91,158,255,0.15);
}

.mission-card.completed {
    border-color: rgba(77, 232, 209, 0.45);
    background: rgba(77, 232, 209, 0.07);
}

.mission-card.locked {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(1);
}

.mission-title {
    font-weight: 700;
    color: #e8f0ff;
    margin-bottom: 5px;
    font-size: 13px;
}

.mission-desc {
    font-size: 11px;
    color: rgba(160, 185, 220, 0.8);
}

.mission-status {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 15px;
}

/* ===================================================
   SETTINGS & HELP SCREENS
   =================================================== */
.htp-content {
    width: min(100%, 900px);
    margin: 0 auto;
    padding: 6px 12px 130px;
}

#screen-help {
    justify-content: flex-start !important;
    align-items: center;
    padding-top: 84px !important;
    padding-bottom: 120px !important;
}

#screen-help .htp-section {
    background: rgba(13, 15, 38, 0.55) !important;
    border: 1px solid rgba(91, 158, 255, 0.1) !important;
    border-radius: 14px;
    padding: 14px 16px !important;
    margin-bottom: 14px;
}

#screen-help .htp-section h3 {
    margin: 0 0 12px;
    color: var(--color-accent);
    letter-spacing: 0.04em;
    font-size: 12px;
    text-transform: uppercase;
}

#screen-help .htp-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 14px;
    padding: 4px 0;
    color: rgba(200, 220, 255, 0.88);
}

#screen-help .htp-row[data-tip] {
    cursor: pointer;
    border-radius: 6px;
    padding: 5px 6px;
    transition: background 0.15s ease;
}

#screen-help .htp-row[data-tip]:hover {
    background: rgba(91, 158, 255, 0.08);
}

/* ===================================================
   MODALS (COMBO, GAME OVER, SETTINGS)
   =================================================== */

/* Combo Modal Ticker */
.combo-modal {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(255, 204, 68, 0.15);
    border: 2px solid var(--color-gold);
    color: var(--color-gold);
    padding: 12px 32px;
    border-radius: 40px;
    font-family: 'Fredoka One', sans-serif;
    font-size: 32px;
    letter-spacing: 0.1em;
    text-shadow: 0 0 16px var(--color-gold);
    box-shadow: 0 0 24px rgba(255, 204, 68, 0.3);
    pointer-events: none;
    opacity: 0;
    z-index: 3000;
    backdrop-filter: blur(10px);
}

.combo-modal.show {
    animation: comboPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes comboPop {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    20%  { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
    80%  { opacity: 1; transform: translate(-50%, -65%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(0.8); }
}

/* Polished Game Over Overlay */
.overlay-content-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.gameover-modern-tag {
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--color-danger);
    text-transform: uppercase;
    font-weight: 800;
    margin-bottom: -12px;
}

/* In-Game Settings Modal */
.in-game-settings {
    position: fixed;
    inset: 0;
    background: rgba(7, 8, 26, 0.94);
    backdrop-filter: blur(12px);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.in-game-settings.show {
    opacity: 1;
    pointer-events: auto;
}

.settings-card {
    background: rgba(18, 20, 50, 0.85);
    border: 1px solid rgba(91, 158, 255, 0.3);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    padding: 28px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6);
}

/* Coach HUD/Ticker */
.coach-hud {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    min-width: 280px;
    background: rgba(13, 15, 38, 0.9);
    border: 1px solid rgba(77, 232, 209, 0.45);
    border-radius: 8px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #e7f4ff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.coach-hud.show {
    opacity: 1;
    top: -48px;
}

.coach-hud-icon {
    font-size: 14px;
    color: var(--color-teal);
    filter: drop-shadow(0 0 6px var(--color-teal));
}

/* Block Type Grid */
.htp-block-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.htp-block-card {
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(91, 158, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    transition: background 0.2s ease;
}

.htp-block-card:hover {
    background: rgba(91, 158, 255, 0.06);
}

.htp-name {
    font-weight: 700;
    font-size: 12px;
    margin-top: 8px;
    color: #e8f0ff;
}

.htp-note {
    font-size: 10px;
    color: rgba(160, 190, 220, 0.75);
    margin-top: 3px;
}

/* Block Chips */
.htp-chip {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border-radius: 10px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow: inset 0 8px 14px rgba(255,255,255,0.1);
    color: rgba(0,0,0,0.35);
}

.htp-chip.c1 { background: #ff6b6b; }
.htp-chip.c2 { background: #ff922b; }
.htp-chip.c3 { background: #fcc419; }
.htp-chip.c4 { background: #b197fc; }
.htp-chip.c5 { background: #66d9e8; }
.htp-chip.c6 { background: #4dabf7; }
.htp-chip.bomb  { background: #1e2029; color: #ff8e98; border-color: rgba(255,66,98,0.35); }
.htp-chip.drill { background: #c0c0c0; color: rgba(50,60,72,0.7); }
.htp-chip.metal {
    background: linear-gradient(135deg, #66d9e8 0%, #4dabf7 100%);
    color: rgba(255,255,255,0.95);
    border-color: rgba(255,255,255,0.32);
}
.htp-chip.frosted { background: #66d9e8; position: relative; }
.htp-chip.frosted::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: rgba(255,255,255,0.92);
    transform: rotate(45deg);
    box-shadow: 0 0 12px rgba(255,255,255,0.45);
}
.htp-chip.dead { background: #3a3e45; color: #d0d0d0; }

/* Shapes */
.shape { display: block; width: 18px; height: 18px; }
.shape-circle   { border-radius: 50%; background: currentColor; }
.shape-square   { background: currentColor; }
.shape-diamond  { width: 16px; height: 16px; transform: rotate(45deg); background: currentColor; }
.shape-hex      { width: 16px; height: 18px; background: currentColor;
                  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.shape-triangle { width: 0; height: 0;
                  border-left: 10px solid transparent;
                  border-right: 10px solid transparent;
                  border-bottom: 16px solid currentColor; }
.shape-plus { position: relative; }
.shape-plus::before, .shape-plus::after {
    content: ''; position: absolute; background: currentColor;
}
.shape-plus::before { width: 18px; height: 6px; left: 0; top: 6px; }
.shape-plus::after  { width: 6px; height: 18px; left: 6px; top: 0; }
.shape-bomb   { font-weight: 900; font-size: 20px; line-height: 1; }
.shape-drill  { width: 0; height: 0;
                border-left: 10px solid transparent;
                border-right: 10px solid transparent;
                border-top: 16px solid currentColor; }
.shape-metal  { font-size: 18px; line-height: 1; width: auto; height: auto; }
.shape-frosted {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.95);
    border-radius: 4px;
    transform: rotate(45deg);
    background: rgba(255,255,255,0.15);
}
.shape-dead { font-weight: 900; font-size: 17px; line-height: 1; width: auto; height: auto; }

/* Settings Screen */
.htp-section {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 20px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(91, 158, 255, 0.1);
    width: 100%;
    max-width: 340px;
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    color: rgba(220, 230, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
}

.setting-slider {
    width: 160px;
    accent-color: var(--color-accent);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    transition: 0.35s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: '';
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background-color: white;
    transition: 0.35s;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

input:checked + .slider {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-2));
    border-color: var(--color-accent);
    box-shadow: 0 0 10px rgba(91, 158, 255, 0.4);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* ===================================================
   COUNTDOWN OVERLAY
   =================================================== */
#countdown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 8, 26, 0.88);
    backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: fadeIn 0.25s ease-out;
}

#countdown-overlay.hidden {
    display: none;
}

#countdown-number {
    font-family: 'Fredoka One', cursive;
    font-size: 130px;
    color: var(--color-accent);
    text-shadow:
        0 0 40px rgba(91, 158, 255, 0.9),
        0 0 80px rgba(91, 158, 255, 0.5),
        0 0 120px rgba(91, 158, 255, 0.2);
    animation: countdownPulse 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes countdownPulse {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ===================================================
   MISC ANIMATIONS
   =================================================== */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-10px); }
}

@keyframes flip {
    0%   { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.flip { animation: flip 0.6s ease-in-out; }

@keyframes shake {
    0%  { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100%{ transform: translate(1px, -2px) rotate(-1deg); }
}

.shake { animation: shake 0.5s; }

@keyframes shake-subtle {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(0, 2px); }
    50%  { transform: translate(0, -1px); }
    75%  { transform: translate(0, 1px); }
    100% { transform: translate(0, 0); }
}

.shake-subtle { animation: shake-subtle 0.2s ease-out; }

/* ===================================================
   MOBILE CONTROLS
   =================================================== */
.mobile-controls {
    display: none;
    width: 100%;
    max-width: 400px;
    justify-content: center;
    gap: 30px;
    margin-top: 16px;
}

.control-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(91, 158, 255, 0.1);
    border: 2px solid rgba(91, 158, 255, 0.25);
    color: white;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    touch-action: manipulation;
    user-select: none;
    transition: all 0.15s ease;
}

.control-btn:active {
    background: rgba(91, 158, 255, 0.3);
    transform: scale(0.93);
    box-shadow: 0 0 16px rgba(91, 158, 255, 0.4);
}

/* ===================================================
   ADS BANNER
   =================================================== */
.ad-banner-container {
    width: 100%;
    min-height: 56px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px dashed rgba(91, 158, 255, 0.12);
}

.ads-banner {
    width: 100%;
    max-width: 350px;
    background: linear-gradient(90deg, #f0b429, #e67e22);
    color: #1a1a2e;
    padding: 12px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 80px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(240, 180, 41, 0.35);
    transition: transform 0.2s;
}

.ads-banner:active {
    transform: scale(0.98);
}

/* Footer */
.footer {
    margin-top: 14px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===================================================
   PREVIEW / HOLD CANVAS
   =================================================== */
#preview-canvas {
    margin: 0 auto;
    background: transparent;
}

/* Hold panel tap hint on mobile */
@media (max-width: 768px) {
    #hold-panel {
        border: 2px solid var(--color-accent) !important;
        box-shadow: 0 0 12px rgba(91, 158, 255, 0.3);
        cursor: pointer;
        transition: all 0.2s;
    }
    #hold-panel:active {
        transform: scale(0.95);
        box-shadow: 0 0 20px rgba(91, 158, 255, 0.6);
    }
}

/* ===================================================
   RESPONSIVE — MOBILE
   =================================================== */
@media (max-width: 767px) {
    #app-root {
        height: 100dvh;
        padding: calc(env(safe-area-inset-top) + 6px) 8px calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom) + 6px);
    }

    .game-layout {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .board-container {
        order: 1;
        margin-inline: auto;
        max-width: calc(100vw - 16px);
    }

    .side-panel {
        order: 2;
        flex-direction: row;
        flex-wrap: nowrap;
        width: 100%;
        justify-content: center;
        align-items: stretch;
        gap: 6px;
    }

    /* Compact stats into one row alongside hold/next */
    .stats-combined {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        padding: 6px 8px;
    }

    .stats-combined .stats-grid {
        display: flex;
        flex-direction: row;
        gap: 6px;
    }

    .stats-combined .stat-cell {
        padding: 4px 6px;
        flex: 1;
    }

    .stats-combined #score-display,
    .stats-combined #level-display {
        font-size: 16px !important;
    }

    /* Hide diamonds and reroll on mobile to save vertical space */
    #diamonds-stat-cell,
    #diamond-reroll-btn,
    #reroll-bar-wrap { display: none !important; }

    /* Compact hold/next */
    .compact-box {
        flex: 0 0 auto;
        min-height: 0;
        padding: 5px 6px;
        min-width: 56px;
    }

    .compact-box canvas {
        width: 56px !important;
        height: 36px !important;
    }

    .panel-box {
        padding: 6px;
        flex: 1;
        min-width: 0;
        min-height: 0;
    }

    .mobile-controls {
        display: flex;
        margin-top: 4px;
        gap: 16px;
    }

    .control-btn {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    .tutorial-box-mobile-hidden {
        display: none;
    }

    .menu-logo {
        width: clamp(160px, 72vw, 280px);
        margin-bottom: 28px;
    }

    .mode-cards-container {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: 12px;
    }

    .mode-card {
        flex-direction: row !important;
        text-align: left !important;
        padding: 14px 18px !important;
        align-items: center;
        gap: 16px;
    }

    .mode-icon {
        flex-shrink: 0;
        margin-bottom: 0 !important;
    }

    .mode-card h3 { margin: 0 0 3px; font-size: 14px; }
    .mode-card p  { font-size: 11px; }

    .bottom-nav {
        height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom));
        padding-bottom: max(env(safe-area-inset-bottom), 6px);
    }

    .nav-item { min-height: 60px; }

    /* Hide Help tab on mobile */
    .nav-item-help { display: none !important; }

    #btn-pause {
        top: calc(env(safe-area-inset-top) + 8px) !important;
        right: 10px !important;
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }

    .gameover-actions .btn-start,
    #overlay-controls .btn-start,
    .menu-btn { min-height: 44px; }

    #countdown-number { font-size: 90px; }

    #screen-help {
        padding-top: 70px !important;
        padding-bottom: 118px !important;
    }

    .htp-content {
        padding: 4px 6px 138px;
    }

    .htp-block-grid {
        grid-template-columns: 1fr 1fr;
    }

    #screen-help .htp-row {
        font-size: 13px;
    }
}

/* ===================================================
   RESPONSIVE — TABLET
   =================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
        padding: 16px;
    }

    .side-panel {
        width: 100%;
        max-width: 500px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
        order: 2;
        margin-top: 16px;
    }

    .stats-combined {
        flex: 1 1 100%;
        max-width: 500px;
    }

    .controls-footer {
        width: min(100%, 720px);
    }

    .controls-footer .tutorial-content {
        grid-template-columns: 1fr;
    }

    .controls-footer .separator {
        display: none;
    }

    .board-container { order: 1; }
    .mobile-controls { display: none; }

    .mode-cards-container {
        grid-template-columns: repeat(2, 1fr);
        max-width: 540px;
    }

    .htp-block-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ad-banner-container { min-height: 50px; margin-top: 10px; }
}

/* ===================================================
   RESPONSIVE — DESKTOP
   =================================================== */
@media (min-width: 1025px) {
    .game-layout {
        flex-direction: row;
        align-items: flex-start;
    }

    .side-panel {
        width: 185px;
        flex-direction: column;
    }

    .mobile-controls { display: none !important; }

    .mode-cards-container {
        grid-template-columns: repeat(2, 1fr);
        max-width: 560px;
    }
}

@media (min-width: 1600px) {
    .game-layout {
        max-width: 1400px;
        margin: 0 auto;
    }
    .side-panel { width: 200px; }
}

/* ===================================================
   SCREEN / VIEWPORT OVERRIDES
   =================================================== */
.screen, .htp-content { touch-action: pan-y; }

#phaser-game-container,
#phaser-game-container canvas,
.board-container { touch-action: none; }

/* ===================================================
   SCREEN PAGE HEADER (shared by Help / News / Settings)
   =================================================== */
.screen-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(91, 158, 255, 0.15);
    width: 100%;
}

.screen-page-icon {
    font-size: 28px;
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(91, 158, 255, 0.5));
}

.screen-page-title {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: clamp(20px, 3vw, 28px);
    font-weight: 800;
    letter-spacing: 0.06em;
    background: linear-gradient(135deg, #e8f0ff 0%, var(--color-accent) 70%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===================================================
   HELP SCREEN — SECTION HEADERS
   =================================================== */
#screen-help .htp-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px !important;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-accent) !important;
    margin: 0 0 10px !important;
}

.htp-section-icon {
    font-size: 14px;
    opacity: 0.85;
}

/* ===================================================
   HELP SCREEN — HTP ROWS (improved layout)
   =================================================== */
#screen-help .htp-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(91, 158, 255, 0.06);
}

#screen-help .htp-row:last-child {
    border-bottom: none;
}

#screen-help .htp-row[data-tip]:hover {
    background: rgba(91, 158, 255, 0.07);
}

.htp-row-label {
    color: rgba(220, 230, 255, 0.92);
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.htp-row-desc {
    color: rgba(160, 185, 220, 0.75);
    font-size: 12px;
    text-align: right;
    font-style: italic;
}

.htp-row-keys {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.htp-or {
    font-size: 10px;
    color: rgba(160, 185, 220, 0.5);
    font-style: italic;
}

/* ===================================================
   KEY BADGES (keyboard-style chips)
   =================================================== */
.key-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg,
        rgba(91, 158, 255, 0.18) 0%,
        rgba(91, 158, 255, 0.08) 100%);
    border: 1px solid rgba(91, 158, 255, 0.35);
    border-bottom-width: 2px;
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #b8d4ff;
    letter-spacing: 0.04em;
    font-family: 'Poppins', sans-serif;
    min-width: 28px;
    text-align: center;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), 0 0 8px rgba(91, 158, 255, 0.1);
    white-space: nowrap;
}

/* ===================================================
   LIVE COACH BOX – enhanced badge
   =================================================== */
.teach-badge {
    background: rgba(91, 158, 255, 0.18);
    border: 1px solid rgba(91, 158, 255, 0.3);
    border-radius: 20px;
    padding: 2px 9px;
    font-size: 10px;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 0.05em;
}

/* ===================================================
   MODES GRID (pill cards in Help > Modes)
   =================================================== */
.htp-modes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.htp-mode-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: linear-gradient(145deg,
        rgba(255,255,255,0.04) 0%,
        rgba(91,158,255,0.025) 100%);
    border: 1px solid rgba(91, 158, 255, 0.14);
    border-radius: 12px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.htp-mode-pill:hover {
    background: rgba(91, 158, 255, 0.08);
    border-color: rgba(91, 158, 255, 0.3);
}

.htp-mode-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
}

.htp-mode-pill strong {
    display: block;
    font-size: 13px;
    color: #e8f0ff;
    margin-bottom: 2px;
}

.htp-mode-pill p {
    margin: 0;
    font-size: 10px;
    color: rgba(160, 185, 220, 0.7);
    line-height: 1.3;
}

/* ===================================================
   CHANGELOG VERSION BADGES
   =================================================== */
.changelog-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: rgba(91, 158, 255, 0.15);
    border: 1px solid rgba(91, 158, 255, 0.3);
    color: var(--color-accent);
    margin-right: 4px;
    vertical-align: middle;
}

.changelog-badge.latest {
    background: rgba(77, 232, 209, 0.15);
    border-color: rgba(77, 232, 209, 0.35);
    color: var(--color-teal);
}

/* ===================================================
   SETTINGS SCREEN LAYOUT
   =================================================== */
#screen-settings {
    justify-content: flex-start !important;
    align-items: center;
    padding-top: 80px !important;
    padding-bottom: 100px !important;
}

.settings-content {
    width: min(100%, 560px);
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Settings Group Card */
.settings-group {
    background: linear-gradient(160deg,
        rgba(255,255,255,0.045) 0%,
        rgba(91,158,255,0.02) 100%);
    border: 1px solid rgba(91, 158, 255, 0.14);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 14px;
}

.settings-group-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.8;
    padding: 10px 16px 8px;
    border-bottom: 1px solid rgba(91, 158, 255, 0.1);
    background: rgba(91, 158, 255, 0.04);
}

/* Setting Row — new layout */
.settings-content .setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid rgba(91, 158, 255, 0.07);
    gap: 16px;
    width: 100%;
    max-width: none;
    margin-bottom: 0;
    box-sizing: border-box;
}

.settings-content .setting-row:last-child {
    border-bottom: none;
}

.settings-content .setting-row:hover {
    background: rgba(91, 158, 255, 0.04);
}

/* Label + sublabel stack */
.setting-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.settings-content .setting-label {
    font-size: 14px;
    font-weight: 600;
    color: rgba(220, 232, 255, 0.92);
}

.setting-sublabel {
    font-size: 11px;
    color: rgba(140, 165, 210, 0.65);
    font-weight: 400;
}

/* Slider — wider and right-aligned */
.settings-content .setting-slider {
    width: 140px;
    flex-shrink: 0;
    accent-color: var(--color-accent);
    cursor: pointer;
}

/* Back button in settings */
.settings-back-btn {
    margin-top: 8px;
    width: 100%;
    text-align: center;
    padding: 13px 24px;
}

/* Settings credit line */
.settings-credit {
    margin-top: 12px;
    text-align: center;
    font-size: 11px;
    color: rgba(120, 140, 180, 0.5);
}

/* ===================================================
   NEWS SCREEN
   =================================================== */
#screen-news {
    justify-content: flex-start !important;
    align-items: center;
    padding-top: 80px !important;
    padding-bottom: 100px !important;
}

/* ===================================================
   RESPONSIVE ADDITIONS
   =================================================== */
@media (max-width: 767px) {
    .htp-modes-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .settings-content {
        width: 100%;
        padding: 0 4px;
    }

    .settings-content .setting-slider {
        width: 110px;
    }

    .screen-page-title {
        font-size: 20px;
    }

    .key-badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    #screen-settings {
        padding-top: 70px !important;
        padding-bottom: 90px !important;
    }

    #screen-news {
        padding-top: 70px !important;
        padding-bottom: 90px !important;
    }
}

@media (max-width: 480px) {
    .htp-row-desc {
        font-size: 11px;
    }
}
