/* ============================================
   BLOCK BLAST - Styles (Enhanced v2)
   ============================================ */

:root {
    --bg-primary: #4A5AC7;
    --bg-secondary: #3D4DB5;
    --bg-dark: #2C3A8C;
    --board-bg: #1A1A3E;
    --board-border: #2A2A5E;
    --cell-empty: rgba(255,255,255,0.04);
    --cell-border: rgba(255,255,255,0.06);
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255,255,255,0.7);
    --accent-gold: #FFD700;

    --color-orange-light: #FFBE76;
    --color-orange: #FF9F43;
    --color-orange-dark: #E17055;
    --color-green-light: #7BED9F;
    --color-green: #2ED573;
    --color-green-dark: #009432;
    --color-blue-light: #74B9FF;
    --color-blue: #54A0FF;
    --color-blue-dark: #2E86DE;
    --color-purple-light: #C77DFF;
    --color-purple: #A55EEA;
    --color-purple-dark: #8854D0;
    --color-cyan-light: #81ECEC;
    --color-cyan: #48DBFB;
    --color-cyan-dark: #0ABDE3;
    --color-red-light: #FF8787;
    --color-red: #FF6B6B;
    --color-red-dark: #EE5A24;
    --color-yellow-light: #FFF3A3;
    --color-yellow: #FECA57;
    --color-yellow-dark: #F39C12;

    --shake-intensity: 3px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-dark) 100%);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image:
        radial-gradient(2px 2px at 10% 20%, rgba(255,255,255,0.15), transparent),
        radial-gradient(2px 2px at 30% 70%, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 50% 40%, rgba(255,255,255,0.12), transparent),
        radial-gradient(2px 2px at 70% 80%, rgba(255,255,255,0.08), transparent),
        radial-gradient(3px 3px at 80% 10%, rgba(255,255,255,0.1), transparent),
        radial-gradient(2px 2px at 90% 50%, rgba(255,255,255,0.12), transparent),
        radial-gradient(2px 2px at 20% 90%, rgba(255,255,255,0.08), transparent),
        radial-gradient(3px 3px at 60% 15%, rgba(255,255,255,0.1), transparent);
    animation: bgFloat 20s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes bgFloat {
    0% { transform: translateY(0) translateX(0); }
    50% { transform: translateY(-15px) translateX(8px); }
    100% { transform: translateY(5px) translateX(-5px); }
}

/* ===== SCREEN FLASH ===== */
#screen-flash {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
}

#screen-flash.flash-gold {
    animation: screenFlashGold 0.4s ease-out forwards;
}

#screen-flash.flash-white {
    animation: screenFlashWhite 0.3s ease-out forwards;
}

@keyframes screenFlashGold {
    0%   { opacity: 0.5; background: radial-gradient(circle, rgba(255,215,0,0.4), rgba(255,107,107,0.2)); }
    100% { opacity: 0; }
}

@keyframes screenFlashWhite {
    0%   { opacity: 0.35; background: rgba(255,255,255,0.4); }
    100% { opacity: 0; }
}

/* Combo background pulse */
body.combo-pulse {
    animation: bgPulse 0.5s ease-out;
}

@keyframes bgPulse {
    0%   { filter: brightness(1.25) saturate(1.2); }
    100% { filter: brightness(1) saturate(1); }
}

/* ===== GAME CONTAINER ===== */
#game-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 12px 16px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}

/* ===== HEADER ===== */
#header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    margin-bottom: 8px;
    gap: 8px;
}

#best-score-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.crown-icon {
    font-size: 18px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

#current-score-box {
    text-align: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

#current-score {
    font-size: 48px;
    font-weight: 900;
    text-shadow: 0 3px 12px rgba(0,0,0,0.3);
    line-height: 1;
    transition: transform 0.15s ease, font-size 0.2s ease;
    white-space: nowrap;
}

#current-score.bump {
    transform: scale(1.15);
}

#header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#settings-btn, #restart-header-btn {
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

#settings-btn:hover, #restart-header-btn:hover {
    background: rgba(255,255,255,0.25);
}

#restart-header-btn:active {
    transform: scale(0.9) rotate(-90deg);
}

.modal-small {
    max-width: 300px;
}

/* ===== COMBO DISPLAY ===== */
#combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    pointer-events: none;
}

#combo-label {
    font-size: 20px;
    font-weight: 800;
    color: #FFF;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    margin-bottom: 2px;
}

#combo-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#combo-number {
    font-size: 72px;
    font-weight: 900;
    background: linear-gradient(180deg, #FFD700, #FF6B6B);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 4px 12px rgba(255,107,107,0.5));
    line-height: 1;
}

#combo-display.animate {
    animation: comboIn 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ===== SCORE POPUP ===== */
