@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&family=Orbitron:wght@400;700;900&display=swap');

:root {
    --neon-primary: #00f0ff;
    --neon-secondary: #ff0055;
    --neon-accent: #ffe600;
    --neon-purple: #c77dff;
    --bg-dark: #050508;
    --bg-card: rgba(10, 10, 15, 0.85);
    --board-line: rgba(0, 240, 255, 0.2);
    --cell-hover: rgba(0, 240, 255, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(136, 0, 255, 0.08), transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(0, 240, 255, 0.08), transparent 40%);
}

.orbitron {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 0.1em;
}

.game-container {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    gap: 40px;
    min-height: 100vh;
    align-items: flex-start;
}

/* Side Panel */
.side-panel {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    position: sticky;
    top: 40px;
}

.back-link {
    color: var(--neon-primary);
    text-decoration: none;
    font-weight: 800;
    font-size: 0.8rem;
    font-family: 'Orbitron', sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.back-link:hover {
    text-shadow: 0 0 10px var(--neon-primary);
    transform: translateX(-5px);
}

.mode-selection, .stats-panel {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.mode-selection::before, .stats-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--neon-secondary);
}

.mode-selection h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--neon-secondary);
}

.btn-mode {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #aaa;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    text-align: left;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.btn-mode:hover {
    border-color: var(--neon-primary);
    color: #fff;
    background: rgba(0, 240, 255, 0.05);
}

.btn-mode.active {
    border-color: var(--neon-primary);
    color: var(--neon-primary);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: inset 0 0 10px rgba(0, 240, 255, 0.2);
}

/* AI Options */
.opt-label {
    font-size: 0.7rem;
    font-family: 'Orbitron', sans-serif;
    color: #888;
    margin-bottom: 8px;
    letter-spacing: 0.15em;
}

.seg-row {
    display: flex;
    gap: 6px;
}

.btn-diff, .btn-side {
    flex: 1;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    padding: 8px 4px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 0.65rem;
    transition: all 0.25s ease;
    letter-spacing: 0.05em;
}

.btn-diff:hover, .btn-side:hover {
    border-color: var(--neon-accent);
    color: #fff;
}

.btn-diff.active, .btn-side.active {
    border-color: var(--neon-accent);
    color: var(--neon-accent);
    background: rgba(255, 230, 0, 0.08);
    box-shadow: inset 0 0 8px rgba(255, 230, 0, 0.15);
}

#player-name {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 240, 255, 0.3);
    padding: 12px;
    color: #fff;
    margin-bottom: 10px;
    outline: none;
    font-family: 'Inter', sans-serif;
}

#player-name:focus {
    border-color: var(--neon-primary);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.btn-primary {
    width: 100%;
    background: var(--neon-primary);
    color: var(--bg-dark);
    border: none;
    padding: 12px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.1em;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--neon-primary);
    transform: translateY(-2px);
}

.btn-secondary {
    width: 100%;
    background: transparent;
    border: 1px solid var(--neon-secondary);
    color: var(--neon-secondary);
    padding: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: rgba(255, 0, 85, 0.1);
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.3);
}

