/* ULF Sudoku — vNext clean stylesheet */

/* ---------- Theme Tokens ---------- */
:root {
    --bg: #ffffff;
    --bg-elev: #f6f7fb;
    --text: #111827;
    --muted: #6b7280;
    --accent: #3a86ff;

    --line: #e0e0e0; /* thin grid lines */
    --line-strong: #999; /* 3×3 separators (used with box-* classes) */
    --box-outline: #ffffff; /* outer grid border */

    --cell-bg: #ffffff;
    --cell-text: #111827;
    --fixed-text: #111827;
    --user-text: #6b7280;

    --midnight: #1b1f3b; /* legacy token used in a few places */
    --success: #3fc380;
    --error: #e63946;
    --ad-bg: #eaeefa;
}

html[data-theme="dark"] {
    --bg: #0f1326;
    --bg-elev: #131831;
    --text: #f9fafb;
    --muted: #9ca3af;
    --accent: #3a86ff;

    --line: #2a2f4e;
    --line-strong: #bfc6ff;
    --box-outline: #ffffff;

    --cell-bg: #0f1326;
    --cell-text: #f9fafb;
    --fixed-text: #ffffff;
    --user-text: #b0b0b0;

    --ad-bg: #0d1122;
}

/* Premium themes */
:root[data-theme-name="forest"] {
    --accent: #2bb673;
    --bg: #0e1512;
    --bg-elev: #11201b;
    --line: #1c2b25;
    --line-strong: #2f5a49;
    --box-outline: #2bb673;
    --cell-bg: #0f1915;
    --cell-text: #e6ffef;
    --fixed-text: #e6ffef;
    --user-text: #a7d8c0;
}

:root[data-theme-name="sandstone"] {
    --accent: #d4a84f;
    --bg: #f6efe5;
    --bg-elev: #f2e7d8;
    --line: #e2d3bd;
    --line-strong: #9a8b73;
    --box-outline: #caa66b;
    --cell-bg: #fffaf3;
    --text: #2b1e0f;
    --cell-text: #2b1e0f;
    --fixed-text: #2b1e0f;
    --user-text: #5a4630;
}

/* NEON: true neon look */
:root[data-theme-name="neon"] {
    --bg: #000000;
    --bg-elev: #07080b;
    --cell-bg: #07080b;
    --text: #00f0ff;
    --cell-text: #00f0ff;
    --muted: #8fdfea;
    --accent: #00f0ff;
    --accent-2: #ff3af2; /* hot pink */
    --line: rgba(255, 58, 242, 0.55);
    --line-strong: #ff3af2;
    --box-outline: #ffe900; /* popping yellow */
    --success: #22ffd2;
    --error: #ff4d6d;
}

/* ---------- Reset / Page Layout ---------- */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        Inter,
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: grid;
    place-items: center;
}

#app {
    width: min(100%, 900px);
    padding: 16px;
    display: grid;
    gap: 16px;
}

/* ---------- Topbar & Meta ---------- */
.topbar.minimal {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
}
.topbar .top-left {
    height: 28px;
}
.topbar .top-right {
    display: flex;
    gap: 8px;
    justify-self: end;
}
.topbar .top-center {
    justify-self: center;
}

.icon-btn {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 12px;
    cursor: pointer;
    transition:
        transform 0.05s ease,
        background 0.2s ease;
}
.icon-btn.small {
    padding: 6px 10px;
}
.icon-btn:hover {
    transform: translateY(-1px);
}

.games-done {
    font-weight: 700;
    font-size: 20px;
    line-height: 1;
    letter-spacing: 0.2px;
    opacity: 0.95;
}

