:root {
    --background: #0d0f14;
    --panel: #171a21;
    --panel-hover: #1e222c;
    --border: #303541;
    --text: #f3f4f6;
    --muted: #9ba3af;
    --accent: #5aa7ff;
    --accent-soft: #24344b;
    --grid-line: #262b36;
    --grid-cell: #12151c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(
            circle at top,
            #171c27 0,
            var(--background) 500px
        );
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.site-header {
    padding: 28px clamp(20px, 5vw, 70px);
    border-bottom: 1px solid var(--border);
    background: rgba(13, 15, 20, 0.85);
}

.site-title {
    font-size: 1.7rem;
    font-weight: bold;
}

.site-subtitle {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.9rem;
}

.back-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
}

.back-link:hover {
    color: var(--accent);
}

main {
    width: min(560px, calc(100% - 40px));
    margin: 0 auto;
    padding: 40px 0 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.game-controls {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

.primary-button {
    padding: 11px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.primary-button:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.difficulty-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
}

.difficulty-button {
    padding: 7px 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.difficulty-button:hover {
    color: var(--text);
}

.difficulty-button.active {
    background: var(--accent-soft, #24344b);
    color: var(--accent);
    border-color: var(--accent);
}

.difficulty-impossible.active {
    background: rgba(230, 72, 79, 0.15);
    color: #e6484f;
    border-color: #e6484f;
}

.move-counter {
    color: var(--muted);
    font-size: 0.95rem;
}

.move-counter span {
    color: var(--text);
    font-weight: bold;
}

.seed-bar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    font-size: 0.85rem;
    color: var(--muted);
}

.seed-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.seed-display span {
    color: var(--text);
    font-family: "Consolas", monospace;
    letter-spacing: 0.03em;
}

.seed-form {
    display: flex;
    gap: 8px;
}

.seed-form input {
    width: 150px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font-size: 0.85rem;
}

.seed-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.text-button {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.text-button:hover {
    background: var(--panel-hover);
    border-color: var(--accent);
}

.text-button.copied {
    background: rgba(90, 209, 167, 0.15);
    border-color: #5ad1a7;
    color: #5ad1a7;
}

.board-wrap {
    position: relative;
    width: 100%;
}

.board {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background:
        repeating-linear-gradient(
            to right,
            var(--grid-cell) 0,
            var(--grid-cell) calc(100% / 6 - 1px),
            var(--grid-line) calc(100% / 6 - 1px),
            var(--grid-line) calc(100% / 6)
        ),
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(100% / 6 - 1px),
            var(--grid-line) calc(100% / 6 - 1px),
            var(--grid-line) calc(100% / 6)
        );
    border: 3px solid var(--border);
    border-radius: 10px;
    overflow: visible;
    touch-action: none;
}

.parking-spot {
    position: absolute;
    top: calc(100% / 6 * 2 + 2px);
    right: 2px;
    height: calc(100% / 6 - 4px);
    width: calc(100% / 6 * 2 - 4px);
    border: 2px dashed rgba(230, 72, 79, 0.55);
    border-radius: 8px;
    background: rgba(230, 72, 79, 0.1);
    pointer-events: none;
}

.vehicle {
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transform-origin: center;
    transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(var(--vscale, 1));
}

.vehicle.dragging {
    cursor: grabbing;
    z-index: 5;
}

.vehicle.selected {
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25), 0 0 0 2px var(--accent);
}

.vehicle.red {
    background: #e6484f;
}

.vehicle.animating {
    transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.4, 1), opacity 0.28s ease;
}

.vehicle.entering {
    --vscale: 0;
    opacity: 0;
}

.vehicle.leaving {
    --vscale: 0;
    opacity: 0;
    pointer-events: none;
}

.instructions {
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    max-width: 420px;
    line-height: 1.5;
}

.win-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 15, 20, 0.75);
    border-radius: 10px;
}

.win-overlay.hidden {
    display: none;
}

.win-card {
    text-align: center;
    padding: 30px 36px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
}

.win-card h2 {
    margin: 0 0 8px;
}

.win-card p {
    margin: 0 0 18px;
    color: var(--muted);
}

footer {
    padding: 30px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    text-align: center;
    font-size: 0.8rem;
}
