:root {
    --cell-size: 58px;
    --gap: 3px;
    --border: #d9d9d9;
    --text: #202124;
    --muted: #6b7280;
    --accent: #2563eb;
    --success: #16803c;
    --error: #b42318;
}

* {
    box-sizing: border-box;
}

.wrap {
    max-width: 1050px;
    margin: 0 auto;
    padding: 24px;
}

h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 22px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(320px, 560px) 1fr;
    gap: 24px;
    align-items: start;
}

.card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    /* Dwingt alles netjes binnen de kaart te blijven */
}

.controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

select,
button {
    font: inherit;
}

select {
    padding: 8px 10px;
    border: 1px solid #cfd4dc;
    border-radius: 8px;
    background: white;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
}

button.primary {
    background: var(--accent);
    color: white;
    font-weight: 700;
}

button.secondary {
    background: #eef1f5;
    color: #30343b;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Speelbord styling */
#board {
    display: grid;
    gap: 3px;
    width: 100%;
    max-width: 100%;
    /* Voorkomt uitbreken op mobiel */
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    box-sizing: border-box;
    /* Voorkom dat de tekst geselecteerd wordt of dat de pagina scrollt bij slepen op touch-schermen */
    touch-action: none;
}

.cell {
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 5px;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.08s, box-shadow 0.12s;
}

.cell:hover {
    transform: scale(0.97);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.65);
}

.cell.conflict {
    box-shadow: inset 0 0 0 3px #d92d20;
}

.swatch.eraser {
    background: #ffffff;
    border: 2px dashed #999;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.swatch.eraser.selected {
    border-color: #000;
    border-style: solid;
    box-shadow: 0 0 0 2px #fff, 0 0 0 5px #000;
}

/* Palet & Legende */
.palette-title {
    font-weight: 650;
    margin: 0 0 9px;
}

#palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.swatch {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    border: 3px solid transparent;
}

.swatch.selected {
    border-color: #000000;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 5px #000000;
}

.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 7px 12px;
    margin-top: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #4b5563;
}

.dot {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.hint {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
}

#status {
    margin-top: 15px;
    padding: 11px 13px;
    border-radius: 9px;
    display: none;
    line-height: 1.45;
}

#status.info {
    display: block;
    background: #eef4ff;
    color: #1e40af;
}

#status.success {
    display: block;
    background: #ecfdf3;
    color: #166534;
}

#status.error {
    display: block;
    background: #fef3f2;
    color: #991b1b;
}

.rules h2,
.solution h2 {
    font-size: 18px;
    margin: 0 0 12px;
}

.rules ul {
    margin: 0;
    padding-left: 21px;
    line-height: 1.65;
}

/* Ongekleurde vakjes */
.cell.empty,
.solution-cell.empty {
    background: #ffffff;
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 8px 8px;
}

/* Oplossingsbord styling (iOS WebKit-proof) */
#solutionBoard {
    display: grid;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    gap: 3px;
    margin: 0 auto;
    box-sizing: border-box;
    contain: layout inline-size;
    /* Dwingt iOS om de hoogte NIET aan te passen aan de inhoud */
}

#solutionText {
    display: block;
    margin-top: 16px !important;
    position: relative;
    z-index: 5;
    color: var(--text);
}

/* Garandeert dat cellen op iOS binnen de grid-kolommen blijven */
.solution-cell {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.25);
    border-radius: 4px;
    box-sizing: border-box;
    padding: 2px;
    position: relative;
    overflow: hidden;
    /* Snijdt eventueel uitstekende afbeeldingen/schaduwen op iOS af */
}

.solution-cell img,
.solution-cell svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Duidelijk geaccentueerde oplossingscel */
.solution-cell.logo {
    border: 3px solid rgba(0, 0, 0, 0.75);
    /* Gebruik een inwaartse schaduw (inset) i.p.v. een uitwaartse schaduw zodat niks uitsteekt */
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8),
        inset 0 0 8px rgba(0, 0, 0, 0.4);
    background-image: linear-gradient(rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.12));
}

.card.solution {
    display: flex;
    flex-direction: column;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

#logo-container {
    display: inline-flex;
    width: 40px;
    height: 40px;
    vertical-align: middle;
    margin-right: 8px;
}

#logo-container svg,
#logo-container img {
    width: 100%;
    height: 100%;
    display: block;
}

@media (max-width: 760px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .wrap {
        padding: 14px;
    }
}
