/* General Reset */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Base styles */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #f3e5f5, #e1bee7); /* puzzle theme */
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow-x: hidden;
}

/* Top navigation */
a {
    text-decoration: none;
    color: white;
    background-color: #6a1b9a;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: bold;
    margin-bottom: 15px;
    display: inline-block;
    transition: background 0.2s;
}
a:hover {
    background-color: #4a148c;
}

/* Wrapper */
#wrapper {
    width: 100%;
    max-width: 900px;
}

/* Header */
h1 {
    text-align: center;
    color: #6a1b9a;
    margin-bottom: 15px;
}

/* Container + card */
.container {
    max-width: 900px;
    margin: auto;
}
.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: center;
}

/* Level select */
#levelSelect {
    margin: 10px 0 20px;
}
select {
    font-size: 1rem;
    padding: 6px 12px;
    border-radius: 6px;
    border: 2px solid #6a1b9a;
}

/* Status */
#status {
    margin-bottom: 10px;
    min-height: 20px;
    font-weight: bold;
    color: #6a1b9a;
}

/* Grid container */
#grid-container {
    width: 100%;
    max-width: 100vw;
    aspect-ratio: var(--cols, 4) / var(--rows, 5);
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Actual grid layout */
#grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 5px;
}

/* Tile styles */
.tile {
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: min(4vmin, 4vw);
    border-radius: 6px;
    box-shadow: inset 0 0 3px #999;
    user-select: none;
}

.tile.x { background-color: #ff3215; color: white; }
.tile.a { background-color: #ffd504; color: black; }
.tile.b { background-color: #0441ae; color: white; }
.tile.c { background-color: #72cb3b; color: black; }
.tile.d { background-color: #ff3215; color: white; }

.tile.o,
.tile["0"] { background-color: grey; color: white; }
.tile["1"],
.tile.1 { background-color: white; color: black; }

.tile.selected {
    outline: 3px solid #333;
    z-index: 1;
}

/* Goal tile highlight */
.tile.goal {
    box-shadow: 0 0 10px 4px rgba(255, 50, 21, 0.6);
    position: relative;
}

.tile.goal::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border: 2px dashed #ff3215;
    border-radius: 4px;
    animation: pulse 1.5s infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Mobile tweaks */
@media (max-width: 600px) {
    .tile {
        font-size: min(6vmin, 6vw);
    }
    select {
        width: 100%;
    }
    .card {
        padding: 15px;
    }
}