#score-popup {
    position: absolute;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent-gold);
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    pointer-events: none;
    z-index: 99;
}

#score-popup.animate {
    animation: scoreFloat 1.2s ease-out forwards;
}

/* ===== BOARD ===== */
#board-wrapper {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
    margin: 4px 0;
    flex-shrink: 0;
    flex-grow: 0;
}

#board {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 3px;
    padding: 8px;
    background: var(--board-bg);
    border-radius: 16px;
    border: 3px solid var(--board-border);
    box-shadow:
        0 8px 32px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.05);
    position: relative;
    z-index: 1;
}

#board.no-grid .board-cell:not([data-color]) {
    background: transparent;
    border-color: transparent;
}

.board-cell {
    border-radius: 4px;
    background: var(--cell-empty);
    border: 1px solid var(--cell-border);
    position: relative;
    transition: background 0.1s, transform 0.1s, box-shadow 0.2s;
}

/* ===== GHOST PREVIEW - Colored with pulse ===== */
.board-cell.ghost {
    border: 2px solid rgba(255,255,255,0.6);
    opacity: 0.7;
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.3),
        inset 0 -2px 0 rgba(0,0,0,0.15),
        0 0 12px rgba(255,255,255,0.3),
        0 0 4px rgba(255,255,255,0.2);
    animation: ghostPulse 0.8s ease-in-out infinite alternate;
}

.board-cell.ghost-invalid {
    border: 2px dashed rgba(255,80,80,0.7);
    background: rgba(255,80,80,0.2) !important;
    opacity: 0.6;
}

@keyframes ghostPulse {
    0% { opacity: 0.6; }
    100% { opacity: 0.8; }
}

/* ===== FILLED BLOCKS ===== */
.board-cell.filled {
    border: none;
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.35),
        inset 0 -2px 0 rgba(0,0,0,0.2),
        0 2px 4px rgba(0,0,0,0.25);
}

.board-cell.filled.place-anim {
    animation: blockPlace 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* ===== PRE-CLEAR GLOW ===== */
.board-cell.pre-clear {
    animation: preClearGlow 0.25s ease-in-out 2;
}

@keyframes preClearGlow {
    0%, 100% { box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), inset 0 -2px 0 rgba(0,0,0,0.2), 0 0 0 0 rgba(255,255,255,0); }
    50%      { box-shadow: inset 0 2px 0 rgba(255,255,255,0.35), inset 0 -2px 0 rgba(0,0,0,0.2), 0 0 16px 4px rgba(255,255,255,0.5); }
}

/* ===== LINE CLEAR ===== */
.board-cell.clear-anim {
    animation: lineClear 0.5s ease-out forwards;
}

/* ===== SHOCKWAVE ===== */
.shockwave {
    position: absolute;
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    pointer-events: none;
    z-index: 3;
    animation: shockwave 0.7s ease-out forwards;
}

@keyframes shockwave {
    0%   { transform: translate(-50%, -50%) scale(0); opacity: 0.8; border-width: 3px; }
    100% { transform: translate(-50%, -50%) scale(6); opacity: 0; border-width: 1px; }
}

/* ===== Near-complete hint ===== */
.board-cell.near-hint {
    animation: nearHint 1.2s ease-in-out infinite;
    border: 1px solid rgba(255,215,0,0.3);
}

@keyframes nearHint {
    0%, 100% {
        box-shadow: inset 0 0 4px 1px rgba(255,215,0,0.1);
        background: rgba(255,215,0,0.03);
    }
    50% {
        box-shadow: inset 0 0 10px 3px rgba(255,215,0,0.4), 0 0 6px rgba(255,215,0,0.2);
        background: rgba(255,215,0,0.1);
    }
}

/* Block colors */
.color-orange { background: linear-gradient(135deg, var(--color-orange-light), var(--color-orange), var(--color-orange-dark)) !important; }
.color-green { background: linear-gradient(135deg, var(--color-green-light), var(--color-green), var(--color-green-dark)) !important; }
.color-blue { background: linear-gradient(135deg, var(--color-blue-light), var(--color-blue), var(--color-blue-dark)) !important; }
.color-purple { background: linear-gradient(135deg, var(--color-purple-light), var(--color-purple), var(--color-purple-dark)) !important; }
.color-cyan { background: linear-gradient(135deg, var(--color-cyan-light), var(--color-cyan), var(--color-cyan-dark)) !important; }
.color-red { background: linear-gradient(135deg, var(--color-red-light), var(--color-red), var(--color-red-dark)) !important; }
.color-yellow { background: linear-gradient(135deg, var(--color-yellow-light), var(--color-yellow), var(--color-yellow-dark)) !important; }

