/* Rocket Sudoku. Scoped to .sd. */
.sd { --cell: #0c1630; --peer: #121f3d; --same: #1b3a63; --sel: #24588a; --hl: #3a3420; --line: #1c2b4a; --thick: #47648c; --muted: #8aa3c4; --text: #dfe9ff; --accent: #55d6ff; --warm: #ffd166; --bad: #ff6b81;
  --sd-bs: min(100%, 560px);
  position: relative; max-width: 980px; margin: 0 auto; padding: 4px 0 8px; color: var(--text);
  display: grid; gap: 10px; justify-content: center; align-content: start;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.sd [hidden] { display: none !important; }
.sd button { font-family: inherit; line-height: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.sd :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sd-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout: portrait stacks, landscape puts the panel beside the board ---------- */
.sd-port { grid-template-columns: var(--sd-bs); grid-template-areas: "head" "info" "board" "tools" "pad"; }
.sd-land { grid-template-columns: var(--sd-bs) var(--sd-pw, 320px); grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "board head" "board info" "board tools" "board pad"; column-gap: 20px; row-gap: 12px; }
.sd-head { grid-area: head; } .sd-info { grid-area: info; } .sd-boardwrap { grid-area: board; } .sd-tools { grid-area: tools; } .sd-pad { grid-area: pad; }
.sd.sd-fit { max-width: none; height: 100%; margin: 0; padding: 6px 4px; align-content: center; overflow: hidden; }
.sd-fit.sd-port { gap: 8px; grid-template-rows: auto minmax(0, 1fr) auto auto auto auto minmax(0, 1fr); grid-template-areas: "head" "." "info" "board" "tools" "pad" "."; align-content: stretch; }   /* header at the top, the rest centred below it */

/* ---------- header ---------- */
.sd-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sd-game { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 10px 0 14px; border-radius: 999px; border: 1px solid #2a3b5f; background: #0b1328; color: #fff; font-weight: 750; font-size: 15px; cursor: pointer; min-width: 0; transition: border-color .15s, background-color .15s; }
.sd-game-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-game svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .sd-game:hover { border-color: var(--accent); } .sd-daily:hover { border-color: var(--warm); } }
.sd-daily { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,209,102,0.35); background: rgba(255,209,102,0.06); color: var(--warm); font-weight: 700; font-size: 14px; cursor: pointer; flex: none; transition: border-color .15s, background-color .15s, color .15s; }
.sd-daily svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sd-daily[aria-pressed="true"] { background: var(--warm); color: #1a1200; border-color: var(--warm); }
.sd-dot { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px #060b18; }
.sd-icons { display: flex; gap: 2px; margin-left: auto; flex: none; }
.sd-ibtn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: #c9d7ef; cursor: pointer; transition: background-color .15s, color .15s; }
@media (hover: hover) { .sd-ibtn:hover { background: rgba(255,255,255,0.07); color: #fff; } }
.sd-ibtn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- info row ---------- */
.sd-info { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; font-size: 13.5px; color: var(--muted); padding: 0 2px; }
.sd-level { font-weight: 600; letter-spacing: 0.02em; }
.sd-mistakes { font-variant-numeric: tabular-nums; display: inline-block; }
.sd-mistakes.has { color: var(--bad); font-weight: 650; }
.sd-clock { display: inline-flex; align-items: center; gap: 2px; }
.sd-time { font-variant-numeric: tabular-nums; font-weight: 700; color: #fff; font-size: 15px; min-width: 3.2em; text-align: right; }
.sd-notimer .sd-time { visibility: hidden; }
.sd-pause { width: 40px; height: 40px; margin: -4px -4px -4px 0; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: #c9d7ef; cursor: pointer; }
.sd-pause svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.sd-pause:disabled { opacity: 0.3; cursor: default; }
@media (hover: hover) { .sd-pause:hover:not(:disabled) { background: rgba(255,255,255,0.07); } }

/* ---------- board ---------- */
.sd-boardwrap { position: relative; width: var(--sd-bs); height: var(--sd-bs); }
.sd-board { width: 100%; height: 100%; box-sizing: border-box; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 2px; background: var(--thick); border-radius: 10px; overflow: hidden; touch-action: none; cursor: pointer; transition: box-shadow .4s; }
.sd-board:focus { outline: none; }
.sd-board:focus-visible { box-shadow: 0 0 0 3px rgba(85,214,255,0.55); }
.sd-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 1px; background: #1f2f4f; min-width: 0; min-height: 0; }
.sd-cell { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; background: var(--cell); color: var(--text); font-size: calc(var(--sd-bs) * 0.062); line-height: 1; font-variant-numeric: tabular-nums; transition: background-color .12s ease; }
.sd-cell.peer { background: var(--peer); }
.sd-cell.same { background: var(--same); }
.sd-cell.hl { background: var(--hl); }
.sd-cell.sel { background: var(--sel); }
.sd-v { pointer-events: none; display: block; }
.sd-cell.given { color: #eef4ff; font-weight: 700; }
.sd-cell.user { color: var(--accent); font-weight: 600; }
.sd-cell.sel.user { color: #c5f1ff; }
.sd-cell.wrong, .sd-cell.sel.wrong { color: var(--bad); }
.sd-cell.wrong:not(.sel) { background: #2a1630; }
.sd-cell.clash::after { content: ''; position: absolute; top: 9%; right: 9%; width: 12%; height: 12%; max-width: 7px; max-height: 7px; border-radius: 50%; background: var(--bad); }
.sd-cell.clash.user { color: var(--bad); }
.sd-notes { position: absolute; inset: 5%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); pointer-events: none; font-size: max(8px, calc(var(--sd-bs) * 0.024)); font-weight: 600; color: #93a9c9; }
.sd-notes i { font-style: normal; display: grid; place-items: center; border-radius: 3px; }
.sd-notes i.on { background: var(--accent); color: #04121c; font-weight: 800; }
.sd-won .sd-board { box-shadow: 0 0 0 2px var(--warm), 0 0 40px rgba(255,209,102,0.25); }

.sd-cover { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; border-radius: 10px; background: rgba(8,13,28,0.97); text-align: center; animation: sd-fade .2s ease; }
.sd-cover > div { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.sd-cover b { font-size: 20px; color: #fff; }
.sd-loading { background: rgba(8,13,28,0.86); }
.sd-loading b { font-size: 15px; color: var(--muted); font-weight: 600; }
.sd-spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #22345a; border-top-color: var(--accent); animation: sd-spin .8s linear infinite; }
.sd-tip { position: absolute; left: 8px; right: 8px; top: 8px; z-index: 5; background: #f4f7fb; color: #0b1328; border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.4; box-shadow: 0 10px 30px rgba(0,0,0,0.5); pointer-events: none; animation: sd-tip .26s cubic-bezier(.2,.8,.2,1); }
.sd-tip.low { top: auto; bottom: 8px; }
.sd-tip b { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #8a6200; margin-bottom: 2px; }
.sd-toast { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -6px); background: #f4f7fb; color: #0b1328; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 999px; pointer-events: none; opacity: 0; z-index: 6; max-width: 92%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.sd-toast.show { animation: sd-toast 1.8s ease forwards; }

/* ---------- tools ---------- */
.sd-tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.sd-tool { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 4px 2px; border: 0; border-radius: 12px; background: transparent; color: #c9d7ef; font-size: 12px; font-weight: 650; cursor: pointer; touch-action: none; transition: background-color .15s, color .15s, opacity .15s; }
.sd-tool svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .sd-tool:hover:not(:disabled) { background: rgba(255,255,255,0.06); color: #fff; } }
.sd-tool:active:not(:disabled) { transform: scale(0.95); }
.sd-tool:disabled { opacity: 0.32; cursor: default; }
.sd-tool[aria-pressed="true"] { color: var(--accent); background: rgba(85,214,255,0.1); }
.sd-flag { position: absolute; top: 3px; left: calc(50% + 8px); font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 5px; border-radius: 6px; background: #22345a; color: var(--muted); }
.sd-tool[aria-pressed="true"] .sd-flag { background: var(--accent); color: #04121c; }
#sd-hint { color: var(--warm); }

/* ---------- number pad ---------- */
.sd-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.sd-key { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: var(--sd-keyh, clamp(54px, calc(var(--sd-bs) * 0.16), 70px)); min-width: 0; padding: 0; border-radius: 12px; border: 1px solid #22345a; background: #0f1a35; color: #fff; cursor: pointer; touch-action: none; transition: background-color .12s, border-color .12s, transform .1s, opacity .2s; }
.sd-key b { font-size: clamp(22px, calc(var(--sd-bs) * 0.07), 32px); font-weight: 650; line-height: 1; }
.sd-key small { font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; }
@media (hover: hover) { .sd-key:hover:not(:disabled) { border-color: var(--accent); background: #13224a; } }
.sd-key:active:not(:disabled) { transform: scale(0.94); background: #1b2f5c; }
.sd-key.gone { visibility: hidden; }
.sd-key:disabled { cursor: default; }
.sd-pad.notes .sd-key { border-style: dashed; border-color: rgba(85,214,255,0.55); background: rgba(85,214,255,0.05); }
.sd-pad.notes .sd-key b { color: var(--accent); font-size: clamp(17px, calc(var(--sd-bs) * 0.05), 24px); }
.sd-land .sd-pad { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 8px; align-self: stretch; max-height: 420px; }
.sd-land .sd-key { height: auto; min-height: 44px; }
.sd-land .sd-key b { font-size: clamp(22px, calc(var(--sd-pw, 320px) * 0.1), 34px); }
.sd-land .sd-pad.notes .sd-key b { font-size: clamp(17px, calc(var(--sd-pw, 320px) * 0.07), 26px); }
.sd-land .sd-head { flex-wrap: nowrap; }
.sd-is-paused .sd-pad, .sd-is-paused .sd-tools, .sd-busy .sd-pad, .sd-busy .sd-tools { opacity: 0.4; pointer-events: none; }

/* ---------- buttons ---------- */
.sd-btn { min-height: 46px; min-width: 104px; padding: 0 20px; border-radius: 999px; border: 1px solid #2a3b5f; background: transparent; color: var(--text); font-weight: 700; font-size: 14.5px; cursor: pointer; transition: background-color .15s, border-color .15s, transform .12s; }
@media (hover: hover) { .sd-btn:hover:not(:disabled) { border-color: #5b7099; background: rgba(255,255,255,0.03); } }
.sd-btn:active:not(:disabled) { transform: scale(0.97); }
.sd-btn-primary { background: var(--warm); color: #1a1200; border-color: var(--warm); }
@media (hover: hover) { .sd-btn-primary:hover:not(:disabled) { background: #ffe08a; border-color: #ffe08a; } }

/* ---------- sheets ---------- */
.sd-scrim { position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(2,4,10,0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: sd-fade .2s ease; }
.sd-scrim.out { animation: sd-fade .17s ease reverse forwards; }
.sd-sheet { position: relative; width: 100%; max-width: 460px; max-height: min(88vh, 760px); overflow: auto; overscroll-behavior: contain; background: #0d1630; border: 1px solid #22345a; border-radius: 20px; padding: 22px 22px 20px; box-shadow: 0 30px 80px rgba(0,0,0,0.6); color: var(--text); animation: sd-sheet .28s cubic-bezier(.2,.8,.2,1); }
.sd-scrim.out .sd-sheet { animation: sd-sheet .17s ease reverse forwards; }
.sd-sheet:focus { outline: none; }
.sd-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 0; background: rgba(255,255,255,0.08); color: #c9d7ef; cursor: pointer; }
.sd-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
@media (hover: hover) { .sd-x:hover { background: rgba(255,255,255,0.14); color: #fff; } }
.sd-sheet-title { margin: 0 44px 6px 0; font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.01em; }
.sd-sheet-title.sd-center { margin: 4px 0 0; }
.sd-center { text-align: center; }
.sd-sub { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; }
.sd-h4 { margin: 18px 0 8px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 750; }
.sd-fine { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.sd-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.sd-sheet-actions .sd-btn { flex: 1 1 0; min-width: 0; }
.sd-sheet-actions .sd-btn-primary { flex-basis: 100%; }

.sd-daily-card { display: flex; align-items: center; gap: 12px; width: 100%; margin: 12px 0 0; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(255,209,102,0.35); background: rgba(255,209,102,0.06); color: var(--text); text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s; }
.sd-daily-card.sd-continue { border-color: #2a3b5f; background: #0b1328; }
@media (hover: hover) { .sd-daily-card:hover { border-color: var(--warm); } .sd-daily-card.sd-continue:hover { border-color: var(--accent); } }
.sd-daily-card.cur { box-shadow: inset 0 0 0 1px var(--warm); }
.sd-dc-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--warm); display: grid; place-items: center; flex: none; }
.sd-dc-icon svg { width: 22px; height: 22px; fill: none; stroke: #1a1200; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sd-dc-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.sd-dc-text b { font-size: 15.5px; color: #fff; } .sd-dc-text small { font-size: 12.5px; color: var(--muted); }
.sd-dc-state { font-size: 12.5px; font-weight: 700; color: var(--muted); text-align: right; flex: none; max-width: 40%; }
.sd-dc-state.ok { color: #5ee6a8; }
.sd-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sd-lv { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px 14px; min-height: 92px; border-radius: 14px; border: 1px solid #22345a; background: #0b1328; color: var(--text); text-align: left; cursor: pointer; transition: border-color .15s, background-color .15s; }
@media (hover: hover) { .sd-lv:hover { border-color: var(--accent); background: #0f1a35; } }
.sd-lv.cur { border-color: var(--accent); }
.sd-lv b { font-size: 16px; color: #fff; }
.sd-lv small { font-size: 12px; color: var(--muted); line-height: 1.35; }
.sd-lv em { font-style: normal; font-size: 11.5px; color: var(--warm); font-weight: 650; margin-top: 2px; }
.sd-pips { display: inline-flex; gap: 3px; margin-bottom: 2px; }
.sd-pips i { width: 14px; height: 4px; border-radius: 2px; background: #2b3a5c; }
.sd-pips i.on { background: var(--accent); }

.sd-res-badge { width: 72px; height: 72px; margin: 2px auto 6px; }
.sd-res-badge svg { width: 100%; height: 100%; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sd-res-badge .ring { stroke: var(--warm); stroke-width: 4; stroke-dasharray: 176 176; animation: sd-ring .6s ease-out both; }
.sd-res-badge .tick { stroke: #fff; stroke-width: 5; stroke-dasharray: 40 40; animation: sd-tick .35s .4s ease-out both; }
.sd-res-time { margin: 2px 0 2px; text-align: center; font-size: 44px; font-weight: 800; color: #fff; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.sd-res-stats { display: flex; justify-content: center; gap: 8px; margin: 14px 0 0; }
.sd-res-stats > div { flex: 1 1 0; min-width: 0; background: #0b1328; border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.sd-res-stats b { display: block; font-size: 19px; color: #fff; font-variant-numeric: tabular-nums; }
.sd-res-stats span { font-size: 11.5px; color: var(--muted); }
.sd-copy { width: 100%; box-sizing: border-box; margin-top: 12px; background: #0b1328; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: 13px/1.4 ui-monospace, monospace; resize: none; user-select: text; -webkit-user-select: text; }
.sd-table-wrap { overflow-x: auto; margin-top: 14px; }
.sd-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.sd-table th, .sd-table td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sd-table th:first-child { text-align: left; color: #fff; }
.sd-table thead th { font-size: 11.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.sd-table small { color: var(--muted); }
.sd-help { margin: 0; padding: 0 0 0 18px; display: grid; gap: 8px; font-size: 14.5px; line-height: 1.45; }
.sd-help b { color: #fff; }
.sd-set { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.sd-set > span { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.sd-set b { font-size: 15px; color: #fff; } .sd-set small { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.sd-set input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sd-sw { flex: none; width: 46px; height: 28px; border-radius: 14px; background: #2b3448; position: relative; transition: background-color .15s; }
.sd-sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.sd-set input:checked + .sd-sw { background: #2ec27e; }
.sd-set input:checked + .sd-sw::after { left: 21px; }
.sd-set input:focus-visible + .sd-sw { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes sd-fade { from { opacity: 0; } }
@keyframes sd-sheet { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes sd-up { from { transform: translateY(100%); } }
@keyframes sd-spin { to { transform: rotate(360deg); } }
@keyframes sd-tip { from { opacity: 0; transform: translateY(-6px); } }
@keyframes sd-toast { 0% { opacity: 0; transform: translate(-50%, -6px); } 12%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -4px); } }
@keyframes sd-ring { from { stroke-dashoffset: 176; } }
@keyframes sd-tick { from { stroke-dashoffset: 40; } }
@media (prefers-reduced-motion: reduce) { .sd *, .sd-scrim, .sd-sheet { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

.sd-tighthead .sd-daily span { display: none; }
.sd-tighthead .sd-daily { width: 40px; padding: 0; justify-content: center; }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .sd-scrim { align-items: flex-end; padding: 0; }
  .sd-sheet { max-width: none; border-radius: 22px 22px 0 0; max-height: 90vh; padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px)); animation-name: sd-up; border-bottom: 0; }
  .sd-scrim.out .sd-sheet { animation-name: sd-up; }
  .sd-daily span { display: none; }
  .sd-daily { width: 40px; padding: 0; justify-content: center; }
  .sd-pad { gap: 4px; }
  .sd-key { border-radius: 10px; }
}
@media (max-width: 360px) { .sd-icons { gap: 0; } .sd-levels { grid-template-columns: 1fr; } }
/* short landscape screens (phones sideways): tighter panel */
@media (max-height: 500px) {
  .sd-land { row-gap: 8px; }
  .sd-land .sd-tool { min-height: 46px; font-size: 11px; }
  .sd-land .sd-tool svg { width: 21px; height: 21px; }
  .sd-land .sd-pad { gap: 6px; }
}
