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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    text-align: center;
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.grid-selector {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.grid-selector label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.grid-selector select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.scoreboard {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.score {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1.2rem;
    border-radius: 12px;
    background: #f8f8f8;
}

.score-x {
    border: 2px solid #e74c3c;
}

.score-o {
    border: 2px solid #3498db;
}

.score-draw {
    border: 2px solid #95a5a6;
}

.score-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
}

.score-x .score-value {
    color: #e74c3c;
}

.score-o .score-value {
    color: #3498db;
}

.score-draw .score-value {
    color: #95a5a6;
}

.score-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.status {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: #555;
    font-weight: 600;
    min-height: 2rem;
}

.board {
    display: grid;
    gap: 8px;
    width: 320px;
    height: 320px;
    margin: 0 auto 1.5rem;
    grid-auto-rows: 1fr;
}

.cell {
    background: #f0f0f0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.cell:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.cell.x {
    color: #e74c3c;
}

.cell.o {
    color: #3498db;
}

.cell.scored {
    background: #d4efdf;
    border: 2px solid #2ecc71;
}

.cell.winner {
    background: #2ecc71;
    color: white;
    animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.08); }
}

.points-display {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.points-x {
    color: #e74c3c;
}

.points-o {
    color: #3498db;
}

.points-separator {
    color: #ccc;
}

.reset-btn {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.reset-btn:active {
    transform: translateY(0);
}

.reset-scores-btn {
    display: block;
    margin: 0.8rem auto 0;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    background: transparent;
    color: #999;
    border: 1px solid #ccc;
    border-radius: 20px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.reset-scores-btn:hover {
    color: #e74c3c;
    border-color: #e74c3c;
}

/* --- Game Launcher --- */

.launcher-subtitle {
    font-size: 1.1rem;
    color: #777;
    margin-bottom: 1.5rem;
}

.launcher-logo {
    height: 100px;
    width: auto;
    margin-bottom: 0.5rem;
}

.game-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.game-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 1rem 0.75rem;
    background: #f8f8f8;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.game-card:hover {
    transform: translateY(-3px);
    border-color: #667eea;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
}

.game-card-icon {
    font-size: 1.8rem;
}

.game-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
}

.game-card-desc {
    font-size: 0.75rem;
    color: #888;
}

.back-btn {
    align-self: flex-start;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.95rem;
    background: transparent;
    color: #667eea;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s;
}

.back-btn:hover {
    color: #764ba2;
}

.game-container {
    display: none;
}

/* --- Pong --- */

.pong-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pong-controls label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.pong-controls select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.pong-score {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1rem;
    font-size: 2rem;
    font-weight: bold;
}

.pong-score-left {
    color: #e74c3c;
}

.pong-score-right {
    color: #3498db;
}

.pong-score-separator {
    color: #ccc;
}

#pongCanvas {
    display: block;
    margin: 0 auto 1rem;
    background: #1a1a2e;
    border-radius: 10px;
    max-width: 100%;
}

.pong-instructions {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.5rem;
}

/* --- Tetris --- */

.tetris-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tetris-controls label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.tetris-controls select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.tetris-info {
    margin-bottom: 1rem;
}

.tetris-score-display {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
}

.tetris-score-display strong {
    color: #333;
}

.tetris-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

#tetrisCanvas {
    display: block;
    background: #1a1a2e;
    border-radius: 10px;
}

.tetris-next {
    text-align: center;
}

.tetris-next p {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
}

#tetrisNextCanvas {
    background: #1a1a2e;
    border-radius: 8px;
}

.tetris-instructions {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.5rem;
}

/* --- Language Selector --- */

.lang-selector {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

.lang-selector select {
    font-size: 0.95rem;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(4px);
}

.lang-selector select:hover {
    border-color: #667eea;
}

/* --- Pac-Man --- */

.pacman-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pacman-controls label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.pacman-controls select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.pacman-info {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 1rem;
}

.pacman-info strong {
    color: #333;
}

#pacmanCanvas {
    display: block;
    margin: 0 auto 1rem;
    background: #000;
    border-radius: 10px;
}

