/* Variables CSS pour thème sombre */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --accent-color: #00ffff;
    --accent-hover: #00e6e6;
    --warning-color: #ff6b6b;
    --success-color: #51cf66;
    --border-color: #555555;
    --shadow-color: rgba(0, 0, 0, 0.5);
    
    /* Couleurs des pièces Tetris */
    --piece-i: #00ffff; /* Cyan */
    --piece-o: #ffff00; /* Jaune */
    --piece-t: #800080; /* Violet */
    --piece-s: #00ff00; /* Vert */
    --piece-z: #ff0000; /* Rouge */
    --piece-j: #0000ff; /* Bleu */
    --piece-l: #ffa500; /* Orange */
    
    /* Tailles responsives */
    --container-width: 90vw;
    --board-size: 12vw;
    --cell-size: 1.2vw;
    --header-size: 2vw;
    --text-size: 0.8vw;
}

/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Container principal */
#game-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 1vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 1vw;
}

header h1 {
    font-size: var(--header-size);
    color: var(--accent-color);
    text-shadow: 0 0 0.3vw var(--accent-color);
    margin-bottom: 0.5vw;
}

/* Zone de jeu principale */
#game-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5vw;
    margin-bottom: 1vw;
    flex-wrap: wrap;
    width: 100%;
    max-width: 80vw;
}

/* Section joueur */
.player-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5vw;
    flex: 1;
    position: relative;
}

/* Centre avec les statistiques */
.center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 0.5vw;
    flex: 1;
    max-width: 25vw;
    height: 100%;
}

.players-stats {
    background: var(--bg-secondary);
    padding: 0.7vw;
    border-radius: 0.5vw;
    border: 0.1vw solid var(--border-color);
    width: 100%;
}

.players-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 0.5vw;
    gap: 0.8vw;
}

.player-name {
    font-size: calc(var(--text-size) * 1.2);
    color: var(--accent-color);
    font-weight: bold;
    text-align: center;
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin: 0.2vw 0;
    gap: 0.8vw;
}

.stat-value {
    font-size: calc(var(--text-size) * 1.1);
    color: var(--text-primary);
    font-weight: bold;
    min-width: 4vw;
    font-family: 'Courier New', monospace;
}

.stat-value:first-child {
    text-align: left;
}

.stat-value:last-child {
    text-align: right;
}

.stat-label {
    font-size: var(--text-size);
    color: var(--text-secondary);
    text-align: center;
    font-weight: normal;
}


/* Plateau de jeu */
.game-board {
    width: var(--board-size);
    height: calc(var(--board-size) * 2);
    background: var(--bg-secondary);
    border: 0.3vw solid var(--border-color);
    border-radius: 0.5vw;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 2vw var(--shadow-color);
}

/* Grille du plateau */
.game-board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to right, var(--border-color) 0.1vw, transparent 0.1vw),
        linear-gradient(to bottom, var(--border-color) 0.1vw, transparent 0.1vw);
    background-size: var(--cell-size) var(--cell-size);
    opacity: 0.3;
    pointer-events: none;
}

/* Cellules du jeu */
.cell {
    position: absolute;
    width: 10%;
    height: 5%;
    border: 0.1vw solid rgba(255, 255, 255, 0.1);
    border-radius: 0.2vw;
    box-sizing: border-box;
}

/* Pièces colorées */
.cell.filled {
    box-shadow: inset 0 0 0.5vw rgba(255, 255, 255, 0.3);
}

.cell.piece-i { background: var(--piece-i); }
.cell.piece-o { background: var(--piece-o); }
.cell.piece-t { background: var(--piece-t); }
.cell.piece-s { background: var(--piece-s); }
.cell.piece-z { background: var(--piece-z); }
.cell.piece-j { background: var(--piece-j); }
.cell.piece-l { background: var(--piece-l); }
.cell.piece-trapped { 
    background: repeating-linear-gradient(
        45deg,
        #444444,
        #444444 3px,
        #666666 3px,
        #666666 6px
    );
    border: 0.1vw solid var(--warning-color);
}

