/* ============================================================
   Ultimate Tic-Tac-Toe 2.0 — Mockup-Faithful Futuristic Theme
   ============================================================ */

:root {
    --bg-deep: #080c14;
    --bg-surface: #0c1018;
    --panel-bg: rgba(10, 16, 28, 0.88);
    --text-white: #e8ecf4;
    --text-dim: #4a5a72;
    --text-muted: #2a3648;
    --cyan: #00e5ff;
    --cyan-dim: rgba(0, 229, 255, 0.12);
    --cyan-glow: rgba(0, 229, 255, 0.25);
    --pink: #ff2eea;
    --pink-dim: rgba(255, 46, 234, 0.12);
    --pink-glow: rgba(255, 46, 234, 0.25);
    --border: rgba(0, 229, 255, 0.12);
    --border-bright: rgba(0, 229, 255, 0.3);
    --cell-bg: #0a0f1a;
    --cell-hover: #111827;
    --radius: 6px;
    --font: 'Rajdhani', sans-serif;
    --font-display: 'Orbitron', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   Background FX
   ============================================================ */
.bg-fx {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, #080c14 0%, #0a1020 40%, #0d0e1a 60%, #12101c 80%, #0c0a14 100%);
}

.bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(0,229,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,229,255,0.04) 1px, transparent 1px);
    background-size: 50px 50px;
}

.bg-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.35;
}

.bg-glow--cyan {
    background: radial-gradient(circle, rgba(0,229,255,0.3) 0%, transparent 70%);
    bottom: -200px;
    left: -100px;
}

.bg-glow--pink {
    background: radial-gradient(circle, rgba(255,46,234,0.2) 0%, transparent 70%);
    top: -150px;
    right: -100px;
}

.scan-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, var(--cyan-dim) 30%, var(--cyan-glow) 50%, var(--cyan-dim) 70%, transparent 100%);
    animation: scan 8s linear infinite;
    opacity: 0.5;
}

@keyframes scan {
    0%   { top: -2px; }
    100% { top: 100%; }
}

/* ============================================================
   App Layout — 2 Columns
   ============================================================ */
.app-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 20px;
    max-width: 980px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    align-content: center;
}

/* ============================================================
   LEFT — Board Area
   ============================================================ */
.board-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Top Bar / Logo */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
}

.top-bar__left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 1.6rem;
    color: var(--cyan);
    text-shadow: 0 0 10px var(--cyan);
    line-height: 1;
}

.logo-text {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1.3;
    color: var(--text-white);
}

.cyan { color: var(--cyan); }
.pink { color: var(--pink); }

/* Turn Bar */
.turn-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.turn-symbol {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1rem;
}

.timer {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-dim);
}

/* Board Wrapper */
.board-wrapper {
    position: relative;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    aspect-ratio: 1/1;
    background: var(--bg-surface);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow:
        0 0 40px rgba(0,229,255,0.04),
        inset 0 0 20px rgba(0,0,0,0.4);
}

/* Sub-Grid */
.sub-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    aspect-ratio: 1/1;
    background: rgba(0, 229, 255, 0.02);
    border-radius: 4px;
    padding: 4px;
    position: relative;
    border: 1.5px solid var(--border);
    transition: all 0.3s ease;
}

.sub-grid.active-target {
    border-color: var(--cyan);
    background: rgba(0, 229, 255, 0.05);
    box-shadow: 0 0 20px rgba(0,229,255,0.1), inset 0 0 15px rgba(0,229,255,0.03);
}

.sub-grid.dim-grid {
    opacity: 0.35;
}

/* Cells */
.cell {
    background: var(--cell-bg);
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    aspect-ratio: 1/1;
    transition: background 0.15s, transform 0.15s;
    padding: 15%;
}

.cell:hover:not(.occupied) {
    background: var(--cell-hover);
}

.cell.occupied { cursor: default; }

.cell svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Sub-Grid Won Overlays */
.sub-grid.won-x::after,
.sub-grid.won-o::after,
.sub-grid.draw-grid::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    backdrop-filter: blur(2px);
    animation: wonPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sub-grid.won-x::after {
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.4);
    box-shadow: inset 0 0 30px rgba(0,229,255,0.08);
}

.sub-grid.won-o::after {
    background: rgba(255, 46, 234, 0.08);
    border: 1px solid rgba(255, 46, 234, 0.4);
    box-shadow: inset 0 0 30px rgba(255,46,234,0.08);
}

