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

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a2a 100%);
    font-family: 'Rajdhani', sans-serif;
    overflow: hidden;
    animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {

    0%,
    100% {
        background-position: 0% 0%;
        filter: brightness(1);
    }

    50% {
        background-position: 5% 5%;
        filter: brightness(1.1);
    }
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 80%, rgba(120, 0, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(0, 200, 255, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 0, 150, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.game-header h1 {
    font-family: 'Orbitron', monospace;
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(180deg, #00f5ff 0%, #7b2fff 50%, #ff00aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(0, 245, 255, 0.5);
    letter-spacing: 15px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 20px rgba(0, 245, 255, 0.5));
    }

    to {
        filter: drop-shadow(0 0 40px rgba(123, 47, 255, 0.8));
    }
}

.game-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Réduit de 20px à 15px */
    min-width: 180px;
    height: 600px;
    /* Alignement sur la hauteur du plateau */
}

/* Panel droit spécifique pour l'alignement */
.right-panel {
    justify-content: flex-start;
}

.right-panel .controls-box {
    margin-top: auto;
    /* Pousse les contrôles vers le bas pour l'alignement */
}

.info-box {
    background: rgba(20, 20, 50, 0.8);
    border: 2px solid rgba(0, 245, 255, 0.3);
    border-radius: 15px;
    padding: 12px;
    /* Réduit pour gagner de la place */
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow:
        0 0 20px rgba(0, 245, 255, 0.1),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.info-box:hover {
    border-color: rgba(0, 245, 255, 0.6);
    box-shadow:
        0 0 30px rgba(0, 245, 255, 0.2),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.info-box h3 {
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    color: rgba(0, 245, 255, 0.8);
    margin-bottom: 10px;
    letter-spacing: 3px;
}

.info-box .value {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.game-board-wrapper {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        0 0 50px rgba(123, 47, 255, 0.3),
        0 0 100px rgba(0, 245, 255, 0.2),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.game-board-wrapper::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #00f5ff, #7b2fff, #ff00aa, #00f5ff);
    background-size: 400% 400%;
    border-radius: 12px;
    z-index: -1;
    animation: borderGlow 3s ease infinite;
}

@keyframes borderGlow {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

#gameBoard {
    display: block;
    background: linear-gradient(180deg, #0a0a1a 0%, #151530 100%);
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.overlay-content h2 {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    background: linear-gradient(180deg, #00f5ff 0%, #7b2fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.overlay-content p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

.final-score {
    margin-top: 20px;
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    color: #ff00aa;
}

.next-piece-box {
    padding: 15px;
}

#nextPiece {
    display: block;
    margin: 10px auto 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

/* Hold Box */
.hold-box {
    padding: 15px;
}

.hold-box h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.key-hint {
    font-size: 0.6rem;
    opacity: 0.6;
    font-weight: 400;
}

#holdPiece {
    display: block;
    margin: 10px auto 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}

.hold-box.disabled {
    opacity: 0.5;
}

.hold-box.disabled #holdPiece {
    filter: grayscale(0.5);
}

.controls-box {
    background: rgba(20, 20, 50, 0.8);
    border: 2px solid rgba(123, 47, 255, 0.3);
    border-radius: 15px;
    padding: 10px 20px;
    /* Moins de padding vertical */
    backdrop-filter: blur(10px);
}

.controls-box h3 {
    font-family: 'Orbitron', monospace;
    font-size: 0.9rem;
    color: rgba(123, 47, 255, 0.8);
    margin-bottom: 8px;
    /* Réduit de 15px à 8px */
    letter-spacing: 3px;
    text-align: center;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 6px;
    /* Réduit de 10px à 6px */
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
}

.control-item.clickable {
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 8px;
}

.control-item.clickable:hover {
    background: rgba(123, 47, 255, 0.2);
    color: #fff;
}

.control-item.clickable:hover .key {
    background: linear-gradient(135deg, rgba(123, 47, 255, 0.5), rgba(0, 245, 255, 0.5));
    border-color: rgba(0, 245, 255, 0.8);
    transform: scale(1.05);
}

/* État actif pour la musique */
.control-item.clickable.active {
    color: #00f5ff;
}

.control-item.clickable.active .key {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.4), rgba(123, 47, 255, 0.4));
    border-color: #00f5ff;
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.5);
    animation: musicPulse 2s ease-in-out infinite;
}

.control-item:last-child {
    margin-bottom: 0;
}

.key {
    background: linear-gradient(135deg, rgba(123, 47, 255, 0.3), rgba(0, 245, 255, 0.3));
    border: 1px solid rgba(0, 245, 255, 0.5);
    border-radius: 5px;
    padding: 5px 10px;
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    min-width: 60px;
    text-align: center;
    color: #fff;
}

@keyframes musicPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* Responsive */
@media (max-width: 900px) {
    .game-content {
        flex-direction: column;
        align-items: center;
    }

    .side-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .game-header h1 {
        font-size: 2.5rem;
        letter-spacing: 8px;
    }
}

/* ===================
   EFFETS VISUELS
   =================== */

/* Score animation */
.info-box .value {
    transition: transform 0.1s ease-out, color 0.2s ease;
}

.info-box .value.pulse {
    animation: valuePulse 0.3s ease-out;
}

@keyframes valuePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
        color: #00f5ff;
    }

    100% {
        transform: scale(1);
    }
}

@keyframes boxUpdate {
    0% {
        transform: scale(1);
        border-color: rgba(0, 245, 255, 0.3);
    }

    30% {
        transform: scale(1.05);
        border-color: #00f5ff;
        box-shadow: 0 0 20px rgba(0, 245, 255, 0.4);
    }

    100% {
        transform: scale(1);
        border-color: rgba(0, 245, 255, 0.3);
    }
}

.stat-update {
    animation: boxUpdate 0.4s ease-out;
}

.value-update {
    animation: valuePulse 0.4s ease-out;
}

/* Canvas de particules */
#particleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Combo indicator */
#comboIndicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Orbitron', monospace;
    font-size: 1.5rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 150;
    text-align: center;
}