.meta-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 12px 6px;
    color: var(--muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.meta-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.meta-label {
    font-size: 11px;
    opacity: 0.8;
}
.meta-value {
    font-size: 13px;
    color: var(--text);
}
.pill.tiny {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    margin-left: 6px;
}

/* ---------- Game Grid ---------- */
.game {
    display: grid;
    place-items: center;
}

.grid {
    width: min(88vw, 520px); /* <- force size */
    max-width: 100%;
    aspect-ratio: 1 / 1;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    background: var(--bg);
    border: 2px solid var(--box-outline);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    border-radius: 0; /* square corners */
    overflow: hidden;
    position: relative;
}

/* NEON outer glow */
:root[data-theme-name="neon"] .grid {
    box-shadow:
        0 0 12px rgba(255, 233, 0, 0.75),
        0 0 32px rgba(255, 58, 242, 0.35),
        0 10px 30px rgba(0, 0, 0, 0.7);
}

/* Cells */
.cell {
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: clamp(16px, 3.2vw, 24px);
    cursor: pointer;
    user-select: none;
    background: var(--cell-bg);
    color: var(--cell-text);
    position: relative;
    transition:
        background 0.15s ease,
        color 0.15s ease,
        transform 0.1s ease;
}

/* 3×3 separators (from JS classes; avoids nth-child clashes) */
.cell.box-top {
    border-top: 2px solid var(--line-strong);
}
.cell.box-left {
    border-left: 2px solid var(--line-strong);
}
.cell.box-bottom {
    border-bottom: 2px solid var(--line-strong);
}
.cell.box-right {
    border-right: 2px solid var(--line-strong);
}

/* Given vs user numbers */
.cell.fixed {
    color: var(--fixed-text);
}
.cell.user {
    color: var(--user-text);
}
.cell.user::after {
    content: "";
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.35;
}

/* Active/same-number styles: SHADED, no outline */
.cell.active {
    background: rgba(255, 255, 255, 0.06); /* tweak per theme as needed */
    box-shadow: none;
}
.cell.same-number:not(.active) {
    background: rgba(255, 255, 255, 0.035);
}

/* Conflicts & feedback */
.cell.wrong {
    outline: 2px solid var(--error);
    box-shadow: inset 0 0 0 3px rgba(230, 57, 70, 0.25);
    animation: shake 0.15s ease;
}
@keyframes shake {
    0% {
        transform: translateX(0);
    }
    33% {
        transform: translateX(-1px);
    }
    66% {
        transform: translateX(1px);
    }
    100% {
        transform: translateX(0);
    }
}
.cell.group-complete {
    box-shadow: inset 0 0 0 3px rgba(63, 195, 128, 0.35);
    background: rgba(63, 195, 128, 0.08);
}
.cell.conflict {
    text-decoration: underline;
    text-decoration-color: var(--error);
    text-decoration-thickness: 2px;
}

/* NEON variants */
:root[data-theme-name="neon"] .cell {
    text-shadow:
        0 0 4px rgba(0, 240, 255, 0.65),
        0 0 10px rgba(0, 240, 255, 0.35);
}
:root[data-theme-name="neon"] .cell.active {
    background: rgba(255, 58, 242, 0.12);
}
:root[data-theme-name="neon"] .cell.same-number:not(.active) {
    background: rgba(0, 240, 255, 0.12);
}

/* Notes (single definition) */
.notes {
    position: absolute;
    inset: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 1px;
    pointer-events: none;
    opacity: 0.55;
    z-index: 0;
}
.note {
    font-size: 10px;
    line-height: 1;
    color: var(--muted);
    display: grid;
    place-items: center;
    opacity: 0.8;
}

/* Tight inner padding so digits feel crisp */
.grid .cell {
    padding: 0.08rem;
}

/* ---------- Controls / Keypad ---------- */
.controls {
    display: grid;
    gap: 12px;
}

.actions {
    display: grid;
    grid-auto-flow: column;
    gap: 8px;
    justify-content: start;
}

.numbers {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 8px 16px;
}
.numbers button {
    flex: 1 1 auto;
    border: none;
    background: none;
    border-radius: 0;
    padding: 10px 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text);
    opacity: 0.95;
    cursor: pointer;
    transition:
        transform 0.05s ease,
        opacity 0.15s ease;
}
.numbers button:active {
    transform: scale(0.98);
}
.numbers button:disabled {
    opacity: 0.25;
    cursor: default;
}
.numbers button.active {
    text-decoration: underline;
}

/* ---------- Ad Banner ---------- */
.ad-banner {
    min-height: 50px;
    height: 50px;
    border-radius: 12px;
    background: var(--ad-bg);
    border: 1px dashed var(--line);
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
    position: relative;
}
#adBanner .adsbygoogle {
    display: block;
    width: 100%;
    height: 50px;
}