.pacman-instructions {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.5rem;
}

/* --- War (Bataille) --- */

.war-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.war-controls label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.war-controls select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.war-auto-btn {
    padding: 0.4rem 1rem;
    font-size: 0.95rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.war-auto-btn:hover {
    background: #764ba2;
}

.war-auto-btn.active {
    background: #e74c3c;
}

.war-table {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
}

.war-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.war-player-label {
    font-size: 1rem;
    font-weight: 700;
    color: #555;
}

.war-card-slot {
    width: 80px;
    height: 112px;
    border-radius: 8px;
    background: #2d5a27;
    border: 3px solid #1a3a15;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #fff;
    transition: transform 0.2s;
}

.war-card-slot.revealed {
    background: #fff;
    border-color: #333;
    color: #333;
}

.war-card-slot.red {
    color: #e74c3c;
}

.war-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
}

.war-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.war-status {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
    min-height: 1.5rem;
}

.war-pile {
    display: flex;
    gap: 2px;
    min-height: 20px;
}

.war-pile-card {
    width: 16px;
    height: 22px;
    background: #2d5a27;
    border: 1px solid #1a3a15;
    border-radius: 3px;
}

.war-instructions {
    font-size: 0.9rem;
    color: #888;
    margin-top: 0.5rem;
}


/* --- Maths --- */

.maths-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.maths-controls label {
    font-size: 1.1rem;
    color: #555;
    font-weight: 600;
}

.maths-controls select {
    font-size: 1.1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    border: 2px solid #667eea;
    color: #333;
    font-weight: 600;
    cursor: pointer;
}

.maths-score-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: #555;
}

.maths-score-bar strong {
    color: #333;
}

.maths-streak strong {
    color: #e67e22;
}

.maths-correct strong {
    color: #27ae60;
}

.maths-wrong strong {
    color: #e74c3c;
}

.maths-problem {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    font-size: 2.5rem;
    font-weight: bold;
    color: #333;
}

.maths-operand {
    background: #f0f0f0;
    padding: 0.4rem 1rem;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}

.maths-operator {
    color: #667eea;
}

.maths-equals {
    color: #999;
}

.maths-answer-box {
    background: #f8f8f8;
    border: 3px dashed #ccc;
    padding: 0.4rem 1rem;
    border-radius: 12px;
    min-width: 80px;
    text-align: center;
    transition: background 0.3s, border-color 0.3s;
}

.maths-answer-box.correct {
    background: #d4efdf;
    border-color: #27ae60;
    color: #27ae60;
}

.maths-answer-box.wrong {
    background: #fadbd8;
    border-color: #e74c3c;
    color: #e74c3c;
}

.maths-input-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.maths-input {
    font-size: 1.5rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 2px solid #667eea;
    width: 120px;
    text-align: center;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
}

.maths-input:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.15);
}

.maths-submit-btn {
    padding: 0.6rem 1.5rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.maths-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.maths-submit-btn:active {
    transform: translateY(0);
}

.maths-feedback {
    font-size: 1.2rem;
    font-weight: 700;
    min-height: 1.8rem;
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.maths-feedback.correct {
    color: #27ae60;
}

.maths-feedback.wrong {
    color: #e74c3c;
}


.maths-log-toggle {
    margin-bottom: 1rem;
}

.maths-log-btn {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    background: transparent;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.maths-log-btn:hover {
    background: #667eea;
    color: white;
}

.maths-log {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
}

.maths-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.maths-log-table th {
    background: #f8f8f8;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: 0;
}

.maths-log-table td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
}

.maths-log-table tr.log-correct td:last-child {
    color: #27ae60;
    font-weight: 700;
}

.maths-log-table tr.log-wrong td:last-child {
    color: #e74c3c;
    font-weight: 700;
}

.maths-log-table tr.log-wrong {
    background: #fdf2f2;
}


.launcher-version {
    margin-top: 1.5rem;
    font-size: 0.75rem;
    color: #ccc;
}