/* Big SVG overlays injected by JS */
.sub-grid .won-overlay {
    position: absolute;
    inset: 0;
    z-index: 11;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    animation: wonPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sub-grid .won-overlay svg {
    width: 65%;
    height: 65%;
    filter: drop-shadow(0 0 15px currentColor);
}

.sub-grid.draw-grid::after {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255,255,255,0.08);
}

@keyframes wonPop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* Board locked during AI */
.board-locked .cell { cursor: wait !important; }
.board-locked .cell:hover { background: var(--cell-bg) !important; transform: none !important; }

/* ============================================================
   COOKIE BANNER (LGPD)
   ============================================================ */
.cookie-banner {
    position: fixed;
    bottom: -100%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: rgba(12, 16, 24, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-top: 2px solid var(--cyan);
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: bottom 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

.cookie-banner.show {
    bottom: 0;
}

.cookie-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-dim);
}

.cookie-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.cookie-btn {
    padding: 8px 20px;
    font-size: 0.75rem;
    letter-spacing: 1px;
}

@media (min-width: 768px) {
    .cookie-banner {
        flex-direction: row;
        align-items: center;
        bottom: 20px;
        border-radius: 12px;
        transform: translateX(-50%) translateY(150%);
    }
    .cookie-banner.show {
        transform: translateX(-50%) translateY(0);
    }
}
/* ============================================================
   RIGHT — Sidebar
   ============================================================ */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-self: start;
    position: sticky;
    top: 20px;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.panel__header {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.signal-icon {
    color: var(--cyan);
    font-size: 0.9rem;
    animation: signalPulse 2s ease infinite;
}

@keyframes signalPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.panel__body {
    padding: 12px 14px;
}

/* Status Panel */
.status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 4px 0;
}

.status-label {
    color: var(--text-dim);
    font-weight: 600;
}

.status-value {
    color: var(--text-white);
    font-weight: 600;
}

/* Thinking Dots */
.thinking-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    background: var(--pink);
    border-radius: 50%;
    animation: thinkBounce 1s infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes thinkBounce {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.7); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* Scoreboard */
.scoreboard-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.score-player {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-icon {
    flex-shrink: 0;
}

.score-info {
    display: flex;
    flex-direction: column;
}

.score-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
}

.score-wins {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-white);
}

.score-vs {
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-dim);
}

/* Mini Grid (Active Board indicator) */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    width: 80px;
    margin: 0 auto;
}

.mini-cell {
    aspect-ratio: 1/1;
    background: rgba(255,255,255,0.04);
    border-radius: 2px;
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.3s;
}

.mini-cell.mini-active {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    box-shadow: 0 0 6px var(--cyan-dim);
}

.mini-cell.mini-won-x {
    background: var(--cyan-dim);
    border-color: rgba(0, 229, 255, 0.4);
}

.mini-cell.mini-won-o {
    background: var(--pink-dim);
    border-color: rgba(255, 46, 234, 0.4);
}

.mini-cell.mini-draw {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.15);
}

/* Sidebar Actions */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 2px;
    background: var(--panel-bg);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.action-btn:hover {
    color: var(--text-white);
    border-color: var(--border-bright);
    background: rgba(0, 229, 255, 0.05);
    box-shadow: 0 0 15px rgba(0,229,255,0.08);
}

.action-btn svg { stroke: currentColor; flex-shrink: 0; }

