:root {
    --bg-color: #05050a;
    --panel-bg: rgba(15, 15, 25, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-muted: #8892b0;
    
    --color-x: #00f0ff;
    --color-x-glow: rgba(0, 240, 255, 0.5);
    
    --color-o: #ff0055;
    --color-o-glow: rgba(255, 0, 85, 0.5);
    
    --color-primary: #7000ff;
    --color-primary-glow: rgba(112, 0, 255, 0.5);
    
    --font-heading: 'Syncopate', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Ambient Background */
#ambient-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #05050a 100%);
    z-index: -2;
}

#particles {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1;
    opacity: 0.5;
}

#app-container {
    position: relative; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
}

.screen {
    position: absolute; width: 100%; height: 100%;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem;
    opacity: 0; transition: opacity 0.4s ease;
}

.screen.active {
    display: flex; opacity: 1; z-index: 10;
}

/* Glassmorphism */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
    max-width: 500px;
    width: 90%;
    padding: 3rem 2rem;
}

/* Typography */
.glitch-text {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    position: relative;
    text-shadow: 0 0 20px var(--color-x-glow);
}

.pro-badge {
    font-family: var(--font-heading);
    color: var(--color-o);
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
    margin-bottom: 1rem;
    text-shadow: 0 0 15px var(--color-o-glow);
}

.tagline {
    color: var(--text-muted); text-align: center; font-size: 0.85rem; letter-spacing: 4px; font-weight: 600; margin-bottom: 3rem;
}

.section-title {
    font-family: var(--font-heading); font-size: 1.5rem; text-align: center; margin-bottom: 2rem; letter-spacing: 2px;
}

/* Buttons */
.menu-buttons, .action-row { display: flex; flex-direction: column; gap: 1rem; width: 100%; }
.action-row { flex-direction: row; margin-top: 2rem; }
.action-row.column { flex-direction: column; }

.cyber-btn {
    font-family: var(--font-heading); font-size: 0.9rem; font-weight: 700; letter-spacing: 1.5px;
    padding: 1.2rem; border-radius: 12px; border: none; cursor: pointer; position: relative;
    transition: all 0.2s ease; width: 100%; position: relative; overflow: hidden;
}

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

.cyber-btn.primary {
    background: linear-gradient(45deg, var(--color-primary), #9900ff); color: white;
    box-shadow: 0 0 20px var(--color-primary-glow);
}
.cyber-btn.primary:hover { box-shadow: 0 0 30px var(--color-primary); filter: brightness(1.2); }

.cyber-btn.secondary {
    background: transparent; border: 1px solid var(--panel-border); color: var(--text-main);
}
.cyber-btn.secondary:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.2); }

/* Setup Forms */
.setup-grid { display: flex; flex-direction: column; gap: 1.5rem; width: 100%; }
.setup-group label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; letter-spacing: 1px; font-weight: 600; }
.cyber-select {
    width: 100%; padding: 1rem; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border);
    color: white; border-radius: 8px; font-family: var(--font-body); font-size: 1rem; outline: none; appearance: none;
}

.symbol-select { display: flex; gap: 1rem; }
.sym-btn {
    flex: 1; padding: 1rem; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border); border-radius: 8px; cursor: pointer; position: relative; transition: all 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.sym-btn.active { border-color: var(--color-x); box-shadow: 0 0 15px var(--color-x-glow); background: rgba(0, 240, 255, 0.1); }
.sym-btn[data-sym="O"].active { border-color: var(--color-o); box-shadow: 0 0 15px var(--color-o-glow); background: rgba(255, 0, 85, 0.1); }

/* Board */
#screen-game { justify-content: space-between; padding: 3rem 1rem; }
.board-container { position: relative; width: 100%; max-width: 400px; aspect-ratio: 1; margin: 0 auto; }
.tic-tac-board {
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 10px; width: 100%; height: 100%;
}

