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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #e2e8f0;
}

/* Mode Selection Styles */
.mode-selection {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

.mode-container {
    background: rgba(45, 55, 72, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.mode-container h1 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    color: #e2e8f0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btn-mode {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border: 2px solid #718096;
    padding: 20px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-height: 120px;
    justify-content: center;
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: bold;
}

.btn-mode:hover {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border-color: #48bb78;
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 5px;
}

.mode-title {
    font-size: 1.3rem;
    font-weight: bold;
    color: #e2e8f0;
    margin-bottom: 5px;
}

.mode-desc {
    font-size: 0.9rem;
    color: #a0aec0;
}

.container {
    background: rgba(45, 55, 72, 0.95);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 500px;
    width: 100%;
    min-height: 600px;
    transition: background 0.3s ease;
    border: 3px solid transparent;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.container.player-x {
    background: rgba(69, 26, 26, 0.95);
    border: 3px solid #e53e3e;
}

.container.player-o {
    background: rgba(26, 54, 93, 0.95);
    border: 3px solid #3182ce;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #e2e8f0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.player-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 20px;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-width: 80px;
    border: 3px solid transparent;
    box-sizing: border-box;
    position: absolute;
    background: #1a202c;
}

.corner-left {
    top: -3px;
    left: -3px;
    border-top-left-radius: 20px;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0;
}

.corner-right {
    top: -3px;
    right: -3px;
    border-top-right-radius: 20px;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0;
}

.turn-counter {
    font-size: 0.8rem;
    color: #a0aec0;
    font-weight: bold;
    text-align: center;
    min-height: 50px;
    max-height: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    margin-bottom: 10px;
    margin-top: 70px;
}

.round-counter {
    font-size: 1rem;
    color: #a0aec0;
    font-weight: bold;
    text-align: center;
    min-height: 40px;
    max-height: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.round-display {
    display: flex;
    gap: 20px;
}

.round-icon {
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.round-icon.current-round {
    transform: scale(1.3);
    text-shadow: 0 0 10px #2d3748, 0 0 3px #48bb78;
    filter: brightness(1.5);
    color: #48bb78;
}

.top-controls {
    text-align: center;
    margin-bottom: 10px;
}

.player-score.active {
    background: rgba(72, 187, 120, 0.2);
    box-shadow: 0 0 15px rgba(72, 187, 120, 0.3);
}

.player-score.player-x.active {
    background: rgba(229, 62, 62, 0.2);
    box-shadow: 0 0 15px rgba(229, 62, 62, 0.3);
}

.player-score.player-o.active {
    background: rgba(49, 130, 206, 0.2);
    box-shadow: 0 0 15px rgba(49, 130, 206, 0.3);
}

.player-score.player-x.active.corner-left {
    border-right: 3px solid #e53e3e;
    border-bottom: 3px solid #e53e3e;
    border-top: 3px solid #e53e3e;
    border-left: 3px solid #e53e3e;
}

.player-score.player-o.active.corner-right {
    border-left: 3px solid #3182ce;
    border-bottom: 3px solid #3182ce;
    border-top: 3px solid #3182ce;
    border-right: 3px solid #3182ce;
}

.player-emoji {
    font-size: 2rem;
    margin-bottom: 5px;
    position: relative;
}

.player-emoji::before {
    content: "👑";
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    font-size: 1rem;
    opacity: 0;
    transition: all 0.5s ease;
}

.player-emoji.winner::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: crownSlideDown 0.5s ease-out;
}

@keyframes crownSlideDown {
    0% {
        transform: translateX(-50%) translateY(-10px);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.score-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e2e8f0;
    transition: all 0.3s ease;
}

.score-value.score-updating {
    color: #ffd700;
    transform: scale(1.2);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.turn-counter span {
    font-size: 1.8rem;
    color: #e2e8f0;
    font-weight: bold;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 120px);
    grid-template-rows: repeat(3, 120px);
    grid-gap: 15px;
    margin: 50px auto 30px auto;
    background: #1a202c;
    padding: 20px;
    border-radius: 15px;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3);
    justify-content: center;
}

.cell {
    aspect-ratio: 1;
    background: #2d3748;
    border: none;
    border-radius: 12px;
    font-size: 4rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    width: 120px;
    height: 120px;
}

.cell:hover {
    background: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.cell.x {
    color: #e53e3e;
    background: #742a2a;
}

.cell.o {
    color: #3182ce;
    background: #2a4365;
}

.cell.disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.cell.winning {
    background: #48bb78 !important;
    color: white;
    animation: pulse 0.6s ease-in-out;
}

.cell.oldest {
    opacity: 0.6;
}

.cell.oldest.x {
    border: 2px dashed #e53e3e;
}

.cell.oldest.o {
    border: 2px dashed #3182ce;
}

.cell.oldest.current-player-turn {
    animation: fadeWarning 0.6s ease-in-out infinite alternate;
}

.cell.newest.x {
    border: 1px solid #e53e3e;
    box-shadow: 0 0 5px rgba(229, 62, 62, 0.3);
}

.cell.newest.o {
    border: 1px solid #3182ce;
    box-shadow: 0 0 5px rgba(49, 130, 206, 0.3);
}

@keyframes fadeWarning {
    0% { opacity: 0.6; }
    100% { opacity: 0.1; }
}

@keyframes glow {
    0% { box-shadow: 0 0 5px rgba(72, 187, 120, 0.3); }
    50% { box-shadow: 0 0 15px rgba(72, 187, 120, 0.8); }
    100% { box-shadow: 0 0 5px rgba(72, 187, 120, 0.3); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.game-controls {
    margin: 20px 0;
}

.btn {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    color: #e2e8f0;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #718096;
    margin: 0 5px;
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
}

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

.btn-secondary {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border: 2px solid #718096;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: #e2e8f0;
}

.btn-primary {
    background: linear-gradient(135deg, #48bb78 0%, #2f855a 100%);
    border: 2px solid #48bb78;
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-3px);
}

.winner-announcement {
    color: #48bb78;
    font-size: 1rem;
    font-weight: bold;
    animation: celebration 0.5s ease-in-out;
    min-height: 50px;
    max-height: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.draw-announcement {
    color: #ed8936;
    font-size: 1.1rem;
    font-weight: bold;
    min-height: 50px;
    max-height: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes celebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@media (max-width: 600px) {
    .container {
        margin: 15px;
        padding: 20px;
        max-width: 95vw;
    }
    
    .turn-counter {
        margin-top: 65px;
    }
    
    .game-board {
        grid-template-columns: repeat(3, 100px);
        grid-template-rows: repeat(3, 100px);
        grid-gap: 10px;
        margin: 45px auto 25px auto;
        padding: 18px;
    }
    
    .cell {
        font-size: 3rem;
        width: 100px;
        height: 100px;
        border-radius: 10px;
    }
    
    .player-score {
        padding: 12px 18px;
        min-width: 90px;
        width: 90px;
    }
    
    .player-emoji::before {
        top: -5px;
        font-size: 0.95rem;
    }
    
    .player-emoji.winner::before {
        transform: translateX(-50%) translateY(0px);
    }
    
    .round-display {
        gap: 18px;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 10px;
        padding: 15px;
        max-width: 95vw;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }
    
    .game-board {
        grid-template-columns: repeat(3, 80px);
        grid-template-rows: repeat(3, 80px);
        grid-gap: 8px;
        margin: 40px auto 20px auto;
        padding: 15px;
    }
    
    .cell {
        font-size: 2.5rem;
        width: 80px;
        height: 80px;
        border-radius: 8px;
    }
    
    .player-score {
        padding: 10px 15px;
        min-width: 80px;
        width: 80px;
    }
    
    .player-emoji {
        font-size: 1.5rem;
    }
    
    .player-emoji::before {
        top: -4px;
        font-size: 0.9rem;
    }
    
    .player-emoji.winner::before {
        transform: translateX(-50%) translateY(0);
    }
    
    .score-value {
        font-size: 1.2rem;
    }
    
    .round-icon {
        font-size: 1.2rem;
    }
    
    .round-display {
        gap: 15px;
    }
    
    .turn-counter {
        font-size: 0.9rem;
        margin-bottom: 5px;
        margin-top: 60px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        margin: 0 3px;
    }
    
    .btn-small {
        padding: 6px 15px;
        font-size: 0.8rem;
    }
}

@media (min-width: 600px) {
    .mode-buttons {
        flex-direction: row;
        gap: 30px;
    }
    
    .btn-mode {
        flex: 1;
    }
}