/* Score popup */
.score-popup {
    position: absolute;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
}

/* Center text popup */
.center-text-popup {
    position: absolute;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    pointer-events: none;
    z-index: 200;
    text-align: center;
    letter-spacing: 3px;
}

/* Game board glow effect */
#gameBoard {
    transition: box-shadow 0.3s ease, filter 0.2s ease;
}

#gameBoard.glow-purple {
    box-shadow: 0 0 30px #7b2fff, 0 0 60px #7b2fff, inset 0 0 30px rgba(123, 47, 255, 0.3);
}

#gameBoard.glow-cyan {
    box-shadow: 0 0 30px #00ffff, 0 0 60px #00ffff, inset 0 0 30px rgba(0, 255, 255, 0.3);
}

/* Flash overlay */
.flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    animation: flashFade 100ms ease-out forwards;
}

@keyframes flashFade {
    from {
        opacity: 0.5;
    }

    to {
        opacity: 0;
    }
}

/* Level up animation */
@keyframes levelUpGlow {
    0% {
        box-shadow: 0 0 10px #7b2fff;
    }

    50% {
        box-shadow: 0 0 50px #7b2fff, 0 0 100px #7b2fff;
    }

    100% {
        box-shadow: 0 0 10px #7b2fff;
    }
}

/* Tetris highlight */
@keyframes tetrisFlash {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.5) saturate(1.5);
    }
}

.tetris-flash {
    animation: tetrisFlash 0.2s ease-out 3;
}

/* Smooth transitions for UI elements */
.info-box {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(123, 47, 255, 0.4);
}

/* Hold box when piece is held */
.hold-box.has-piece canvas {
    animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.1);
    }
}

/* High Scores Table */
.high-scores-container {
    margin-top: 20px;
    width: 100%;
    max-width: 250px;
    font-family: 'Rajdhani', sans-serif;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(0, 245, 255, 0.1);
}

.high-scores-container h3 {
    font-size: 0.9rem;
    color: #00f5ff;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(0, 245, 255, 0.2);
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.score-entry:last-child {
    border-bottom: none;
}

.score-entry .rank {
    color: #7b2fff;
    font-weight: bold;
    width: 20px;
}

.score-entry .pts {
    color: #fff;
    flex-grow: 1;
    text-align: right;
    padding-right: 15px;
}

.score-entry .date {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.7rem;
    width: 70px;
    text-align: right;
}

.new-record {
    animation: goldGlow 1.5s infinite alternate;
    color: #ffd700 !important;
}

@keyframes goldGlow {
    from {
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
    }

    to {
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.5);
    }
}

.resume-button {
    background: linear-gradient(135deg, #7b2fff, #00f5ff);
    border: none;
    border-radius: 25px;
    padding: 10px 20px;
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    margin: 15px 0;
    transition: all 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
}

.resume-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(0, 245, 255, 0.5);
}

.resume-button.hidden {
    display: none;
}

.menu-screen.hidden {
    display: none;
}

.menu-screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-selection {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 250px;
    margin: 20px 0;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
}

.mode-btn:hover {
    background: rgba(0, 245, 255, 0.1);
    border-color: #00f5ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.2);
}

.mode-btn.primary {
    background: linear-gradient(135deg, rgba(123, 47, 255, 0.3), rgba(0, 245, 255, 0.3));
    border-color: rgba(0, 245, 255, 0.5);
    margin: 15px 0;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    text-transform: uppercase;
}

.mode-name {
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.mode-desc {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

/* Global Stats Module */
.persistence-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.persistence-display.hidden {
    display: none;
}

.stats-container {
    margin-top: 5px;
    width: 100%;
    max-width: 260px;
    font-family: 'Rajdhani', sans-serif;
    background: rgba(123, 47, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(123, 47, 255, 0.2);
}

.stats-container h3 {
    font-size: 0.8rem;
    color: #7b2fff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item .label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 2px;
}

.stat-item span:not(.label) {
    font-size: 0.85rem;
    color: #fff;
    font-weight: bold;
}