/* Stats */
.score-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.score-box {
    flex: 1;
    padding: 15px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.score-box.black { border-top: 3px solid var(--neon-purple); }
.score-box.white { border-top: 3px solid var(--neon-primary); }

.score-box .label {
    font-size: 0.7rem;
    font-family: 'Orbitron', sans-serif;
    color: #888;
    margin-bottom: 5px;
    letter-spacing: 0.15em;
}

.score-box .value {
    font-size: 1.8rem;
    font-weight: 900;
    font-family: 'Orbitron', sans-serif;
    transition: transform 0.3s ease;
}

.turn-indicator {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    color: var(--neon-primary);
    padding: 10px;
    background: rgba(0, 240, 255, 0.1);
    border-radius: 2px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    letter-spacing: 0.1em;
}

.match-info {
    font-size: 0.75rem;
    color: #888;
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: 0.05em;
}

/* Board Area */
.main-board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.board-frame {
    padding: 15px;
    background: #0a0a10;
    border: 1px solid rgba(0, 240, 255, 0.3);
    box-shadow:
        0 0 50px rgba(0, 0, 0, 0.8),
        0 0 80px rgba(0, 240, 255, 0.15);
    border-radius: 8px;
    position: relative;
}

.othello-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(80vw, 600px);
    height: min(80vw, 600px);
    background: #0d1f1a;
    background-image:
        linear-gradient(135deg, #0a1815 0%, #0d2a22 100%);
    border: 1px solid var(--board-line);
}

.cell {
    border: 1px solid rgba(0, 240, 255, 0.12);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
    position: relative;
    transition: background 0.2s;
}

.cell.valid-move {
    cursor: pointer;
}

.cell.valid-move:hover {
    background: rgba(0, 240, 255, 0.15);
}

.cell.valid-move::after {
    content: '';
    width: 18%;
    height: 18%;
    background: rgba(0, 240, 255, 0.4);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    animation: pulseDot 1.6s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50%      { opacity: 1;   transform: scale(1.15); }
}

/* Last move highlight */
.cell.last-move::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 2px dashed var(--neon-accent);
    border-radius: 4px;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(255, 230, 0, 0.4);
    animation: lastMovePulse 1.8s ease-in-out infinite;
}

@keyframes lastMovePulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* Piece */
.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    transform-style: preserve-3d;
    position: relative;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.3s ease;
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #4a2270, #1a0030 70%, #0a0015);
    box-shadow:
        0 0 18px rgba(199, 125, 255, 0.55),
        inset 0 -4px 8px rgba(0, 0, 0, 0.4),
        inset 0 4px 6px rgba(199, 125, 255, 0.25);
    border: 1px solid #c77dff;
}

.piece.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, #d0f5ff 60%, #88e0ff);
    box-shadow:
        0 0 18px rgba(0, 240, 255, 0.55),
        inset 0 -4px 8px rgba(0, 100, 130, 0.3),
        inset 0 4px 6px rgba(255, 255, 255, 0.5);
    border: 1px solid #00f0ff;
}

.piece.drop-in {
    animation: dropIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropIn {
    0%   { transform: scale(0)   rotate(-180deg); opacity: 0; }
    60%  { transform: scale(1.1) rotate(0deg);    opacity: 1; }
    100% { transform: scale(1)   rotate(0deg);    opacity: 1; }
}

.piece.flipping {
    animation: flipPiece 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes flipPiece {
    0%   { transform: rotateY(0deg)   scale(1); }
    50%  { transform: rotateY(90deg)  scale(1.15); }
    100% { transform: rotateY(0deg)   scale(1); }
}

/* Pass toast */
.pass-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(5, 5, 8, 0.92);
    border: 1px solid var(--neon-accent);
    color: var(--neon-accent);
    padding: 16px 32px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: 0.15em;
    box-shadow: 0 0 30px rgba(255, 230, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    white-space: nowrap;
}

.pass-toast.show {
    animation: passShow 1.6s ease forwards;
}

@keyframes passShow {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* Overlays */
.matching-overlay {
    text-align: center;
    padding: 20px;
    border: 1px dashed var(--neon-primary);
    margin-top: 20px;
}

.loader {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 240, 255, 0.1);
    border-top: 3px solid var(--neon-primary);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 8, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    animation: overlayFade 0.4s ease;
}

@keyframes overlayFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.overlay h2 {
    font-size: 2.5rem;
    color: var(--neon-secondary);
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(255, 0, 85, 0.5);
}

.winner-text {
    font-size: 1.5rem;
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    text-shadow: 0 0 15px currentColor;
}

.final-scores {
    font-size: 3rem;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    margin-bottom: 40px;
    letter-spacing: 0.1em;
}

#btn-retry {
    max-width: 200px;
}

.btn-small {
    background: transparent;
    border: 1px solid #555;
    color: #888;
    padding: 5px 15px;
    font-size: 0.7rem;
    cursor: pointer;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 900px) {
    .game-container {
        flex-direction: column;
        align-items: center;
        padding: 20px 10px;
    }
    .side-panel {
        flex: none;
        width: 100%;
        max-width: 600px;
        position: static;
    }
    .othello-board {
        width: 90vw;
        height: 90vw;
    }
}
