* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #07111f;
    --surface: #0f1c2e;
    --surface-2: #17263a;
    --text: #f7f9fc;
    --muted: #9eacc0;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --line: #314158;
    --line-strong: #8ca0b8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --cell-size: min(9.4vw, 52px);
}

body {
    min-height: 100vh;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent 34rem),
        var(--bg);
    color: var(--text);
    padding: 22px 14px;
}

a { color: inherit; }

.app-shell {
    width: min(100%, 760px);
    margin: 0 auto;
}

.brand-header,
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand-header { margin-bottom: 18px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    color: white;
    font-size: 1.25rem;
    font-weight: 900;
}

.brand strong,
.brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }

.game-badge,
.eyebrow,
.difficulty-label {
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.game-badge {
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.35);
    background: rgba(56, 189, 248, 0.08);
    border-radius: 999px;
    padding: 7px 12px;
}

.game-card {
    background: rgba(15, 28, 46, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 22px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
    padding: 28px;
}

.title-block { text-align: center; }
.eyebrow { color: var(--accent); margin-bottom: 6px; }
h1 { font-size: clamp(2rem, 6vw, 2.8rem); }
.title-block > p:last-child {
    max-width: 560px;
    margin: 8px auto 0;
    color: var(--muted);
    line-height: 1.5;
}

.stats-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 22px 0;
}

.stat {
    padding: 12px 8px;
    text-align: center;
    background: var(--surface-2);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
}
.stat span { display: block; color: var(--muted); font-size: 0.78rem; }
.stat strong { display: block; margin-top: 3px; font-size: 1.1rem; }
#timer { color: var(--accent); }

.difficulty-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.difficulty-label { color: var(--muted); }
.difficulty-controls,
.controls { display: flex; gap: 8px; flex-wrap: wrap; }

.game-board {
    position: relative;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: min(100%, 486px);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border: 3px solid var(--line-strong);
    background: #f8fafc;
    border-radius: 8px;
    overflow: hidden;
}

.game-board.paused::after {
    content: "Partida pausada";
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    background: rgba(15, 28, 46, 0.96);
    color: var(--text);
    font-size: clamp(1.4rem, 5vw, 2.2rem);
    font-weight: 900;
    text-align: center;
}

.game-board.locked {
    pointer-events: none;
}

.cell {
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid #cbd5e1;
    border-bottom: 1px solid #cbd5e1;
    background: #fff;
    color: #172033;
    font-size: clamp(1rem, 3.4vw, 1.35rem);
    font-weight: 800;
}
.cell:nth-child(3n) { border-right: 3px solid #64748b; }
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) { border-bottom: 3px solid #64748b; }
.cell:nth-child(n + 73) { border-bottom: 0; }
.cell.fixed { background: #e9eef5; color: #253247; }
.cell.error { background: #fee2e2; }

.cell input {
    width: 100%;
    height: 100%;
    border: 0;
    text-align: center;
    background: transparent;
    color: #0369a1;
    font: inherit;
    caret-color: transparent;
}
.cell input:focus {
    outline: 3px solid rgba(14, 165, 233, 0.55);
    outline-offset: -3px;
    background: #e0f2fe;
}
.cell.error input { color: #b91c1c; }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 15px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:focus-visible { outline: 3px solid rgba(56, 189, 248, 0.38); outline-offset: 3px; }
.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
    filter: none;
}
.btn-difficulty { background: #223249; color: #dce6f2; }
.btn-difficulty.active { background: var(--accent-strong); color: white; }
.btn-primary { background: var(--accent-strong); color: white; }
.btn-secondary { background: #334155; color: white; }
.btn-new { background: #2563eb; color: white; }

.controls { justify-content: center; margin-top: 20px; }
.message {
    min-height: 30px;
    text-align: center;
    margin-top: 16px;
    font-weight: 800;
    line-height: 1.45;
}
.message.success { color: #4ade80; }
.message.error { color: #f87171; }
.message.info { color: var(--accent); }

footer {
    color: var(--muted);
    font-size: 0.86rem;
    padding: 18px 4px 0;
}
footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 560px) {
    body { padding: 12px 8px; }
    .game-card { padding: 19px 10px; border-radius: 17px; }
    .brand-header { padding: 0 5px; }
    .difficulty-row { justify-content: center; }
    .difficulty-label { width: 100%; text-align: center; }
    .difficulty-controls { justify-content: center; width: 100%; }
    .controls { gap: 6px; }
    .controls .btn { flex: 1 1 30%; padding: 10px 8px; font-size: 0.85rem; }
    footer { flex-direction: column; gap: 5px; text-align: center; }
}
