/* ══════════════════════════════════════════════
   Simply Sudoku — Shared Styles
   ══════════════════════════════════════════════ */

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

:root {
    --bg:      #f5f5f9;
    --bg2:     #ffffff;
    --bg3:     #ebebf0;
    --border:  #dcdce4;
    --txt:     #0d0d14;
    --muted:   #6b6b80;
    --btn:     #1a1a2e;
    --btn-txt: #ffffff;
    --blue:    #2563eb;
    --sel:     #dbeafe;
    --hi:      #eaeaf2;
    --given:   #e8e8f0;
    --err-bg:  #fef2f2;
    --err:     #dc2626;
    --ok-bg:   #f0fdf4;
    --ok:      #16a34a;
    --warn-bg: #fffbeb;
    --warn:    #d97706;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    touch-action: manipulation;
    color: var(--txt);
    -webkit-font-smoothing: antialiased;
}

/* ── Header ─────────────────────────────────────── */
.header {
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 100%);
    border-bottom: 1px solid rgba(255,255,255,.06);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 10px;
}

.header h1 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.3px;
    flex-shrink: 0;
    color: #ffffff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    background: rgba(255,255,255,.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px;
    transition: background .15s;
}

.user-chip:hover { background: rgba(255,255,255,.18); }

.user-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    color: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.sign-in-link {
    padding: 6px 13px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    background: rgba(255,255,255,.1);
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s;
}

.sign-in-link:hover { background: rgba(255,255,255,.18); }

.badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .8px;
    background: #ffffff;
    color: #1a1a2e;
    padding: 3px 9px;
    border-radius: 20px;
    flex-shrink: 0;
}

/* ── Dark mode vars ──────────────────────────────── */
[data-theme="dark"] {
    --bg:      #0c0c10;
    --bg2:     #14141c;
    --bg3:     #1c1c28;
    --border:  #2a2a3a;
    --txt:     #f0f0f8;
    --muted:   #8888aa;
    --btn:     #f0f0f8;
    --btn-txt: #0c0c10;
    --blue:    #60a5fa;
    --sel:     #1e3a5f;
    --hi:      #1a1a28;
    --given:   #1e1e2e;
    --err-bg:  #1e0808;
    --err:     #f87171;
    --ok-bg:   #041e10;
    --ok:      #4ade80;
    --warn-bg: #1c1000;
    --warn:    #fbbf24;
}

[data-theme="dark"] .header {
    background: linear-gradient(160deg, #0d0d18 0%, #111120 100%);
    border-bottom: 1px solid rgba(255,255,255,.04);
}

/* ── Ad slots ─────────────────────────────────────── */
.ad-slot {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    flex-shrink: 0;
    min-height: 0;
}
.ad-slot:empty { display: none; }

/* ── Settings icon in header ──────────────────────── */
.settings-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: rgba(255,255,255,.6);
    font-size: 17px;
    text-decoration: none;
    flex-shrink: 0;
    transition: color .15s;
}
.settings-link:hover { color: #ffffff; }

/* ── Bottom Nav ──────────────────────────────────── */
.bnav {
    display: flex;
    border-top: 1px solid rgba(255,255,255,.06);
    background: linear-gradient(0deg, #111120 0%, #1a1a2e 100%);
    flex-shrink: 0;
    position: relative;
}

.bnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 4px 8px;
    text-decoration: none;
    color: rgba(255,255,255,.35);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    transition: color .15s;
    position: relative;
}

.bnav a i { font-size: 16px; }

.bnav a.on {
    color: #ffffff;
}

.bnav a.on::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 2.5px;
    background: #fff;
    border-radius: 0 0 4px 4px;
    opacity: .9;
}

