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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    min-height: 100vh;
    color: #fff;
}

.screen { min-height: 100vh; display: flex; flex-direction: column; }
.screen.hidden { display: none !important; }

/* Settings */
.settings-container {
    max-width: 540px; margin: auto; padding: 40px;
    background: rgba(0,0,0,0.3); border-radius: 20px; text-align: center;
}
.settings-container h1 { font-size: 3.5rem; margin-bottom: 10px; }
.settings-container h2 { font-size: 2rem; margin-bottom: 35px; font-weight: normal; opacity: 0.9; }
.setting-group { margin-bottom: 28px; }
.setting-group label { display: block; font-size: 1.4rem; margin-bottom: 12px; }
.player-input {
    width: 100%; padding: 14px 18px; font-size: 1.3rem;
    border: 3px solid #fff; border-radius: 10px;
    background: rgba(255,255,255,0.9); color: #2c3e50; text-align: center; display: block;
}
.player-input:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.button-group { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.setting-btn {
    padding: 14px 22px; font-size: 1.15rem;
    border: 3px solid #fff; background: transparent; color: #fff;
    border-radius: 12px; cursor: pointer; transition: all 0.2s;
    min-width: 130px; min-height: 60px;
}
.setting-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.setting-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.setting-btn.active { background: #fff; color: #2c3e50; font-weight: bold; }
.primary-btn {
    margin-top: 20px; padding: 20px 50px; font-size: 1.8rem;
    background: #e74c3c; color: #fff; border: none; border-radius: 15px;
    cursor: pointer; font-weight: bold; transition: all 0.2s;
    min-height: 70px; display: flex; width: 100%; align-items: center; justify-content: center;
    text-decoration: none;
}
.primary-btn:hover { background: #c0392b; transform: scale(1.03); }
.primary-btn:focus { outline: 4px solid #f39c12; outline-offset: 3px; }
.secondary-btn { margin-top: 15px; background: rgba(255,255,255,0.2); border: 3px solid #fff; }
.secondary-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.03); }
.back-btn { text-decoration: none; }

.rules-summary {
    background: rgba(255,255,255,0.1); border-radius: 12px;
    padding: 18px 22px; margin: 20px 0; text-align: left;
}
.rules-summary h3 { font-size: 1.3rem; margin-bottom: 10px; }
.rules-summary ul { list-style: none; }
.rules-summary li { font-size: 1.05rem; padding: 5px 0; opacity: 0.9; }
.rules-summary li::before { content: '• '; color: #f39c12; font-weight: bold; }

/* Header */
.game-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 25px; background: rgba(0,0,0,0.3);
    flex-wrap: wrap; gap: 10px; min-height: 80px;
}
.game-header h1 { font-size: 1.8rem; }
.header-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.header-right { display: flex; gap: 12px; flex-wrap: wrap; }
.player-indicator {
    display: flex; align-items: center; gap: 14px;
    background: rgba(255,255,255,0.15); padding: 12px 22px;
    border-radius: 12px; font-size: 1.3rem; font-weight: bold;
    border: 3px solid rgba(255,255,255,0.3);
}
.current-symbol {
    font-size: 1.8rem; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-weight: 900;
}
.current-symbol.x { color: #e74c3c; }
.current-symbol.o { color: #3498db; }
.turn-label { font-weight: normal; opacity: 0.85; }
.action-btn {
    padding: 14px 22px; font-size: 1.1rem;
    background: rgba(255,255,255,0.9); color: #2c3e50;
    border: none; border-radius: 10px; cursor: pointer;
    font-weight: bold; transition: all 0.2s; min-height: 52px;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.action-btn:hover { background: #fff; transform: scale(1.05); }
.action-btn:focus { outline: 4px solid #f39c12; outline-offset: 2px; }

/* Game Area */
.game-area {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 20px; gap: 20px;
}

/* Score Display */
.score-display {
    display: flex; gap: 20px; align-items: center;
}
.score-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 20px; border-radius: 12px;
    background: rgba(255,255,255,0.1); font-size: 1.1rem;
    border: 3px solid transparent;
}
.score-item.x-score { border-color: rgba(231,76,60,0.5); }
.score-item.o-score { border-color: rgba(52,152,219,0.5); }
.score-num { font-size: 2rem; font-weight: bold; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* Morpion Grid */
.morpion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 16px;
}

.morpion-cell {
    width: clamp(100px, 22vw, 140px);
    height: clamp(100px, 22vw, 140px);
    background: rgba(255,255,255,0.1);
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 900;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.morpion-cell:hover:not(.x):not(.o) { background: rgba(255,255,255,0.25); transform: scale(1.05); }
.morpion-cell:focus { outline: 4px solid #f39c12; outline-offset: 2px; }
.morpion-cell.x { color: #e74c3c; cursor: default; }
.morpion-cell.o { color: #3498db; cursor: default; }
.morpion-cell.win {
    background: rgba(241,196,15,0.25);
    border-color: #f1c40f;
    box-shadow: 0 0 20px rgba(241,196,15,0.5);
    animation: win-pulse 0.7s ease infinite alternate;
}
@keyframes win-pulse {
    from { box-shadow: 0 0 10px rgba(241,196,15,0.4); }
    to   { box-shadow: 0 0 25px rgba(241,196,15,0.8); }
}

/* Result Banner */
.result-banner {
    font-size: 1.6rem; font-weight: bold; text-align: center;
    padding: 16px 32px; border-radius: 14px;
    background: rgba(0,0,0,0.4); border: 3px solid #f39c12;
    animation: fade-in 0.3s ease;
}
.result-banner.hidden { display: none; }
@keyframes fade-in {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

@media (max-width: 768px) {
    .game-header { justify-content: center; }
    .header-left { display: none; }
    .header-center, .header-right { width: 100%; justify-content: center; }
    .score-display { gap: 10px; }
    .score-item { padding: 10px 14px; font-size: 1rem; }
}
