:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --border-color: #334155;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;

    --green-color: #10b981;
    --red-color: #ef4444;
    --gray-color: #64748b;
    --cell-bg: rgba(255, 255, 255, 0.05);
    --cell-hover: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 2rem;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 800px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

header h1 {
    margin-top: 0;
    font-size: 2rem;
    text-align: center;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.controls,
.action-panel {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.action-panel {
    margin-bottom: 0px;
}

label {
    font-weight: 600;
}

input[type="number"] {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem;
    border-radius: 8px;
    width: 70px;
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s;
    text-align: center;
}

button {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.6rem 1.4rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

button.action-btn {
    background: #8b5cf6;
}

button:hover {
    background: var(--accent-hover);
}

button.action-btn:hover {
    background: #7c3aed;
}

button:active {
    transform: scale(0.95);
}

.grid-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.grid-container {
    display: grid;
    gap: 2px;
    background: var(--border-color);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.grid-cell {
    background-color: var(--cell-bg);
    aspect-ratio: 1/1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s, transform 0.1s;
    min-width: 60px;
    position: relative;
}

.grid-cell:hover {
    background-color: var(--cell-hover);
}

.grid-cell:active {
    transform: scale(0.95);
}

/* Cell Content */
.cell-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    position: absolute;
    top: 4px;
    left: 4px;
}

.cell-value {
    font-size: 0.95rem;
    font-weight: bold;
    color: #e2e8f0;
    z-index: 2;
}

.cell-policy {
    font-size: 1.8rem;
    font-weight: bold;
    color: #fcd34d;
    z-index: 2;
}

/* Cell States */
.grid-cell.start {
    background-color: var(--green-color) !important;
    color: white;
}

.grid-cell.end {
    background-color: var(--red-color) !important;
    color: white;
}

.grid-cell.obstacle {
    background-color: var(--gray-color) !important;
    color: white;
}

.grid-cell.path {
    background-color: rgba(16, 185, 129, 0.6) !important;
}

.status-panel {
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
    min-height: 1.5rem;
    margin-top: 10px;
}

.status-indicator {
    transition: color 0.3s ease;
}