.cell {
    background: var(--panel-bg); border-radius: 16px; border: 1px solid var(--panel-border);
    display: flex; justify-content: center; align-items: center; cursor: pointer; position: relative;
    transition: background 0.3s, transform 0.1s, box-shadow 0.3s;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.cell:hover { background: rgba(255,255,255,0.05); }
.cell:active { transform: scale(0.95); }

/* X and O Graphics using CSS */
.cell.x::before, .cell.x::after {
    content: ''; position: absolute; width: 60%; height: 8px; background: var(--color-x); border-radius: 4px;
    box-shadow: 0 0 15px var(--color-x); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.cell.x::before { transform: rotate(45deg); }
.cell.x::after { transform: rotate(-45deg); }

.cell.o::before {
    content: ''; position: absolute; width: 50%; height: 50%; border: 8px solid var(--color-o); border-radius: 50%;
    box-shadow: 0 0 15px var(--color-o), inset 0 0 15px var(--color-o); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn { 0% { transform: scale(0) rotate(var(--rot, 0deg)); opacity: 0; } 100% { transform: scale(1) rotate(var(--rot, 0deg)); opacity: 1; } }
.cell.x::before { --rot: 45deg; }
.cell.x::after { --rot: -45deg; }

/* Win Line */
.win-line {
    position: absolute; background: white; height: 6px; border-radius: 3px; box-shadow: 0 0 20px white;
    transform-origin: left center; z-index: 5; display: none; pointer-events: none; transition: width 0.4s ease-out; width: 0;
}

/* HUD */
.hud { display: flex; justify-content: space-between; width: 100%; max-width: 500px; margin-bottom: 2rem; }
.player-card { display: flex; flex-direction: column; align-items: flex-start; }
.player-card.right { align-items: flex-end; }
.hud-name { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; letter-spacing: 1px; margin-bottom: 0.2rem; }
.hud-score { font-size: 2rem; font-family: var(--font-heading); font-weight: 700; }
.hud-sym { font-size: 1.5rem; font-weight: 900; margin-top: 0.2rem; }
.hud-sym.x { color: var(--color-x); text-shadow: 0 0 10px var(--color-x-glow); }
.hud-sym.o { color: var(--color-o); text-shadow: 0 0 10px var(--color-o-glow); }
.hud-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#match-status { font-size: 0.8rem; font-weight: 800; letter-spacing: 2px; margin-bottom: 0.5rem; }
#turn-indicator { font-size: 1rem; font-family: var(--font-heading); color: white; transition: color 0.3s; }
.turn-x { color: var(--color-x) !important; text-shadow: 0 0 10px var(--color-x-glow); }
.turn-o { color: var(--color-o) !important; text-shadow: 0 0 10px var(--color-o-glow); }

/* Controls */
.game-controls { display: flex; gap: 1.5rem; margin-top: 2rem; }
.icon-btn { 
    width: 50px; height: 50px; border-radius: 25px; border: 1px solid var(--panel-border); background: var(--panel-bg);
    color: white; font-size: 1.2rem; cursor: pointer; position: relative; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-2px); }

/* Floating Audio */
.floating-btn { position: fixed; top: 1rem; right: 1rem; z-index: 100; width: 40px; height: 40px; border-radius: 20px; background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border); color: white; cursor: pointer; position: relative; }

/* Stats & Results */
.result-title { font-family: var(--font-heading); font-size: 2.5rem; text-align: center; margin-bottom: 2rem; }
.result-title.win { color: var(--color-x); text-shadow: 0 0 20px var(--color-x-glow); }
.result-title.lose { color: var(--color-o); text-shadow: 0 0 20px var(--color-o-glow); }
.result-title.draw { color: var(--text-muted); }
.stat-row { display: flex; justify-content: space-between; padding: 1rem 0; border-bottom: 1px solid var(--panel-border); font-size: 0.9rem; }
.stat-row.highlight { color: var(--color-primary); font-weight: 700; text-shadow: 0 0 10px var(--color-primary-glow); }
.stat-row.xp-row { color: var(--color-x); font-weight: 700; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; width: 100%; }
.stat-card { background: rgba(0,0,0,0.3); padding: 1.5rem; border-radius: 12px; text-align: center; border: 1px solid var(--panel-border); }
.stat-val { font-size: 1.8rem; font-family: var(--font-heading); font-weight: 700; margin-bottom: 0.5rem; }
.stat-lbl { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 1px; font-weight: 600; }
.player-mini-profile { margin-top: 2rem; width: 100%; text-align: center; }
.rank-badge { font-family: var(--font-heading); color: var(--color-primary); margin-bottom: 0.5rem; letter-spacing: 1px; font-size: 0.9rem; }
.xp-bar { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.xp-fill { height: 100%; background: var(--color-x); width: 0%; box-shadow: 0 0 10px var(--color-x); transition: width 0.5s ease; }

.toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); background: white; color: black; padding: 0.8rem 1.5rem; border-radius: 20px; font-weight: 700; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-10px); box-shadow: 0 10px 30px rgba(255,255,255,0.3); }

/* Responsive adjustments */
@media (max-width: 450px) {
    .glass-panel { padding: 2rem 1.5rem; border-radius: 16px; border: none; border-top: 1px solid rgba(255,255,255,0.1); background: var(--bg-color); box-shadow: none; }
    .glitch-text { font-size: 2rem; }
}
