@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg-primary: #080c14;
    --bg-secondary: #0f172a;
    --card-bg: rgba(15, 23, 42, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    /* Neon accents */
    --neon-cyan: #06b6d4;
    --neon-cyan-glow: rgba(6, 182, 212, 0.45);
    --neon-magenta: #d946ef;
    --neon-magenta-glow: rgba(217, 70, 239, 0.45);
    --neon-emerald: #10b981;
    --neon-emerald-glow: rgba(16, 185, 129, 0.45);
    --neon-amber: #f59e0b;
    --neon-amber-glow: rgba(245, 158, 11, 0.45);
    --neon-rose: #f43f5e;
    --neon-rose-glow: rgba(244, 63, 94, 0.45);
    
    --transition-speed: 0.25s;
    --font-sans: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(217, 70, 239, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
}

/* HEADER STYLE */
header {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #38bdf8, #d946ef);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title h1::after {
    content: "AI SEARCH";
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1.5px;
    box-shadow: 0 0 8px var(--neon-cyan-glow);
}

.header-title p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.header-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: var(--transition-speed);
}

.header-links a:hover {
    color: var(--neon-cyan);
    border-color: rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.05);
}

/* MAIN CONTAINER Layout */
main {
    max-width: 1600px;
    margin: 30px auto;
    padding: 0 25px;
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 25px;
}

/* CARD / CONTAINER COMMON */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.12);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

/* SIDEBAR CONTROLS */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.control-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper, .input-wrapper {
    position: relative;
    width: 100%;
}

select, input[type="number"], input[type="range"] {
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-speed);
}

select:focus, input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
}

.range-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* TOGGLE BUTTON GROUP */
.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 8px;
}

.btn-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    transition: var(--transition-speed);
    text-align: center;
}

.btn-tab.active {
    background: var(--neon-cyan);
    color: #080c14;
    box-shadow: 0 0 12px var(--neon-cyan-glow);
}

.btn-tab:hover:not(.active) {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

/* SYSTEM ACTION BUTTONS */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--neon-cyan), #0284c7);
    color: #080c14;
    border: none;
    border-radius: 8px;
    padding: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 14px var(--neon-cyan-glow);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

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

/* GAMEPLAY DISPLAY GRID */
.workspace {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* TOP STATUS GRID */
.status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stats-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stats-card.cyan::before { background: var(--neon-cyan); }
.stats-card.magenta::before { background: var(--neon-magenta); }
.stats-card.emerald::before { background: var(--neon-emerald); }
.stats-card.amber::before { background: var(--neon-amber); }

.stats-card .stats-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.stats-card .stats-value {
    font-size: 1.4rem;
    font-weight: 800;
    font-family: var(--font-sans);
}

.stats-card .stats-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--font-mono);
}

/* BOARD & LOGS CONTAINER */
.board-logs-container {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 25px;
    align-items: start;
}

/* GAME BOARD */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.board {
    display: grid;
    grid-template-columns: repeat(7, 60px);
    grid-template-rows: repeat(7, 60px);
    gap: 8px;
    background: rgba(8, 12, 20, 0.9);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cell {
    width: 60px;
    height: 60px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(6, 182, 212, 0.2);
    transform: scale(1.05);
}

/* PLAYER CELL */
.cell.player {
    background: radial-gradient(circle, rgba(6, 182, 212, 0.3) 0%, rgba(6, 182, 212, 0.15) 100%);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan-glow);
    animation: pulse-cyan 2s infinite;
}

/* EXIT CELL */
.cell.exit {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, rgba(16, 185, 129, 0.15) 100%);
    border: 2px solid var(--neon-emerald);
    box-shadow: 0 0 15px var(--neon-emerald-glow);
}

/* OBSTACLE CELL */
.cell.obstacle {
    background: radial-gradient(circle, rgba(217, 70, 239, 0.25) 0%, rgba(15, 23, 42, 0.9) 100%);
    border: 1.5px solid var(--neon-magenta);
    box-shadow: 0 0 10px var(--neon-magenta-glow);
}

/* ANIMATED NEW OBSTACLE */
.cell.obstacle.newly-placed {
    animation: bounce-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ACTIVE AI EVALUATION TARGET */
.cell.eval-target {
    border: 2px dashed var(--neon-amber);
    box-shadow: inset 0 0 10px var(--neon-amber-glow);
    animation: flash-amber 0.6s infinite alternate;
}

/* LEGEND & SHORTCUTS */
.board-legend {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 11px;
}

/* LOGS BOX */
.terminal-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 480px;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    display: inline-block;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.terminal-dot::after {
    content: "";
    margin-left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #eab308;
    display: inline-block;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.6);
}

