:root {
    --primary: #3498db; --success: #2ecc71; --danger: #e74c3c;
    --warning: #f39c12; --dark: #2c3e50; --light: #ecf0f1; --bg: #f5f6fa;
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); margin: 0; display: flex; justify-content: center; }

.container { max-width: 1100px; width: 100%; padding: 20px; display: flex; flex-direction: column; align-items: center; }

.header { text-align: center; margin-bottom: 20px; }
.header h1 { margin: 0; color: var(--dark); }

.controls {
    background: white; padding: 20px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08); width: 100%; margin-bottom: 30px;
}

.input-group { display: flex; gap: 30px; margin-bottom: 15px; justify-content: center; }
.control-item { display: flex; flex-direction: column; gap: 5px; }

.optimization-settings {
    display: flex; gap: 20px; justify-content: center; margin-bottom: 20px;
    padding: 12px; background: #f8f9fa; border-radius: 8px; font-size: 13px;
}
.optimization-settings label { 
    cursor: help; display: flex; align-items: center; gap: 5px; 
    border-bottom: 1px dotted #95a5a6; padding-bottom: 2px;
}

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

button { padding: 12px 20px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.2s; text-transform: uppercase; font-size: 12px; }
#startBtn { background: var(--success); color: white; }
#pauseBtn { background: var(--warning); color: white; }
.reset-btn { background: #95a5a6; color: white; }
button:hover:not(:disabled) { opacity: 0.9; transform: translateY(-2px); }
button:disabled { background: #dcdde1; cursor: not-allowed; }

.status-box { text-align: center; margin-top: 15px; font-weight: bold; color: var(--primary); }

.main-content { display: flex; gap: 30px; width: 100%; justify-content: center; align-items: flex-start; }

.board-container { display: grid; grid-template-areas: ". col" "row board"; background: white; padding: 15px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.board { grid-area: board; display: grid; gap: 4px; background: #34495e; padding: 8px; border-radius: 4px; position: relative; }

.cell { width: 50px; height: 50px; background: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold; position: relative; z-index: 1; border-radius: 3px; cursor: pointer; }
.cell.black { background: #d1d8e0; }
.cell.start { background: var(--success) !important; color: white; }
.cell.end { background: var(--primary) !important; color: white; }
.cell.visited { background: #9b59b6; color: white; }
.cell.current { background: var(--danger) !important; color: white; z-index: 10; box-shadow: 0 0 15px rgba(231, 76, 60, 0.5); }

.coords { display: flex; font-family: monospace; font-weight: bold; color: #7f8c8d; font-size: 14px; }
.row-coords { grid-area: row; flex-direction: column; justify-content: space-around; padding-right: 10px; }
.col-coords { grid-area: col; justify-content: space-around; padding-bottom: 10px; }

.log-container { width: 350px; background: white; padding: 20px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.event-log { height: 400px; background: #2c3e50; color: #ecf0f1; padding: 12px; font-family: 'Courier New', monospace; font-size: 11px; border-radius: 6px; overflow-y: auto; }
.log-entry { padding: 3px 0; border-bottom: 1px solid #3e5871; }

.arrows-layer { position: absolute; top: 8px; left: 8px; pointer-events: none; z-index: 5; }
.possible-move-arrow { stroke: var(--warning); stroke-width: 2; opacity: 0.5; marker-end: url(#arrowhead-possible); }
.actual-move-arrow { stroke: var(--danger); stroke-width: 4; marker-end: url(#arrowhead-actual); stroke-dasharray: 6,3; animation: dash 1s linear infinite; }

@keyframes dash { to { stroke-dashoffset: -9; } }
@media (max-width: 900px) { .main-content { flex-direction: column; align-items: center; } .log-container { width: 100%; } }
.stats-panel {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 10px;
    font-family: monospace;
    font-size: 14px;
    color: #34495e;
    background: #dfe6e9;
    padding: 8px;
    border-radius: 5px;
}
.stats-panel span { font-weight: bold; color: var(--danger); }