[data-theme="dark"] .bnav {
    background: linear-gradient(0deg, #0a0a12 0%, #111120 100%);
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-block;
    width: 100%;
    padding: 11px 8px;
    border: 1.5px solid var(--border);
    border-radius: 11px;
    background: var(--bg2);
    color: var(--txt);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: background .15s, border-color .15s, box-shadow .15s;
    font-family: inherit;
    line-height: 1.2;
}

.btn:hover {
    background: var(--bg3);
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}

.btn-dark  {
    background: var(--btn);
    color: var(--btn-txt);
    border-color: var(--btn);
}
.btn-dark:hover {
    background: #2a2a40;
    border-color: #2a2a40;
    box-shadow: 0 4px 14px rgba(26,26,46,.35);
}

.btn-green { color: var(--ok); border-color: #86efac; background: var(--ok-bg); }
.btn-green:hover { background: #dcfce7; }

.btn-red   { color: var(--err); border-color: #fca5a5; background: var(--err-bg); }
.btn-red:hover   { background: #fee2e2; }

.btn-blue  { color: var(--blue); border-color: #93c5fd; background: #eff6ff; }
.btn-blue:hover  { background: #dbeafe; }

.btn-sm    { padding: 6px 12px; font-size: 11px; border-radius: 8px; width: auto; }

/* ── Modal / Overlay ─────────────────────────────── */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 18px;
    backdrop-filter: blur(2px);
}

.overlay.hide { display: none; }

.modal {
    background: var(--bg2);
    border-radius: 20px;
    padding: 24px 20px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 32px 80px rgba(0,0,0,.28);
    border: 1px solid var(--border);
}

.modal h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; text-align: center; }
.modal p  { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 14px; }

.modal-acts { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.modal-acts .btn { margin: 0; }

.modal-close {
    position: absolute;
    top: 14px; right: 16px;
    border: none; background: none; font-size: 20px;
    color: var(--muted); cursor: pointer; line-height: 1;
    transition: color .15s;
}
.modal-close:hover { color: var(--txt); }

/* ── Forms ───────────────────────────────────────── */
.form-group { margin-bottom: 12px; }

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 5px;
}

.form-input {
    display: block;
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    background: var(--bg2);
    color: var(--txt);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.form-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-input.err { border-color: var(--err); }

/* ── Alert boxes ─────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
    display: none;
    border: 1px solid transparent;
}

.alert.show   { display: block; }
.alert.ok     { background: var(--ok-bg);   color: var(--ok);   border-color: #86efac; }
.alert.err    { background: var(--err-bg);  color: var(--err);  border-color: #fca5a5; }
.alert.info   { background: #eff6ff;        color: var(--blue); border-color: #93c5fd; }
.alert.warn   { background: var(--warn-bg); color: var(--warn); border-color: #fcd34d; }

/* ── Spinner ─────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.empty-state i    { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state p    { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--txt); }
.empty-state span { font-size: 12px; }

/* ── Pill tabs ───────────────────────────────────── */
.pills {
    display: flex;
    gap: 6px;
    padding: 9px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
}

.pills::-webkit-scrollbar { display: none; }

.pill {
    white-space: nowrap;
    padding: 5px 13px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s;
    font-family: inherit;
}

.pill:hover {
    background: var(--bg3);
    color: var(--txt);
}

.pill.on {
    background: var(--btn);
    color: var(--btn-txt);
    border-color: var(--btn);
    box-shadow: 0 2px 8px rgba(26,26,46,.2);
}

/* ── Sudoku grid (shared between play + build) ────── */
.sbox {
    background: var(--txt);
    border: 3px solid var(--txt);
    border-radius: 16px;
    padding: 3px;
    display: inline-block;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    position: relative;
}

.sgrid {
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--bg2);
    border-radius: 13px;
    overflow: hidden;
}

.sgrid td {
    width: 50px; height: 50px;
    text-align: center; vertical-align: middle;
    font-size: 22px; font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    user-select: none;
    transition: background .08s;
    letter-spacing: -.5px;
}

/* 3×3 box dividers */
.sgrid tr:nth-child(3n) td    { border-bottom: 2.5px solid var(--txt); }
.sgrid tr:last-child td       { border-bottom: 1px solid var(--border); }
.sgrid tr:nth-child(3n+1) td  { border-top: 2.5px solid var(--txt); }
.sgrid td:nth-child(3n)       { border-right: 2.5px solid var(--txt); }
.sgrid td:nth-child(3n+1)     { border-left: 2.5px solid var(--txt); }
.sgrid td:last-child          { border-right: 1px solid var(--border); }

/* Given clues */
.cg  { background: var(--bg2); color: var(--txt); font-weight: 900; }

/* User-entered */
.cu  { color: var(--blue); font-weight: 700; }

.cs  { background: var(--sel) !important; box-shadow: inset 0 0 0 2.5px var(--blue); }
.chi { background: var(--hi); }
.ci  { background: var(--err-bg) !important; color: var(--err) !important; }

.cnotes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%; height: 100%; padding: 1px;
}

.nd {
    font-size: 8px; font-weight: 700; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
}

/* ── Responsive grid sizes ───────────────────────── */
@media (max-width: 400px) {
    .sgrid td { width: 37px; height: 37px; font-size: 16px; }
    .nd { font-size: 7px; }
}
@media (max-width: 360px) {
    .sgrid td { width: 32px; height: 32px; font-size: 14px; }
}

@media (min-height: 700px) and (max-width: 400px) {
    .sgrid td { width: 44px; height: 44px; font-size: 19px; }
    .nd { font-size: 8px; }
}
@media (min-height: 700px) and (max-width: 375px) {
    .sgrid td { width: 40px; height: 40px; font-size: 17px; }
}

@media (min-width: 520px) {
    .sgrid td { width: 55px; height: 55px; font-size: 24px; }
}
@media (min-width: 520px) and (max-height: 820px) {
    .sgrid td { width: 48px; height: 48px; font-size: 21px; }
}
@media (min-width: 520px) and (max-height: 720px) {
    .sgrid td { width: 42px; height: 42px; font-size: 18px; }
}

@media (orientation: landscape) and (max-height: 480px) {
    .sgrid td { width: 32px; height: 32px; font-size: 13px; }
}

/* ── Variant cell tints ───────────────────────────── */

/* Diagonal (X-Sudoku) */
.cd { background: #eef3ff; }
[data-theme="dark"] .cd { background: #0e1828; }
.cs.cd  { background: var(--sel) !important; }
.chi.cd { background: #d8e6ff; }
[data-theme="dark"] .chi.cd { background: #14243a; }

/* Hyper Sudoku window cells */
.ch { background: #edfff5; }
[data-theme="dark"] .ch { background: #08180e; }
.cs.ch  { background: var(--sel) !important; }
.chi.ch { background: #ccf7e0; }
[data-theme="dark"] .chi.ch { background: #0e2418; }

/* Even/Odd Sudoku */
.ce { background: #eeeeff; }
.co { background: #fff8ec; }
[data-theme="dark"] .ce { background: #0e0e28; }
[data-theme="dark"] .co { background: #1c1200; }
.cs.ce, .cs.co { background: var(--sel) !important; }