.terminal-dot::before {
    content: "";
    margin-left: 28px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.terminal-body {
    flex-grow: 1;
    background: rgba(5, 8, 16, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    color: #10b981;
    overflow-y: auto;
    height: 380px;
    margin-top: 12px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.terminal-log {
    margin-bottom: 6px;
    border-left: 2px solid transparent;
    padding-left: 6px;
}

.terminal-log.system { border-color: var(--neon-cyan); color: #38bdf8; }
.terminal-log.ai { border-color: var(--neon-magenta); color: #f472b6; }
.terminal-log.player { border-color: var(--neon-emerald); color: #34d399; }
.terminal-log.warn { border-color: var(--neon-amber); color: #fbbf24; }
.terminal-log.pruned { border-color: var(--neon-rose); color: #fb7185; }

/* GAME TREE VISUALIZATION PANEL */
.tree-panel {
    display: flex;
    flex-direction: column;
}

.tree-container-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    background: rgba(5, 8, 16, 0.65);
    border-radius: 12px;
    overflow: hidden;
    height: 500px;
    width: 100%;
}

.tree-canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.tree-canvas:active {
    cursor: grabbing;
}

.tree-controls {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.tree-btn {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    transition: var(--transition-speed);
}

.tree-btn:hover {
    background: var(--neon-cyan);
    color: #080c14;
    box-shadow: 0 0 10px var(--neon-cyan-glow);
}

/* SVG Tree Elements */
.tree-edge {
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.3s ease, stroke-dasharray 0.3s ease;
}

.tree-edge.pruned-edge {
    stroke: rgba(244, 63, 94, 0.3);
    stroke-dasharray: 4;
}

.tree-edge.active-edge {
    stroke: var(--neon-cyan);
    stroke-width: 3.5;
}

.tree-node-g {
    transition: transform 0.3s ease;
    cursor: pointer;
}

.tree-node-circle {
    stroke-width: 2;
    transition: fill 0.3s, stroke 0.3s, r 0.3s;
}

.tree-node-g.max .tree-node-circle {
    fill: #0c4a6e;
    stroke: var(--neon-cyan);
}

.tree-node-g.min .tree-node-circle {
    fill: #4c1d95;
    stroke: var(--neon-magenta);
}

.tree-node-g.pruned-node .tree-node-circle {
    fill: #4c0519 !important;
    stroke: var(--neon-rose) !important;
    opacity: 0.65;
}

.tree-node-g.active-eval .tree-node-circle {
    fill: #78350f !important;
    stroke: var(--neon-amber) !important;
    r: 16;
}

.tree-node-g.best-path .tree-node-circle {
    stroke: var(--neon-emerald) !important;
    stroke-width: 4px;
}

.tree-node-text {
    font-family: var(--font-sans);
    font-weight: bold;
    font-size: 11px;
    fill: var(--text-main);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.tree-node-score {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--neon-amber);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* Tooltip on SVG hover */
.tree-tooltip {
    position: fixed;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--neon-cyan);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 1000;
    line-height: 1.4;
    font-family: var(--font-mono);
    display: none;
}

/* PERFORMANCE COMPARISON BENCHMARK TABLE */
.benchmark-panel {
    display: flex;
    flex-direction: column;
}

.benchmark-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.4);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    text-align: left;
}

th {
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.savings-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--neon-emerald);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* FOOTER */
footer {
    border-top: 1px solid var(--border-color);
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 50px;
}

footer p {
    margin-bottom: 8px;
}

footer a {
    color: var(--neon-cyan);
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

/* KEYFRAMES & PULSING ANIMATIONS */
@keyframes pulse-cyan {
    0% {
        box-shadow: 0 0 10px rgba(6, 182, 212, 0.45);
        border-color: rgba(6, 182, 212, 0.8);
    }
    50% {
        box-shadow: 0 0 20px rgba(6, 182, 212, 0.8);
        border-color: rgba(6, 182, 212, 1);
    }
    100% {
        box-shadow: 0 0 10px rgba(6, 182, 212, 0.45);
        border-color: rgba(6, 182, 212, 0.8);
    }
}

@keyframes flash-amber {
    0% {
        border-color: rgba(245, 158, 11, 0.2);
        background: rgba(245, 158, 11, 0.05);
    }
    100% {
        border-color: rgba(245, 158, 11, 1);
        background: rgba(245, 158, 11, 0.25);
    }
}

@keyframes bounce-in {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* RESPONSIVE DESIGN */
@media (max-width: 1200px) {
    main {
        grid-template-columns: 1fr;
    }
    .board-logs-container {
        grid-template-columns: 1fr;
    }
    .board-wrapper {
        width: 100%;
    }
    .board {
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 15px 20px;
    }
    .status-grid {
        grid-template-columns: 1fr 1fr;
    }
    .board {
        grid-template-columns: repeat(7, 45px);
        grid-template-rows: repeat(7, 45px);
        gap: 6px;
    }
    .cell {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .status-grid {
        grid-template-columns: 1fr;
    }
    .board {
        grid-template-columns: repeat(7, 36px);
        grid-template-rows: repeat(7, 36px);
        gap: 4px;
        padding: 6px;
    }
    .cell {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}