/* ---------- Menu / Sheet ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: grid;
    align-content: end;
    transition: opacity 0.2s ease;
}
.overlay.hidden {
    display: none;
}

.sheet {
    background: var(--bg);
    color: var(--text);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border: 1px solid var(--line);
    padding: 16px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
}
.drag-handle {
    width: 48px;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
    margin: 0 auto 12px;
    opacity: 0.7;
}

.sheet-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.select,
.primary,
.secondary,
.ghost {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
}
.primary {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}
.secondary:hover,
.ghost:hover,
.primary:hover {
    opacity: 0.95;
}
.ghost {
    background: transparent;
}

.theme-preview {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}
.chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-elev);
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
}
.locked {
    opacity: 0.6;
}
.premium-cta {
    margin-top: 8px;
}
.chip.forest {
    background: #0f1915;
    color: #e6ffef;
    border-color: #1c2b25;
}
.chip.sandstone {
    background: #f2e7d8;
    color: #3d2e1e;
    border-color: #e2d3bd;
}
.chip.neon {
    background: #000;
    color: #00f0ff;
    border-color: #ff3af2;
}

/* ---------- Modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.45);
}
.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg);
    color: var(--text);
    border-radius: 16px;
    border: 1px solid var(--line);
    padding: 16px;
    width: min(92vw, 480px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.modal-content.center {
    text-align: center;
}
.modal-actions {
    display: grid;
    grid-auto-flow: column;
    gap: 8px;
    margin-top: 8px;
}
.tiny-note {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}
.congrats-title {
    font-weight: 800;
    letter-spacing: 0.5px;
    font-size: 24px;
}

/* ---------- Auth ---------- */
.auth-buttons {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}
.oauth {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    cursor: pointer;
}
.oauth.apple {
    background: #000;
    color: #fff;
}
.oauth.google {
    background: #fff;
    color: #111;
}
.email-auth {
    display: flex;
    gap: 8px;
}
.email-auth input {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--text);
}

/* ---------- Completion / Zen ---------- */
.board-complete {
    box-shadow: inset 0 0 0 3px rgba(63, 195, 128, 0.35);
    animation: pulse 0.8s ease;
}
@keyframes pulse {
    from {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
    to {
        transform: scale(1);
    }
}
html.zen .ad-banner {
    display: none !important;
}
html.zen .timer {
    opacity: 0.4;
}

/* ---------- PWA install buttons ---------- */
#installBtn[hidden],
#installMenuBtn[hidden] {
    display: none !important;
}

/* ---------- Content block (How to play) ---------- */
.content-wrap {
    max-width: 920px;
    margin: 24px auto 64px;
    padding: 0 16px;
}
.content h1,
.content h2,
.content h3 {
    margin: 0 0 12px;
    line-height: 1.25;
}
.content p,
.content li,
.content dd {
    line-height: 1.6;
}
.content h1 {
    font-size: 1.6rem;
}
.content h2 {
    font-size: 1.25rem;
    margin-top: 20px;
}
.content h3 {
    font-size: 1.05rem;
    margin-top: 16px;
}
.content ol,
.content ul {
    margin: 10px 0 16px 20px;
}
.content .features {
    columns: 2;
    gap: 24px;
}
@media (max-width: 640px) {
    .content .features {
        columns: 1;
    }
}
.faq {
    margin: 12px 0 0;
}
.faq dt {
    font-weight: 700;
    margin-top: 12px;
}
.faq dd {
    margin: 4px 0 10px 0;
}
.notice {
    opacity: 0.85;
    margin-top: 16px;
}

/* ---------- Palette popover ---------- */
.popover {
    position: fixed;
    right: 10px;
    top: 60px;
    z-index: 10000;
    width: min(92vw, 360px);
    background: rgba(25, 28, 45, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.popover.hidden {
    display: none;
}
.popover-title {
    font-size: 13px;
    opacity: 0.8;
    margin: 2px 4px 8px;
}
.popover-sub {
    font-size: 11px;
    opacity: 0.6;
    margin: 10px 4px 6px;
}
.chip-row.tight {
    gap: 6px;
    flex-wrap: wrap;
}