/* Particle Canvas */
#particle-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* ===== PIECES PANEL ===== */
#pieces-panel {
    width: 100%;
    max-width: 420px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 16px 8px;
    margin-top: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    min-height: 100px;
    flex-shrink: 0;
}

.piece-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    min-height: 80px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    padding: 8px;
}

.piece-slot:active {
    transform: scale(0.95);
}

.piece-slot.used {
    opacity: 0;
    pointer-events: none;
}

.piece-slot.appear {
    animation: pieceAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.piece-grid {
    display: grid;
    gap: 2px;
}

.piece-cell {
    border-radius: 3px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 0 -1px 0 rgba(0,0,0,0.2),
        0 1px 2px rgba(0,0,0,0.2);
}

.piece-cell.empty {
    background: transparent !important;
    box-shadow: none;
}

/* ===== DRAG GHOST ===== */
#drag-ghost {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    transition: none;
    opacity: 0.92;
    filter: drop-shadow(0 6px 20px rgba(0,0,0,0.35));
}

#drag-ghost .piece-grid {
    gap: 3px;
}

#drag-ghost .piece-cell {
    border-radius: 4px;
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,0.35),
        inset 0 -2px 0 rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,0.4);
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: linear-gradient(180deg, #5B6BD6 0%, #4A5AC7 100%);
    border-radius: 24px;
    padding: 32px 28px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.15);
    animation: modalIn 0.3s ease-out;
    text-align: center;
}

.modal-large {
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 { font-size: 22px; }
.modal h2 { font-size: 28px; font-weight: 900; margin-bottom: 16px; }

.close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.close-btn:hover { background: rgba(255,255,255,0.25); }

/* Game Over Modal */
#gameover-modal {
    text-align: center;
}

#gameover-modal h2 {
    margin-bottom: 8px;
}

#final-score-display { margin: 12px 0 16px; }
.final-score-label { font-size: 16px; color: var(--text-secondary); margin-bottom: 4px; }

#final-score {
    font-size: 56px;
    font-weight: 900;
    background: linear-gradient(180deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    word-break: break-all;
}

#final-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 12px 0 20px;
}
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-value { font-size: 28px; font-weight: 800; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

#name-input-section {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#player-name {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

#player-name::placeholder { color: rgba(255,255,255,0.4); }
#player-name:focus { border-color: rgba(255,255,255,0.5); }

#submit-score-btn {
    padding: 10px 16px;
    background: var(--accent-gold);
    color: #333;
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.2s;
}

#submit-score-btn:hover { background: #FFE44D; transform: scale(1.05); }
#submit-score-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#submit-result { margin-bottom: 12px; font-size: 15px; font-weight: 700; color: var(--accent-gold); }

/* Share Section */
#share-section {
    margin-bottom: 16px;
    text-align: center;
}

.share-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#share-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.share-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.share-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.1); }
.share-btn:active { transform: scale(0.95); }

#share-toast {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-gold);
    animation: toastFade 1.5s ease-out forwards;
}

@keyframes toastFade {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
}

.modal-buttons { display: flex; gap: 10px; }