.cell.current {
    box-shadow: 0 0 1vw currentColor;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Séparateur VS */
.vs-separator {
    font-size: calc(var(--text-size) * 1.2);
    font-weight: bold;
    color: var(--warning-color);
    text-shadow: 0 0 0.3vw var(--warning-color);
    text-align: center;
    padding: 0;
    margin: 0;
}

/* Prochaines pièces dans le format stats */
.next-pieces-row .stat-label {
    font-size: calc(var(--text-size) * 0.9);
}

.next-preview {
    width: 3vw;
    height: 3vw;
    background: var(--bg-tertiary);
    border: 0.1vw solid var(--border-color);
    border-radius: 0.3vw;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Points d'attaque styling */
.attack-points .stat-label {
    color: var(--warning-color);
    font-weight: bold;
}

.attack-points .stat-value {
    color: var(--warning-color);
    text-shadow: 0 0 0.2vw var(--warning-color);
}

/* Panel d'attaques */
.attack-panel {
    background: var(--bg-secondary);
    border: 0.1vw solid var(--border-color);
    border-radius: 0.5vw;
    padding: 0.6vw;
    width: 100%;
    margin: 0.3vw 0;
}

.attack-section {
    margin-bottom: 0.5vw;
}

.attack-section:last-child {
    margin-bottom: 0;
}

.attack-section h4 {
    font-size: calc(var(--text-size) * 0.9);
    margin-bottom: 0.3vw;
    text-align: center;
}

.attack-section:first-child h4 {
    color: var(--warning-color);
}

.attack-section:last-child h4 {
    color: var(--success-color);
}

.attack-list {
    display: flex;
    flex-direction: column;
    gap: 0.2vw;
}

.attack-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3vw 0.5vw;
    background: var(--bg-tertiary);
    border-radius: 0.3vw;
    font-size: calc(var(--text-size) * 0.7);
    border-left: 0.2vw solid var(--border-color);
    transition: all 0.2s ease;
}

.attack-item.available {
    opacity: 1;
}

.attack-item.unavailable {
    opacity: 0.3;
    border-left-color: var(--border-color);
    background: var(--bg-secondary);
}

.attack-item.offensive {
    border-left-color: var(--warning-color);
}

.attack-item.offensive.available {
    background: rgba(255, 107, 107, 0.15);
    border-left-width: 0.3vw;
}

.attack-item.offensive.unavailable {
    border-left-color: rgba(255, 107, 107, 0.3);
}

.attack-item.defensive {
    border-left-color: var(--success-color);
}

.attack-item.defensive.available {
    background: rgba(81, 207, 102, 0.15);
    border-left-width: 0.3vw;
}

.attack-item.defensive.unavailable {
    border-left-color: rgba(81, 207, 102, 0.3);
}

/* Indicateurs par joueur */
.attack-item.player1-available::before {
    content: '1';
    position: absolute;
    left: -0.8vw;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-color);
    color: var(--bg-primary);
    width: 1.2vw;
    height: 1.2vw;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--text-size) * 0.6);
    font-weight: bold;
}

.attack-item.player2-available::after {
    content: '2';
    position: absolute;
    right: -0.8vw;
    top: 50%;
    transform: translateY(-50%);
    background: var(--accent-color);
    color: var(--bg-primary);
    width: 1.2vw;
    height: 1.2vw;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--text-size) * 0.6);
    font-weight: bold;
}

.attack-item {
    position: relative;
}

.attack-info {
    display: flex;
    align-items: center;
    gap: 0.3vw;
    flex: 1;
}

.attack-key {
    background: var(--bg-primary);
    color: var(--accent-color);
    padding: 0.1vw 0.3vw;
    border-radius: 0.2vw;
    font-size: calc(var(--text-size) * 0.6);
    font-weight: bold;
    min-width: 1.5vw;
    text-align: center;
}

.attack-name {
    color: var(--text-primary);
    flex: 1;
}

.attack-cost {
    color: var(--accent-color);
    font-weight: bold;
    font-size: calc(var(--text-size) * 0.6);
}

/* Informations des contrôles */
.controls-info {
    background: var(--bg-tertiary);
    border: 0.1vw solid var(--border-color);
    border-radius: 0.5vw;
    padding: 0.5vw;
    text-align: center;
    width: 100%;
    max-width: var(--board-size);
}

.controls-info p {
    font-size: calc(var(--text-size) * 0.8);
    color: var(--text-muted);
}

/* Contrôles de jeu */
.game-controls {
    display: flex;
    gap: 1vw;
    justify-content: center;
    flex-wrap: wrap;
}

/* Boutons */
.btn-primary, .btn-secondary {
    padding: 0.8vw 1.5vw;
    font-size: var(--text-size);
    border: none;
    border-radius: 0.5vw;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: var(--bg-primary);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-color));
    transform: translateY(-0.2vw);
    box-shadow: 0 0.5vw 1vw var(--shadow-color);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 0.2vw solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent-color);
}

.btn-primary:disabled, .btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Toast notifications */
#toast-container {
    position: fixed;
    top: 2vw;
    right: 2vw;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1vw;
    max-width: 30vw;
}

.toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 1.5vw;
    border-radius: 1vw;
    border-left: 0.5vw solid var(--accent-color);
    box-shadow: 0 0.5vw 1vw var(--shadow-color);
    animation: slideIn 0.3s ease-out;
    word-wrap: break-word;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4vw;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.removing {
    animation: slideOut 0.3s ease-in forwards;
}

.toast.success { border-left-color: var(--success-color); }
.toast.warning { border-left-color: var(--warning-color); }
.toast.error { border-left-color: var(--warning-color); }
.toast.info { border-left-color: var(--accent-color); }