/* ============================================================
   Modal
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 12, 0.92);
    backdrop-filter: blur(16px);
    z-index: 200;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal.show { display: flex; }

.modal-content {
    background: linear-gradient(160deg, #0d1220, #060810);
    padding: 3rem 2.5rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border-bright);
    max-width: 380px;
    width: 100%;
    box-shadow: 0 0 80px rgba(0, 229, 255, 0.08);
    animation: modalIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-icon {
    margin-bottom: 1rem;
}

.modal-icon svg {
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 0 20px currentColor);
}

.modal-content h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: 0.4rem;
}

.modal-sub {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 2rem;
}

.profile-input {
    width: 100%;
    background: var(--cell-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    color: var(--text-white);
    font-family: var(--font-display);
    font-size: 0.8rem;
    margin-bottom: 20px;
    outline: none;
    text-align: center;
    transition: all 0.3s;
}

.profile-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan-dim);
    background: var(--cell-hover);
}

.profile-input::placeholder {
    color: var(--text-muted);
}

.lang-select {
    background: var(--cell-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-white);
    font-family: var(--font);
    font-size: 0.75rem;
    padding: 2px 6px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s;
}

.lang-select:hover {
    border-color: var(--cyan);
}

.lang-select option {
    background: var(--bg-surface);
    color: var(--text-white);
}

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: var(--font-display);
    font-size: 0.7rem;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.settings-btn:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan-dim);
}

#reset-score-btn:hover {
    background: rgba(255, 46, 234, 0.1);
    border-color: var(--pink);
    color: var(--pink);
    box-shadow: 0 0 10px var(--pink-dim);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1.5rem 0;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    font-family: var(--font-display);
    letter-spacing: 1px;
    opacity: 0.7;
}

.footer-credit {
    margin-bottom: 4px;
    color: var(--text-dim);
}

.footer-corp {
    font-weight: 700;
}

.modal-action { width: 100%; }

.modal-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 1rem;
}

@media (min-width: 480px) {
    .modal-actions-grid {
        grid-template-columns: 1fr 1fr;
    }
    #modal-reset-btn { grid-column: span 2; }
}

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

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text);
    color: var(--text);
}

.post-game-toolbar {
    display: none;
    justify-content: center;
    gap: 15px;
    padding: 1rem;
    background: rgba(0, 229, 255, 0.05);
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.post-game-toolbar.show {
    display: flex;
}

.toolbar-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    height: auto;
}

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

/* ============================================================
   Light Theme
   ============================================================ */
[data-theme="light"] {
    --bg-deep: #e8ecf4;
    --bg-surface: #dde2ed;
    --panel-bg: rgba(220, 228, 240, 0.92);
    --text-white: #1a1e2e;
    --text-dim: #4a5a72;
    --text-muted: #8a9ab2;
    --cyan: #0097a7;
    --cyan-dim: rgba(0, 151, 167, 0.12);
    --cyan-glow: rgba(0, 151, 167, 0.25);
    --pink: #c2185b;
    --pink-dim: rgba(194, 24, 91, 0.12);
    --pink-glow: rgba(194, 24, 91, 0.25);
    --border: rgba(0, 151, 167, 0.18);
    --border-bright: rgba(0, 151, 167, 0.35);
    --cell-bg: #d0d8e8;
    --cell-hover: #c5cfe0;
}

[data-theme="light"] .bg-gradient {
    background: linear-gradient(180deg, #e8ecf4 0%, #dde2ed 40%, #d5dce8 60%, #e0e4ef 80%, #e8ecf4 100%);
}

[data-theme="light"] .bg-grid {
    background-image:
        linear-gradient(rgba(0,151,167,0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,151,167,0.06) 1px, transparent 1px);
}

[data-theme="light"] .bg-glow--cyan { opacity: 0.15; }
[data-theme="light"] .bg-glow--pink { opacity: 0.1; }

[data-theme="light"] .modal-content {
    background: linear-gradient(160deg, #e0e5f0, #d5dce8);
}

[data-theme="light"] .cell svg line { stroke: #0097a7; }
[data-theme="light"] .cell svg circle { stroke: #c2185b; }

/* ============================================================
   Match History
   ============================================================ */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-empty {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    padding: 8px;
}

.history-entry {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
    border-left: 3px solid var(--text-muted);
    font-family: var(--font-display);
    letter-spacing: 0.5px;
}

.history-entry.win-x { border-left-color: var(--cyan); }
.history-entry.win-o { border-left-color: var(--pink); }
.history-entry.win-draw { border-left-color: var(--text-dim); }

.history-result {
    font-weight: 700;
    font-size: 0.75rem;
}

.history-meta {
    color: var(--text-muted);
    font-size: 0.65rem;
}

/* ============================================================
   Responsive — stack to single column on small screens
   ============================================================ */
@media (max-width: 900px) {
    .app-layout {
        grid-template-columns: 1fr;
        max-width: 560px;
    }

    .sidebar {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar .panel { flex: 1; min-width: 180px; }
    .sidebar-actions { flex-direction: row; }
    .sidebar-actions .action-btn { flex: 1; }
}

@media (max-width: 500px) {
    .app-layout { padding: 10px; gap: 10px; }
    .meta-grid { gap: 5px; padding: 5px; }
    .sub-grid { gap: 2px; padding: 3px; }
    .cell { padding: 12%; }
    .logo-text { font-size: 0.6rem; }
    .turn-bar { font-size: 0.7rem; padding: 6px 10px; }
}