.btn-primary {
    flex: 1; padding: 14px;
    background: linear-gradient(180deg, #FF6B6B, #EE5A24);
    color: white; border: none; border-radius: 14px;
    font-size: 18px; font-weight: 800; font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(238,90,36,0.4);
    transition: transform 0.15s;
}

.btn-primary:hover { transform: scale(1.03); }

.btn-secondary {
    flex: 1; padding: 14px;
    background: rgba(255,255,255,0.15);
    color: white; border: 1px solid rgba(255,255,255,0.2);
    border-radius: 14px;
    font-size: 16px; font-weight: 700; font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.btn-secondary:hover { background: rgba(255,255,255,0.25); transform: scale(1.03); }

/* Leaderboard */
#leaderboard-content { overflow-y: auto; flex: 1; }
#leaderboard-loading { padding: 40px; font-size: 18px; color: var(--text-secondary); }
#leaderboard-table { width: 100%; border-collapse: collapse; font-size: 14px; }

#leaderboard-table thead th {
    padding: 10px 8px; text-align: left; font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: sticky; top: 0; background: #5B6BD6; z-index: 1;
}

#leaderboard-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}

#leaderboard-table tbody tr:hover { background: rgba(255,255,255,0.05); }
#leaderboard-table td { padding: 10px 8px; font-weight: 600; }
#leaderboard-table .rank-cell { width: 40px; font-weight: 800; }
.rank-1 { color: #FFD700; }
.rank-2 { color: #C0C0C0; }
.rank-3 { color: #CD7F32; }
.country-flag { margin-right: 4px; font-size: 16px; }

/* Settings */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.setting-row span { font-size: 16px; font-weight: 600; }
hr { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 16px 0; }

.toggle { position: relative; display: inline-block; width: 50px; height: 28px; }
.toggle input { display: none; }

.toggle-slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 28px; transition: background 0.3s;
}

.toggle-slider::before {
    content: ''; position: absolute;
    width: 22px; height: 22px; left: 3px; bottom: 3px;
    background: white; border-radius: 50%;
    transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider { background: #2ED573; }
.toggle input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== ANIMATIONS ===== */
@keyframes blockPlace {
    0%   { transform: scale(0) rotate(-5deg); opacity: 0; }
    40%  { transform: scale(1.2, 0.85) rotate(2deg); opacity: 1; }
    60%  { transform: scale(0.9, 1.1) rotate(-1deg); }
    80%  { transform: scale(1.05, 0.97); }
    100% { transform: scale(1) rotate(0); }
}

@keyframes lineClear {
    0%   { transform: scale(1); opacity: 1; filter: brightness(1); }
    15%  { transform: scale(1.08); filter: brightness(2.5); background: rgba(255,255,255,0.9) !important; }
    30%  { transform: scale(1.12); filter: brightness(2); }
    50%  { transform: scale(1.05); filter: brightness(1.5); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; filter: brightness(0.5); }
}

@keyframes comboIn {
    0%   { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; }
    30%  { transform: translate(-50%, -50%) scale(1.3) rotate(5deg); opacity: 1; }
    50%  { transform: translate(-50%, -50%) scale(0.9) rotate(-2deg); opacity: 1; }
    65%  { transform: translate(-50%, -50%) scale(1.1) rotate(1deg); opacity: 1; }
    80%  { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.95) rotate(0); opacity: 0; }
}

@keyframes scoreFloat {
    0%   { transform: translateY(0) scale(1); opacity: 1; }
    40%  { transform: translateY(-30px) scale(1.3); opacity: 1; }
    100% { transform: translateY(-90px) scale(1.5); opacity: 0; }
}

@keyframes pieceAppear {
    0%   { transform: scale(0) translateY(20px) rotate(-8deg); opacity: 0; }
    50%  { transform: scale(1.15) translateY(-6px) rotate(3deg); opacity: 1; }
    75%  { transform: scale(0.95) translateY(2px) rotate(-1deg); }
    100% { transform: scale(1) translateY(0) rotate(0); }
}

@keyframes modalIn {
    0%   { transform: scale(0.8) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Board shake - intensity controlled via CSS variable */
@keyframes boardShake {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    10%  { transform: translate(calc(var(--shake-intensity) * -1), calc(var(--shake-intensity) * -0.7)) rotate(-0.3deg); }
    20%  { transform: translate(var(--shake-intensity), calc(var(--shake-intensity) * 0.5)) rotate(0.3deg); }
    30%  { transform: translate(calc(var(--shake-intensity) * -0.8), var(--shake-intensity)) rotate(-0.2deg); }
    40%  { transform: translate(calc(var(--shake-intensity) * 0.7), calc(var(--shake-intensity) * -0.8)) rotate(0.2deg); }
    50%  { transform: translate(calc(var(--shake-intensity) * -0.6), calc(var(--shake-intensity) * 0.4)) rotate(-0.1deg); }
    60%  { transform: translate(calc(var(--shake-intensity) * 0.4), calc(var(--shake-intensity) * -0.3)); }
    70%  { transform: translate(calc(var(--shake-intensity) * -0.3), calc(var(--shake-intensity) * 0.2)); }
    80%  { transform: translate(calc(var(--shake-intensity) * 0.2), calc(var(--shake-intensity) * -0.1)); }
    90%  { transform: translate(calc(var(--shake-intensity) * -0.1), 0); }
}

.board-shake {
    animation: boardShake 0.5s ease-out;
}

/* ===== RESPONSIVE ===== */
@media (max-height: 700px) {
    #current-score { font-size: 36px; }
    #header { margin-bottom: 4px; }
    #pieces-panel { padding: 10px 8px; margin-top: 4px; min-height: 80px; }
    #game-container { padding: 8px 12px; }
}

@media (max-height: 600px) {
    #current-score { font-size: 28px; }
    #board-wrapper { max-width: 320px; }
    .piece-slot { min-width: 60px; min-height: 60px; }
}

@media (max-width: 360px) {
    #current-score { font-size: 32px; }
    #best-score-box { padding: 4px 10px; font-size: 14px; }
    #settings-btn, #restart-header-btn { width: 38px; height: 38px; }
    #final-score { font-size: 48px; }
}

@media (min-width: 768px) {
    #board-wrapper { max-width: 420px; }
    #pieces-panel { max-width: 420px; }
}
