:root {
    --bg-gradient: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    --board-bg: #2c3e50;
    --selected-outline: #ffd700;
    --tile-bg: rgba(255, 255, 255, 0.1);
    --grid-gap: 6px;
}

@import url('https://fonts.googleapis.com/css2?family=Pacifico&display=swap');

/* Force nav to stay at top, not overlap content */
#nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 999;
}

/* Add padding to body to account for fixed nav */
body {
    padding-top: 60px;
}

body {
    margin: 0;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 20px;
    box-sizing: border-box;
}

h1 {
    margin: 0 0 20px 0;
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-family: 'Pacifico', cursive;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    text-transform: none;
    color: white;
}

/* Mode Selector Panel */
.mode-panel {
    background: linear-gradient(145deg, #1a2a6c, #162144);
    border: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    max-width: 700px;
    width: 100%;
}

.mode-panel h2 {
    font-family: 'Pacifico', cursive;
    font-size: 2rem;
    margin: 0 0 30px 0;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    color: white;
}

/* Mode Selector */
.mode-selector {
    text-align: center;
    max-width: 700px;
    width: 100%;
}

.mode-options {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px 40px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
    max-width: 220px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.mode-btn:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}

.mode-icon {
    font-size: 3rem;
}

.mode-name {
    font-size: 1.5rem;
    font-weight: bold;
    font-family: 'Pacifico', cursive;
    color: #ffd700;
}

.mode-desc {
    font-size: 0.9rem;
    opacity: 0.8;
    text-align: center;
}

.game-container {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.scoreboard {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    padding: 20px;
    min-width: 140px;
    text-align: center;
}

.scoreboard h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: white;
}

.score-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

#game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: var(--grid-gap);
    padding: 12px;
    background: var(--board-bg);
    border: 4px solid rgba(255, 215, 0, 0.3);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    user-select: none;
    touch-action: manipulation;
    width: min(568px, 95vw);
    aspect-ratio: 1 / 1;
}

.tile {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 5vw, 2rem);
    cursor: pointer;
    background: var(--tile-bg);
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tile:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.tile.selected {
    outline: 3px solid var(--selected-outline);
    transform: scale(1.03) translateY(-5px);
    background: rgba(255, 215, 0, 0.2);
    z-index: 2;
    box-shadow: 0 8px 16px rgba(255, 215, 0, 0.4);
}

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

.tile.destroying {
    animation: destroy 50ms ease-out forwards;
}

@keyframes board-shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px); }
    20% { transform: translateX(8px); }
    30% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

.shaking-board {
    animation: board-shake 0.4s ease-in-out;
}

@keyframes tile-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    10% { transform: translateX(-3px) rotate(-3deg); }
    20% { transform: translateX(3px) rotate(3deg); }
    30% { transform: translateX(-2px) rotate(-2deg); }
    40% { transform: translateX(2px) rotate(2deg); }
    50% { transform: translateX(-1px) rotate(-1deg); }
    60% { transform: translateX(1px) rotate(1deg); }
    70% { transform: translateX(-1px) rotate(0deg); }
    80% { transform: translateX(1px) rotate(0deg); }
    90% { transform: translateX(0) rotate(0deg); }
}

.shaking {
    animation: tile-shake 0.3s ease-in-out;
}

@keyframes drop-in {
    0% { transform: translateY(-80px); opacity: 0; }
    60% { transform: translateY(5px); opacity: 1; }
    80% { transform: translateY(-3px); }
    100% { transform: translateY(0); }
}

.dropping {
    animation: drop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#status {
    margin-top: 35px;
    font-size: 1.5rem;
    font-weight: bold;
    padding: 10px 25px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 30px;
    border: 2px solid var(--selected-outline);
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.5);
}

.sound-controls {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 30px;
    padding: 8px 20px;
    font-size: 1rem;
}

.sound-controls input[type="range"] {
    width: 120px;
    accent-color: var(--selected-outline);
}

#volume-value {
    font-weight: bold;
    color: var(--selected-outline);
    min-width: 40px;
}

/* Mobile landscape */
@media (max-width: 768px) and (orientation: landscape) {
    body { padding: 12px; }
    
    .mode-panel { padding: 30px; max-width: 100%; }
    
    .game-container {
        flex-direction: column;
        align-items: center;
    }
    
    .scoreboard {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        min-width: auto;
        width: 100%;
        max-width: 400px;
        justify-content: space-between;
    }
}

/* Mobile portrait */
@media (max-width: 480px) and (orientation: portrait) {
    body { padding: 10px; }
    
    .mode-panel { padding: 20px; }
    
    .mode-options {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .game-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .scoreboard {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 8px 16px;
        min-width: auto;
        width: 100%;
        max-width: 340px;
        justify-content: space-between;
    }
    
    .scoreboard h2 { margin: 0; font-size: 1rem; }
    .score-value { font-size: 1.5rem; }
    
    #status {
        font-size: 1.1rem;
        padding: 8px 16px;
        margin-top: 12px;
    }
    
    .sound-controls {
        margin-top: 10px;
        padding: 6px 14px;
        font-size: 0.9rem;
    }
    
    .sound-controls input[type="range"] { width: 80px; }
}