/* Sudoku game page.
   (Controllers/GamesController.cs, Views/Games/Sudoku.cshtml)

   Loads alongside predict.css purely for the shared top bar, which is keyed on
   body:has(.predict-shell). Prize badges reuse .history-position-badge and the
   .pos-* classes from site.css. Nothing else reads this file. */

.sdk-shell {
    max-width: 520px;
    margin: 0 auto;
    padding: 16px 16px calc(126px + env(safe-area-inset-bottom));
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.sdk-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.sdk-back {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 18px;
    text-decoration: none;
}

.sdk-topbar h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
}

.sdk-tagline {
    margin: 2px 0 0;
    color: var(--text-soft);
    font-size: 12px;
}

/* ── Board ──────────────────────────────────────────────────────────────── */

.sdk-card {
    padding: 16px 14px;
    border: 1px solid rgba(216, 169, 63, .4);
    border-radius: 18px;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(216, 169, 63, .1), transparent 60%),
        var(--surface);
    box-shadow: var(--shadow);
}

.sdk-board {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 1px;
    max-width: 360px;
    margin: 0 auto;
    padding: 2px;
    border: 2px solid var(--text);
    border-radius: 8px;
    background: var(--line);
}

.sdk-cell {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    min-width: 0;
    padding: 0;
    border: 0;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Thicker rules between the 3x3 boxes, drawn as borders on the last cell of
   each band so the grid keeps its familiar shape. */
.sdk-cell.edge-right {
    border-right: 2px solid var(--text);
}

.sdk-cell.edge-bottom {
    border-bottom: 2px solid var(--text);
}

/* The six blanks. Given digits stay plain, so the cells to solve stand out. */
.sdk-input {
    background: rgba(216, 169, 63, .16);
    color: #8b5c12;
    font-weight: 900;
    cursor: pointer;
}

body.dark .sdk-input {
    color: #f0c65a;
}

.sdk-input:focus {
    outline: none;
    background: rgba(216, 169, 63, .34);
    box-shadow: 0 0 0 2px #c8952c inset;
}

.sdk-input.is-wrong {
    background: rgba(226, 75, 74, .22);
    color: #c0392b;
}

body.dark .sdk-input.is-wrong {
    color: #f09595;
}

.sdk-input.is-correct {
    background: rgba(108, 191, 63, .3);
    color: #2f6b16;
}

body.dark .sdk-input.is-correct {
    color: #c0dd97;
}

/* ── Actions ────────────────────────────────────────────────────────────── */

.sdk-actions {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 8px;
    margin-top: 16px;
}

.sdk-btn {
    padding: 0;
    border: 0;
    border-radius: 12px;
    font-family: inherit;
    cursor: pointer;
}

.sdk-btn-ghost {
    padding: 13px 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
}

.sdk-btn-gold {
    background: linear-gradient(180deg, #8b5c12, #6d4710);
}

.sdk-btn-gold span {
    display: block;
    padding: 13px 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, #e8bd52, #c8952c);
    color: #40290a;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    transform: translateY(-3px);
    transition: transform .09s ease;
}

.sdk-btn-gold:active span {
    transform: translateY(0);
}

.sdk-btn-gold[disabled] span {
    transform: translateY(0);
    opacity: .75;
}

.sdk-status {
    margin: 12px 0 0;
    min-height: 18px;
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
}

.sdk-status.is-error {
    color: #c0392b;
}

/* ── Congratulations popup ──────────────────────────────────────────────── */

/* A centred overlay above everything, including the fixed bottom nav. It shows
   for one second and dismisses itself.

   The :not([hidden]) guard matters: a bare "display: grid" here would be an
   author rule beating the browser's own [hidden] { display: none }, which would
   leave the popup on screen permanently. */
.sdk-congrats:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(12, 16, 23, .55);
    /* Click-through, so a tap landing during the one-second flash still reaches
       the page underneath instead of being swallowed. */
    pointer-events: none;
    animation: sdk-fade .18s ease;
}

.sdk-congrats-box {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 26px 34px;
    border: 1px solid rgba(216, 169, 63, .85);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff6e0, #f4dda6);
    box-shadow: 0 18px 44px rgba(0, 0, 0, .45);
    animation: sdk-pop .32s cubic-bezier(.2, .9, .3, 1.25);
}

body.dark .sdk-congrats-box {
    background: linear-gradient(180deg, #2a2313, #1c1810);
    border-color: rgba(240, 198, 90, .75);
}

.sdk-congrats-mark {
    font-size: 42px;
    line-height: 1;
}

.sdk-congrats-box strong {
    color: #6d4710;
    font-size: 19px;
    font-weight: 900;
    letter-spacing: .01em;
}

body.dark .sdk-congrats-box strong {
    color: #f0c65a;
}

@keyframes sdk-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes sdk-pop {
    from { opacity: 0; transform: scale(.82); }
    to   { opacity: 1; transform: none; }
}

/* ── Results ────────────────────────────────────────────────────────────── */

.sdk-results,
.sdk-history,
.sdk-about {
    margin-top: 20px;
}

.sdk-digits {
    display: grid;
    justify-items: center;
    gap: 2px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
}

.sdk-digits-label {
    color: var(--text-soft);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.sdk-digits-value {
    color: var(--gold);
    font-size: 28px;
    font-weight: 900;
    letter-spacing: .14em;
    font-variant-numeric: tabular-nums;
}

.sdk-section-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.sdk-section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 900;
}

.sdk-section-head span {
    color: var(--text-soft);
    font-size: 11.5px;
}

.sdk-empty {
    margin: 0;
    padding: 18px 0;
    color: var(--text-soft);
    font-size: 13px;
    text-align: center;
}

.sdk-list {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    overflow: hidden;
}

.sdk-list-head,
.sdk-row {
    display: grid;
    grid-template-columns: 26px 60px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
}

.sdk-list-head {
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
    color: var(--text-soft);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.sdk-row {
    border-bottom: 1px solid var(--line);
}

.sdk-row:last-child {
    border-bottom: 0;
}

.sdk-row.has-hit {
    background: rgba(216, 169, 63, .07);
}

.sdk-index {
    color: var(--text-soft);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.sdk-number {
    font-size: 17px;
    font-weight: 900;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}

.sdk-row.has-hit .sdk-number {
    color: var(--gold);
}

.sdk-hits {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.sdk-hit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 10px;
    white-space: nowrap;
}

.sdk-hit img {
    width: 14px;
    height: 14px;
    object-fit: contain;
    border-radius: 3px;
}

.sdk-hit time {
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
}

.sdk-hits .history-position-badge {
    padding: 1px 5px;
    font-size: 9px;
}

.sdk-none {
    color: var(--text-soft);
    font-size: 11px;
}

/* ── History & footer ───────────────────────────────────────────────────── */

.sdk-history-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.sdk-history-list .sdk-empty {
    grid-column: 1 / -1;
}

.sdk-history-chip {
    display: grid;
    gap: 2px;
    padding: 10px 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    text-align: center;
}

.sdk-history-chip strong {
    color: var(--gold);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: .08em;
    font-variant-numeric: tabular-nums;
}

.sdk-history-chip span {
    color: var(--text-soft);
    font-size: 10.5px;
}

.sdk-history-chip.is-new {
    border-color: rgba(216, 169, 63, .7);
    animation: sdk-pop .45s ease;
}

.sdk-about h2 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 900;
}

.sdk-about p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.6;
}

.sdk-disclaimer {
    margin: 16px 0 0;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.6;
}

@media (max-width: 380px) {
    .sdk-cell {
        font-size: 12px;
    }

    .sdk-list-head,
    .sdk-row {
        grid-template-columns: 22px 54px minmax(0, 1fr);
        gap: 6px;
        padding: 8px 9px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sdk-congrats-box,
    .sdk-history-chip.is-new {
        animation: none;
    }
}
