* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: #eaf4fb;
    color: #1d2b36;
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 48px;
    text-align: center;
}

h1 { margin-bottom: 8px; }

.ayuda { color: #475966; max-width: 640px; margin: 0 auto 16px; }

.mensaje {
    min-height: 44px;
    padding: 10px 14px;
    margin: 12px auto;
    max-width: 640px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #c8d8e4;
}
.mensaje.error { background: #fdecea; border-color: #e5a29b; }
.mensaje.exito { background: #e8f6ec; border-color: #8fcba0; }

#escena {
    display: grid;
    grid-template-columns: 1fr 1.1fr 1fr;
    gap: 8px;
    align-items: stretch;
    margin: 20px 0;
}

.orilla {
    background: #d9c79a;
    border-radius: 10px;
    padding: 12px;
    min-height: 220px;
}
.orilla h2 { font-size: 1rem; margin: 0 0 8px; }

.rio {
    background: #5aa9e6;
    border-radius: 10px;
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
}

.barca {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: left 0.8s ease;
    left: 6%;
    background: #8b5a2b;
    color: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 110px;
}
.barca.derecha { left: calc(94% - 110px); }

.fichas {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    min-height: 48px;
    margin-top: 6px;
}

.ficha {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid transparent;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: transform 0.15s, border-color 0.15s;
}
.ficha:hover { transform: scale(1.1); }
.ficha.misionero { background: #fff6d6; }
.ficha.canibal { background: #f3b9b0; }
.ficha.seleccionada { border-color: #1d2b36; }

.controles {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
}

button {
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secundario { background: #64748b; }
button.resolver { background: #16a34a; }

.contador, .estado { margin: 10px 0 0; }
code { background: #fff; padding: 2px 6px; border-radius: 4px; }

@media (max-width: 640px) {
    #escena { grid-template-columns: 1fr; }
    .rio { min-height: 120px; }
}