:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-magenta: #d946ef;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gradient-start: #06b6d4;
    --gradient-end: #d946ef;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --stone-color: #94a3b8;
    --stone-highlight: #06b6d4;
    --stone-removed: #475569;
    --player1-color: #06b6d4;
    --player2-color: #d946ef;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    text-align: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    flex: 1;
}

.controls-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 40px);
}

.control-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.value-display {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.primary-btn,
.secondary-btn,
.accent-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.secondary-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.secondary-btn:hover {
    background: var(--border);
}

.accent-btn {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

.accent-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.accent-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: var(--bg-tertiary);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--accent);
}

.strategy-info {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
}

.strategy-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.strategy-row:last-child {
    border-bottom: none;
}

.strategy-row .value-display {
    font-weight: 600;
}

/* Game Panel */
.game-panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
}

.game-status-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.status-item {
    flex: 1;
    min-width: 140px;
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
}

.status-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.status-value {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--accent);
}

.status-value.player1 {
    color: var(--player1-color);
}

.status-value.player2 {
    color: var(--player2-color);
}

/* Game Board */
.game-board-container {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    min-height: 200px;
}

.game-board {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    padding: 10px;
}

.game-placeholder {
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-align: center;
    padding: 40px;
}

.stone {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #e2e8f0, #94a3b8, #64748b);
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3), inset -1px -1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    position: relative;
    cursor: default;
}

.stone.highlight {
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.6), 2px 2px 6px rgba(0, 0, 0, 0.3);
}

.stone.removed {
    background: radial-gradient(circle at 35% 35%, #334155, #1e293b, #0f172a);
    opacity: 0.2;
    transform: scale(0.7);
    box-shadow: none;
}

.stone.removing {
    animation: stoneRemove 0.5s ease-out forwards;
}

@keyframes stoneRemove {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
        background: radial-gradient(circle at 35% 35%, #06b6d4, #0891b2);
    }
    100% {
        transform: scale(0.5);
        opacity: 0.15;
        background: radial-gradient(circle at 35% 35%, #334155, #1e293b);
    }
}

.stone.ai-removing {
    animation: stoneAIRemove 0.5s ease-out forwards;
}

@keyframes stoneAIRemove {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
        background: radial-gradient(circle at 35% 35%, #d946ef, #a855f7);
    }
    100% {
        transform: scale(0.5);
        opacity: 0.15;
        background: radial-gradient(circle at 35% 35%, #334155, #1e293b);
    }
}

/* Move Controls */
.move-controls {
    margin-bottom: 20px;
}

.move-controls h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.move-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.move-btn {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 50px;
    text-align: center;
}

.move-btn:hover:not(:disabled) {
    border-color: var(--accent);
    background: rgba(6, 182, 212, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.move-btn.optimal {
    border-color: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.move-btn.optimal:hover:not(:disabled) {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* Move History */
.move-history {
    margin-bottom: 20px;
}

.move-history h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.history-item {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.history-item.p1 {
    background: rgba(6, 182, 212, 0.2);
    color: var(--player1-color);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.history-item.p2 {
    background: rgba(217, 70, 239, 0.2);
    color: var(--player2-color);
    border: 1px solid rgba(217, 70, 239, 0.3);
}

/* Game Message */
.game-message {
    text-align: center;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    display: none;
    animation: messageAppear 0.5s ease;
}

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

.game-message.win {
    display: block;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
    border: 2px solid var(--success);
    color: var(--success);
}

.game-message.lose {
    display: block;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(217, 70, 239, 0.2));
    border: 2px solid var(--danger);
    color: var(--danger);
}

.game-message.hint {
    display: block;
    background: rgba(245, 158, 11, 0.15);
    border: 2px solid var(--warning);
    color: var(--warning);
    font-size: 1rem;
}

/* Celebration */
.celebration {
    animation: celebrate 0.6s ease infinite alternate;
}

@keyframes celebrate {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 12px;
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tab-content {
    position: relative;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

.content-section {
    max-height: calc(100vh - 400px);
    overflow-y: auto;
    padding-right: 10px;
}

/* Education Cards */
.edu-card {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--accent);
    transition: border-color 0.3s;
}

.edu-card:hover {
    border-left-color: var(--accent-magenta);
}

.edu-card h3 {
    font-size: 1.15rem;
    margin-bottom: 10px;
    color: var(--accent);
}

.edu-card p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
}

.edu-card ul {
    margin-left: 20px;
    color: var(--text-secondary);
}

.edu-card li {
    margin-bottom: 6px;
    line-height: 1.6;
}

.equation {
    background: var(--bg-primary);
    padding: 16px 20px;
    border-radius: 8px;
    margin: 12px 0;
    border-left: 4px solid var(--accent-magenta);
}

.equation p {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 6px 0;
    font-weight: 600;
}

footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
    text-align: center;
    color: var(--text-secondary);
}

footer p {
    margin: 6px 0;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Responsive */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 280px 1fr;
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        position: relative;
        top: 0;
        max-height: none;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .game-status-bar {
        flex-direction: column;
    }

    .stone {
        width: 28px;
        height: 28px;
    }

    .move-btn {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .control-section {
        padding: 12px;
    }

    .game-panel {
        padding: 12px;
    }

    .stone {
        width: 24px;
        height: 24px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
