@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Rajdhani:wght@500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    background-color: transparent;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Rajdhani', sans-serif;
}

.full_screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ---------- SETTINGS / MENU ---------- */

#settings {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: radial-gradient(ellipse at center, #1c2a3a 0%, #05070c 75%);
    color: #eafcff;
    padding: 20px;
    width: 100%;
    text-align: center;
}

#settings h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 44px;
    letter-spacing: 4px;
    margin: 0 0 10px 0;
    color: #4dd4ff;
    text-shadow:
        0 0 8px #4dd4ff,
        0 0 20px #1a8fd1,
        0 0 40px rgba(77, 212, 255, 0.5);
    animation: title_glow 2.4s ease-in-out infinite;
}

@keyframes title_glow {
    0%, 100% { text-shadow: 0 0 8px #4dd4ff, 0 0 20px #1a8fd1, 0 0 40px rgba(77,212,255,0.5); }
    50%      { text-shadow: 0 0 14px #7be8ff, 0 0 30px #4dd4ff, 0 0 60px rgba(77,212,255,0.8); }
}

#high_score_display {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: #ffd24d;
    text-shadow: 0 0 10px rgba(255, 210, 77, 0.7);
    margin-bottom: 8px;
    min-height: 20px;
}

#high_score_display .loading {
    opacity: 0.6;
    font-size: 12px;
    color: #8fa3b0;
    text-shadow: none;
}

.button {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1px;
    margin: 6px 0;
    padding: 12px 34px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    min-width: 220px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
    box-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 18px rgba(0,0,0,0.25) inset;
}

.button:hover {
    transform: translateY(-2px);
    filter: brightness(1.12);
}

.button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.35);
}

#new_button {
    background: linear-gradient(180deg, #6fdc6f 0%, #3f9a3f 100%);
}

#new_button:hover {
    box-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 22px rgba(111, 220, 111, 0.6);
}

#close_button {
    background: linear-gradient(180deg, #e9736e 0%, #b83a35 100%);
}

#close_button:hover {
    box-shadow: 0 4px 0 rgba(0,0,0,0.35), 0 0 22px rgba(233, 115, 110, 0.6);
}

#instructions {
    margin-top: 18px;
    font-size: 15px;
    color: #9fb3c0;
    line-height: 1.7;
    max-width: 340px;
}

#instructions .key {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: #14202b;
    border: 1px solid #3a5566;
    border-radius: 4px;
    padding: 3px 6px;
    margin: 0 2px;
    color: #7be8ff;
}

/* ---------- GAME SCREEN ---------- */

#tetris {
    background-color: #000;
    color: #fff;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    z-index: 5;
    background: linear-gradient(180deg, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0) 100%);
    pointer-events: none;
}

#hud * {
    pointer-events: auto;
}

#score_block {
    display: flex;
    flex-direction: column;
    font-family: 'Rajdhani', sans-serif;
}

#score {
    font-size: 1.7em;
    font-weight: 700;
    color: #7be8ff;
    text-shadow: 0 0 10px rgba(77, 212, 255, 0.5);
}

#best_score {
    font-size: 1em;
    font-weight: 500;
    color: #ffd24d;
    text-shadow: 0 0 8px rgba(255, 210, 77, 0.4);
}

#score.new_high {
    animation: pulse_gold 0.6s ease;
}

@keyframes pulse_gold {
    0%   { color: #7be8ff; text-shadow: 0 0 10px rgba(77,212,255,0.5); }
    50%  { color: #ffd24d; text-shadow: 0 0 18px rgba(255,210,77,0.9); transform: scale(1.15); }
    100% { color: #7be8ff; text-shadow: 0 0 10px rgba(77,212,255,0.5); }
}

#next_piece_panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(11, 15, 20, 0.6);
    border: 1px solid #2b3d47;
    border-radius: 8px;
    padding: 8px 12px;
}

#next_piece_label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #7be8ff;
    letter-spacing: 2px;
}

#next_piece_grid {
    position: relative;
    width: 72px;
    height: 72px;
}

.next_piece_cell {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}

#gear {
    font-size: 1.8em;
    cursor: pointer;
    color: #cfe9f2;
    transition: transform 0.3s ease, color 0.2s ease;
}

#gear:hover {
    transform: rotate(90deg);
    color: #7be8ff;
}

#game {
    background-color: #0b0f14;
    border-style: solid;
    border-width: 2px;
    border-color: #2b3d47;
    box-shadow: 0 0 40px rgba(77, 212, 255, 0.15) inset;
    transition: filter 0.15s ease;
}

/* screen shake + flash for line clears / game over */
#game.shake {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 3px); }
    40% { transform: translate(6px, -3px); }
    60% { transform: translate(-4px, -2px); }
    80% { transform: translate(4px, 2px); }
}

#flare_layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.flare_flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.35);
    opacity: 0;
    animation: flash_fade 0.35s ease-out forwards;
}

@keyframes flash_fade {
    0%   { opacity: 0.8; }
    100% { opacity: 0; }
}

.flare_particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    opacity: 1;
    animation: particle_fly 0.8s ease-out forwards;
}

@keyframes particle_fly {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; }
}

#game_over_banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    font-family: 'Press Start 2P', monospace;
    font-size: 28px;
    color: #ff5c5c;
    text-shadow: 0 0 16px rgba(255, 92, 92, 0.8);
    text-align: center;
    z-index: 6;
    display: none;
    pointer-events: none;
}

#game_over_banner.show {
    display: block;
    animation: game_over_pop 0.5s ease forwards;
}

@keyframes game_over_pop {
    0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}