.toast-content {
    display: flex;
    align-items: center;
    gap: 1vw;
    flex: 1;
}

.toast-icon {
    font-size: calc(var(--text-size) * 1.2);
    font-weight: bold;
}

.toast-message {
    font-size: var(--text-size);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: calc(var(--text-size) * 1.5);
    cursor: pointer;
    padding: 0.5vw;
    border-radius: 50%;
    width: 3vw;
    height: 3vw;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

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

.modal-content {
    background: var(--bg-secondary);
    border: 0.3vw solid var(--border-color);
    border-radius: 1.5vw;
    padding: 3vw;
    max-width: 50vw;
    text-align: center;
    box-shadow: 0 1vw 2vw var(--shadow-color);
    animation: scaleIn 0.3s ease-out;
}

.modal-content h2 {
    color: var(--accent-color);
    font-size: calc(var(--text-size) * 1.5);
    margin-bottom: 2vw;
}

.modal-content p {
    font-size: var(--text-size);
    color: var(--text-secondary);
    margin-bottom: 3vw;
    line-height: 1.5;
    white-space: pre-line;
}

/* Styles modaux spécifiques */
.modal-confirm .modal-content {
    border-left: 0.5vw solid var(--accent-color);
}

.modal-alert .modal-content {
    border-left: 0.5vw solid var(--success-color);
}

.modal-success .modal-content {
    border-left: 0.5vw solid var(--success-color);
}

.modal-error .modal-content {
    border-left: 0.5vw solid var(--warning-color);
}

.modal-warning .modal-content {
    border-left: 0.5vw solid var(--warning-color);
}

.modal-gameOver .modal-content {
    border-left: 0.5vw solid gold;
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
}

.modal-pause .modal-content {
    border-left: 0.5vw solid var(--accent-color);
}

.modal-buttons {
    display: flex;
    gap: 2vw;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Indicateurs d'effets */
.effect-indicator {
    position: absolute;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 0.2vw;
}

#player1-section .effect-indicator {
    right: -3vw;
    align-items: flex-start;
}

#player2-section .effect-indicator {
    left: -3vw;
    align-items: flex-end;
}

.effect-icon {
    font-size: 1.5vw;
    width: 2.5vw;
    height: 2.5vw;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 0.1vw solid var(--border-color);
    animation: effectAppear 0.3s ease-out;
    transition: all 0.3s ease;
}

.effect-icon.removing {
    animation: effectDisappear 0.3s ease-in forwards;
}

.effect-icon.rotation-block {
    color: var(--warning-color);
    border-color: var(--warning-color);
    box-shadow: 0 0 0.3vw var(--warning-color);
    animation: effectPulse 1s ease-in-out infinite;
}

.effect-icon.speed-boost {
    color: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 0.3vw var(--accent-color);
    animation: effectSpin 2s linear infinite;
}

.effect-icon.controls-reverse {
    color: #ff6b6b;
    border-color: #ff6b6b;
    box-shadow: 0 0 0.3vw #ff6b6b;
    animation: effectShake 0.5s ease-in-out infinite alternate;
}

@keyframes effectAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes effectDisappear {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

@keyframes effectPulse {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes effectSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes effectShake {
    from {
        transform: translateX(-0.1vw);
    }
    to {
        transform: translateX(0.1vw);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    :root {
        --container-width: 98vw;
        --board-size: 30vw;
        --cell-size: 3vw;
        --header-size: 6vw;
        --text-size: 2.5vw;
    }
    
    #game-area {
        flex-direction: column;
        align-items: center;
        gap: 3vw;
        max-width: 95vw;
    }
    
    .center-info {
        max-width: 90vw;
        order: 0;
    }
    
    .players-stats {
        padding: 1.5vw;
    }
    
    .players-header {
        margin-bottom: 1vw;
    }
    
    .player-name {
        font-size: calc(var(--text-size) * 1.3);
    }
    
    .stat-row {
        margin: 0.5vw 0;
    }
    
    .stat-value {
        font-size: calc(var(--text-size) * 1.2);
        min-width: 4vw;
    }
    
    .vs-separator {
        font-size: calc(var(--text-size) * 1.5);
    }
    
    .next-pieces {
        flex-direction: column;
        gap: 0.5vw;
    }
    
    .next-piece {
        max-width: none;
    }
    
    .next-piece #next1, .next-piece #next2 {
        width: 6vw;
        height: 6vw;
    }
    
    .player-section {
        width: 100%;
        max-width: 35vw;
    }
    
    #player1-section { order: 1; }
    #player2-section { order: 2; }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
        gap: 2vw;
    }
    
    .btn-primary, .btn-secondary {
        padding: 2vw 4vw;
        width: 80vw;
        max-width: 40vw;
    }
    
    #toast-container {
        max-width: 90vw;
        right: 5vw;
    }
    
    .modal-content {
        max-width: 90vw;
        padding: 4vw;
    }
}