:root {
    --color-bg: #050505;
    --color-surface: #0f0f0f;
    --color-blue: #3A86FF;
    --color-purple: #8B5CF6;
    --color-pink: #EC4899;
    --color-green: #10B981;
    --color-yellow: #FFB800;
    --color-red: #FF006E;
    --color-orange: #FF6B35;
    --color-border: rgba(255, 255, 255, 0.08);
    --font-main: 'Space Grotesk', sans-serif;
}

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

body {
    background: var(--color-bg);
    color: #fff;
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

header {
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    padding: 1.2rem 0;
    position: sticky; top: 0; z-index: 100;
}

.container { 
    max-width: 1100px; 
    margin: 0 auto; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 2rem; 
}

/* Logo Sync */
.logo-text { 
    font-size: 1.2rem; 
    font-weight: 700; 
    letter-spacing: 0.25em; 
}
.logo-text span:nth-child(1) { color: #FFB800; }
.logo-text span:nth-child(2) { color: #FF006E; }
.logo-text span:nth-child(3) { color: #FF6B35; }
.logo-text span:nth-child(4) { color: #FFB800; }
.logo-text span:nth-child(5) { color: var(--color-blue); }
.logo-text span:nth-child(6) { color: var(--color-purple); }
.logo-text span:nth-child(7) { color: var(--color-pink); }

.back-link {
    text-decoration: none; 
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem; 
    font-weight: 700; 
    display: flex; 
    align-items: center; 
    gap: 8px;
    transition: 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.back-link:hover { color: #fff; }

/* Main Layout */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
}

.screen {
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === START SCREEN === */
.start-content {
    max-width: 600px;
    margin: 0 auto;
}

.game-title {
    text-align: center;
    margin-bottom: 3rem;
}

.icon-hero {
    width: 90px; 
    height: 90px; 
    margin: 0 auto 1.5rem;
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 20px; 
    background: rgba(139, 92, 246, 0.1); 
    color: var(--color-purple);
    animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.game-title h2 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-title p {
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
}

/* === MODE SELECTOR === */
.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 1.5rem 2rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.mode-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.mode-btn:hover::before {
    opacity: 1;
}

.mode-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.mode-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mode-player .mode-icon {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-purple);
}

.mode-ai .mode-icon {
    background: rgba(236, 72, 153, 0.15);
    color: var(--color-pink);
}

.mode-player:hover {
    border-color: var(--color-purple);
}

.mode-ai:hover {
    border-color: var(--color-pink);
}

.mode-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mode-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.mode-desc {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.4);
}

/* === GAME SCREEN === */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

.stat-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    transition: all 0.3s;
}

.stat-highlight {
    border-left: 4px solid var(--color-pink);
    background: linear-gradient(135deg, var(--color-surface) 0%, rgba(236, 72, 153, 0.05) 100%);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-purple);
}

.stat-icon-pink {
    background: rgba(236, 72, 153, 0.15);
    color: var(--color-pink);
}

.stat-icon-blue {
    background: rgba(58, 134, 255, 0.15);
    color: var(--color-blue);
}

.stat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    font-weight: 600;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
}

/* === MORPION GRID === */
.game-container {
    max-width: 700px;
    margin: 0 auto;
}

.morpion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto 2rem;
}

/* === CELL === */
.cell {
    aspect-ratio: 1;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    user-select: none;
}

.cell:hover:not(.cell-filled) {
    border-color: var(--color-purple);
    background: rgba(139, 92, 246, 0.1);
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.3);
}

.cell-filled {
    cursor: not-allowed;
}

/* === CELL SYMBOLS === */
.cell-x svg path {
    stroke: var(--color-purple);
}

.cell-o svg circle {
    stroke: var(--color-pink);
}

/* === WINNING CELLS === */
.cell-winner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.05) 100%) !important;
    border-color: var(--color-green) !important;
    animation: winPulse 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.4) !important;
}

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

/* === ANIMATIONS === */
@keyframes symbolAppear {
    from {
        opacity: 0;
        transform: scale(0.5) rotate(-45deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.cell-filled {
    animation: symbolAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    20%, 60% {
        transform: translateX(-6px);
    }
    40%, 80% {
        transform: translateX(6px);
    }
}

.shake-animation {
    animation: shake 0.4s ease;
}

@keyframes counterBump {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

.score-update {
    animation: counterBump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* === GAME MESSAGE === */
.game-message {
    text-align: center;
    margin-bottom: 2rem;
    min-height: 32px;
}

.game-message p {
    font-size: 1.1rem;
    font-weight: 600;
    animation: messageSlide 0.3s ease;
    letter-spacing: 0.05em;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-success {
    color: var(--color-green);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.message-warning {
    color: var(--color-yellow);
    text-shadow: 0 0 20px rgba(255, 184, 0, 0.3);
}

.message-info {
    color: rgba(255,255,255,0.6);
}

/* === BOARD DISABLED === */
.board-disabled .cell:not(.cell-filled) {
    cursor: not-allowed;
    opacity: 0.3;
    pointer-events: none;
}

/* === BUTTONS === */
.actions {
    display: flex;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-purple) 0%, var(--color-pink) 100%);
    color: white;
    box-shadow: 0 10px 25px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.5);
}

.btn-secondary {
    background: transparent;
    color: #fff;
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
}

.btn:active {
    transform: scale(0.97);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    main {
        padding: 2rem 1rem;
    }
    
    .game-title h2 {
        font-size: 2.2rem;
    }
    
    .icon-hero {
        width: 70px;
        height: 70px;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .stat-item {
        padding: 1rem;
        flex-direction: row;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
    }
    
    .stat-value {
        font-size: 1.8rem;
    }
    
    .morpion-grid {
        gap: 0.8rem;
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .cell {
        border-width: 2px;
    }
    
    .cell svg {
        width: 70px !important;
        height: 70px !important;
    }
    
    .actions {
        flex-direction: column;
        gap: 0.8rem;
    }
    
    .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 0 1rem;
    }
    
    .logo-text {
        font-size: 1rem;
    }
    
    .game-title h2 {
        font-size: 1.8rem;
    }
    
    .game-title p {
        font-size: 0.9rem;
    }
    
    .icon-hero {
        width: 60px;
        height: 60px;
    }
    
    .icon-hero svg {
        width: 35px !important;
        height: 35px !important;
    }
    
    .mode-btn {
        padding: 1rem 1.2rem;
        gap: 1rem;
    }
    
    .mode-icon {
        width: 48px;
        height: 48px;
    }
    
    .mode-name {
        font-size: 1rem;
    }
    
    .mode-desc {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .morpion-grid {
        max-width: 100%;
        gap: 0.6rem;
        padding: 0 0.5rem;
    }
    
    .cell svg {
        width: 50px !important;
        height: 50px !important;
    }
    
    .game-message p {
        font-size: 1rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.9rem 1.5rem;
    }
}

@media (max-width: 380px) {
    .game-title h2 {
        font-size: 1.5rem;
    }
    
    .morpion-grid {
        gap: 0.5rem;
    }
    
    .cell svg {
        width: 40px !important;
        height: 40px !important;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
}