:root {
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-hi: #8b6dff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --gold: #ffd43b;
  --red: #ff5a76;
  --user: #b9a8ff;
  --board: min(calc(100vw - 20px), 520px);
  --font:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(
      120% 70% at 50% -10%,
      rgba(104, 66, 255, 0.22),
      transparent 60%
    ),
    var(--bg);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.sd-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sd-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- HUD ---------- */
.sd-hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "brand chips actions";
  align-items: center;
  gap: 8px 10px;
  padding: 7px 8px 7px 12px;
  border-radius: 20px;
  background: linear-gradient(180deg, #25263b, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 6px 18px rgba(0, 0, 0, 0.35);
}

.sd-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sd-brand-icon {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.sd-chips {
  grid-area: chips;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.sd-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: #11121e;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sd-chip strong {
  font-size: 17px;
  font-weight: 900;
}

.sd-chip svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.sd-chip-diff {
  background: linear-gradient(180deg, #8467ff, #5a35f0);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 8px rgba(104, 66, 255, 0.4);
  font-weight: 900;
  font-size: 14px;
}

.sd-chip-mistakes svg {
  fill: var(--red);
}

.sd-chip-mistakes.is-danger strong {
  color: var(--red);
}

.sd-chip-score {
  color: var(--gold);
}

.sd-chip-time {
  color: #7fd8ff;
}

.sd-chip-time strong,
.sd-chip-score strong {
  color: #fff;
}

.sd-hud-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sd-icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #36385a, #2a2b3d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 0 rgba(0, 0, 0, 0.3),
    0 3px 8px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s;
}

.sd-icon-btn svg {
  width: 20px;
  height: 20px;
}

.sd-icon-btn:active:not(:disabled) {
  transform: scale(0.9);
}

.sd-icon-btn:disabled {
  opacity: 0.45;
}

/* ---------- Pills ---------- */
.sd-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #37395a, #2a2b3d);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -3px 0 rgba(0, 0, 0, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.12s,
    filter 0.15s;
}

.sd-pill:active {
  transform: scale(0.95);
}

.sd-pill-primary {
  background: linear-gradient(180deg, #8a6dff, #6842ff 55%, #5530e6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -4px 0 rgba(40, 12, 150, 0.55),
    0 6px 16px rgba(104, 66, 255, 0.45);
}

.sd-pill-primary:hover {
  filter: brightness(1.08);
}

.sd-short {
  display: none;
}

.sd-nowrap {
  white-space: nowrap;
}

.sd-new {
  white-space: nowrap;
  min-height: 42px;
  padding: 0 16px;
  font-size: 15px;
}

.sd-pill-big {
  min-height: 56px;
  font-size: 20px;
  width: 100%;
}

.sd-pill-small {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}

/* ---------- Play area ---------- */
.sd-play {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sd-board-wrap {
  width: var(--board);
  flex: none;
}

.sd-board {
  --gap: 2px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 3px 1fr 1fr 1fr 3px 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr 3px 1fr 1fr 1fr 3px 1fr 1fr 1fr;
  gap: var(--gap);
  width: 100%;
  aspect-ratio: 1;
  padding: 6px;
  border-radius: 20px;
  background: linear-gradient(180deg, #0b0c18, #121327);
  box-shadow:
    0 0 0 2px rgba(139, 109, 255, 0.35),
    0 14px 34px rgba(0, 0, 0, 0.5),
    inset 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: filter 0.2s;
}

.sd-board.is-paused .sd-val,
.sd-board.is-paused .sd-notes {
  opacity: 0;
}

.sd-cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #2b2d48, #232540);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22);
  color: var(--user);
  font-size: calc(var(--board) * 0.066);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition:
    background-color 0.12s,
    transform 0.1s;
}

.sd-cell:focus-visible {
  outline-offset: -2px;
  z-index: 2;
}

.sd-val {
  position: relative;
  z-index: 1;
}

.sd-cell.is-given {
  color: #fff;
}

.sd-cell.is-peer {
  background: linear-gradient(180deg, #3a3c7c, #313368);
}

.sd-cell.is-same {
  background: linear-gradient(180deg, #5a45d6, #4632b8);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.sd-cell.is-conflict {
  background: linear-gradient(180deg, #5a2440, #491c35);
  color: #ffc2cd;
}

.sd-cell.is-wrong {
  color: var(--red);
  background: linear-gradient(180deg, #4a2240, #3c1b36);
}

.sd-cell.is-selected {
  background: linear-gradient(180deg, #8f75ff, #6842ff 60%, #5634e8);
  color: #fff;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 0 rgba(30, 8, 120, 0.5),
    0 0 0 2px rgba(255, 255, 255, 0.85),
    0 6px 16px rgba(104, 66, 255, 0.65);
  z-index: 1;
}

.sd-cell.is-selected.is-wrong {
  background: linear-gradient(180deg, #ff7a91, #e8385a);
  color: #fff;
}

.sd-notes {
  position: absolute;
  inset: 8%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: calc(var(--board) * 0.026);
  font-weight: 800;
  color: var(--muted);
  pointer-events: none;
}

.sd-notes > span {
  display: grid;
  place-items: center;
  border-radius: 4px;
  line-height: 1;
}

.sd-notes > span.is-hot {
  background: var(--accent);
  color: #fff;
}

.sd-cell.is-selected .sd-notes {
  color: #e6e0ff;
}

/* ---------- Panel ---------- */
.sd-panel {
  width: var(--board);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sd-tools {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.sd-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sd-tool-icon {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #37395a, #2a2b3d);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 -3px 0 rgba(0, 0, 0, 0.32),
    0 4px 10px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s;
}

.sd-tool-icon svg {
  width: 24px;
  height: 24px;
}

.sd-tool:active:not(:disabled) .sd-tool-icon {
  transform: scale(0.9);
}

.sd-tool:disabled {
  opacity: 0.45;
}

.sd-tool[aria-pressed="true"] .sd-tool-icon {
  background: linear-gradient(180deg, #8a6dff, #6842ff 60%, #5530e6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -3px 0 rgba(40, 12, 150, 0.55),
    0 5px 14px rgba(104, 66, 255, 0.5);
}

.sd-tool[aria-pressed="true"] {
  color: #fff;
}

.sd-badge {
  position: absolute;
  top: -5px;
  right: -9px;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #f5b50a);
  color: #3a2600;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.sd-badge-toggle {
  background: #4a4c68;
  color: #d8daf0;
  right: -14px;
}

.sd-tool[aria-pressed="true"] .sd-badge-toggle {
  background: linear-gradient(180deg, #7ef0bf, #2fc98b);
  color: #073b24;
}

.sd-pad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 3px;
}

.sd-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #3a3c63, #2a2b45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.1s,
    opacity 0.2s;
}

.sd-key-digit {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: #cfc4ff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.sd-key-count {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.sd-key:active:not(:disabled) {
  transform: scale(0.92) translateY(1px);
}

.sd-key:hover:not(:disabled) .sd-key-digit {
  color: #fff;
}

.sd-key.is-done {
  opacity: 0.25;
}

.sd-key.is-done .sd-key-count {
  visibility: hidden;
}

.sd-pad.is-notes .sd-key {
  background: linear-gradient(180deg, #2d2f4d, #232438);
  box-shadow:
    inset 0 0 0 2px rgba(139, 109, 255, 0.6),
    inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.sd-pad.is-notes .sd-key-digit {
  color: var(--accent-hi);
  font-size: 22px;
}

.sd-help {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: #2a2b3d;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  font: inherit;
  font-size: 11px;
  color: #fff;
}

/* ---------- FX canvas ---------- */
.sd-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

/* ---------- Overlay ---------- */
.sd-overlay {
  position: absolute;
  inset: -4px;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 22px;
  background: rgba(12, 13, 28, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow: auto;
}

.sd-overlay[hidden] {
  display: none;
}

.sd-card {
  position: relative;
  width: min(100%, 370px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  border-radius: 28px;
  background: linear-gradient(180deg, #2a2b44, #1c1d2e);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(139, 109, 255, 0.25),
    0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.sd-card[hidden] {
  display: none;
}

.sd-card.is-in {
  animation: sd-card-in 0.36s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.sd-card h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.sd-lede {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.sd-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #2a2b3d;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.sd-close svg {
  width: 16px;
  height: 16px;
}

.sd-close[hidden] {
  display: none;
}

.sd-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sd-hero-icon {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 12px rgba(104, 66, 255, 0.55));
  animation: sd-bob 3s ease-in-out infinite;
}

.sd-card .sd-hero-title {
  font-size: 40px;
  line-height: 1;
  background: linear-gradient(180deg, #fff 30%, #c9bdff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #4a2fc4)
    drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}

.sd-continue {
  width: 100%;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, #8a6dff, #6842ff 55%, #5530e6);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -4px 0 rgba(40, 12, 150, 0.55),
    0 6px 16px rgba(104, 66, 255, 0.45);
  transition: transform 0.12s;
}

.sd-continue:active {
  transform: scale(0.96);
}

.sd-continue[hidden] {
  display: none;
}

.sd-continue-top {
  font-size: 20px;
  font-weight: 900;
}

.sd-continue-sub {
  font-size: 13px;
  color: #e3dcff;
}

.sd-diffs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: #11121e;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.sd-diff {
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  font-size: 14px;
  transition:
    background 0.15s,
    color 0.15s;
}

.sd-diff[aria-checked="true"] {
  background: linear-gradient(180deg, #8467ff, #5a35f0);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 3px 8px rgba(104, 66, 255, 0.45);
}

.sd-daily {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 10px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #3a2f12, #2a2238 70%);
  box-shadow:
    inset 0 0 0 2px rgba(255, 212, 59, 0.45),
    0 4px 12px rgba(0, 0, 0, 0.3);
  text-align: left;
  transition: transform 0.12s;
}

.sd-daily:active {
  transform: scale(0.97);
}

.sd-daily-icon {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffe066, #f5a70a);
  color: #3a2600;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    0 3px 8px rgba(245, 167, 10, 0.35);
}

.sd-daily-icon svg {
  width: 24px;
  height: 24px;
}

.sd-daily-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sd-daily-text strong {
  font-size: 16px;
  font-weight: 900;
}

.sd-daily-text span {
  font-size: 13px;
  color: var(--muted);
}

.sd-daily-go {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--gold);
  color: #3a2600;
  font-weight: 900;
  font-size: 14px;
}

.sd-daily.is-done .sd-daily-go {
  background: #2fc98b;
  color: #06331f;
}

.sd-menu-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sd-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  position: relative;
}

.sd-switch input {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 26px;
  margin: 0;
}

.sd-switch-track {
  width: 44px;
  height: 26px;
  padding: 3px;
  border-radius: 999px;
  background: #3a3b52;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
  transition: background 0.2s;
}

.sd-switch-track span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #d9dbee);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.sd-switch input:checked + .sd-switch-track {
  background: var(--accent);
}

.sd-switch input:checked + .sd-switch-track span {
  transform: translateX(18px);
}

.sd-switch input:focus-visible + .sd-switch-track {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.sd-pause-disc {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #8a6dff, #5530e6);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.3),
    0 10px 24px rgba(104, 66, 255, 0.5);
}

.sd-pause-disc svg {
  width: 34px;
  height: 34px;
}

.sd-trophy {
  width: 96px;
  height: 96px;
  margin-top: -6px;
  filter: drop-shadow(0 10px 16px rgba(245, 167, 10, 0.45));
  animation: sd-trophy 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both 0.1s;
}

.sd-card-win h2 {
  color: var(--gold);
  text-shadow: 0 3px 0 #a86a00;
}

.sd-results {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sd-results div,
.sd-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 16px;
  background: #11121e;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
}

.sd-results span,
.sd-stat span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sd-results strong,
.sd-stat strong {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.sd-newbest {
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #7ef0bf, #2fc98b);
  color: #06331f;
  font-weight: 900;
}

.sd-newbest[hidden] {
  display: none;
}

.sd-lose-hearts {
  display: flex;
  gap: 4px;
}

.sd-lose-hearts svg {
  width: 36px;
  height: 36px;
  fill: #4b3c52;
  animation: sd-heart-out 0.5s both;
}

.sd-lose-hearts svg:nth-child(2) {
  animation-delay: 0.12s;
}

.sd-lose-hearts svg:nth-child(3) {
  animation-delay: 0.24s;
}

.sd-card-lose h2 {
  color: #ff8aa0;
}

.sd-btn-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

[hidden] {
  display: none !important;
}

.sd-tabs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  padding: 4px;
  border-radius: 999px;
  background: #11121e;
}

.sd-tab {
  min-height: 40px;
  padding: 0 2px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.sd-tab[aria-selected="true"] {
  background: linear-gradient(180deg, #8467ff, #5a35f0);
  color: #fff;
}

.sd-stat-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sd-stat:first-child {
  grid-column: 1 / -1;
}

.sd-stat-win strong {
  font-size: 34px;
  color: var(--gold);
}

.sd-stat-time strong {
  color: #7fd8ff;
}

/* ---------- Animations ---------- */
.sd-cell.is-intro {
  animation: sd-intro 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) both;
  animation-delay: var(--d, 0ms);
}

.sd-cell.is-pop .sd-val {
  display: inline-block;
  animation: sd-pop 0.34s cubic-bezier(0.2, 1.8, 0.4, 1);
}

.sd-cell.is-shake,
.sd-board.is-shake,
.sd-chip.is-shake {
  animation: sd-shake 0.42s ease;
}

.sd-cell.is-nope {
  animation: sd-nope 0.25s ease;
}

.sd-cell.is-hint {
  animation: sd-hint 0.9s ease;
}

.sd-cell.is-ripple::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.55),
    rgba(139, 109, 255, 0.35)
  );
  opacity: 0;
  animation: sd-ripple 0.55s ease-out both;
  animation-delay: var(--ripple-delay, 0ms);
  pointer-events: none;
}

.sd-cell.is-ripple {
  animation: sd-ripple-cell 0.5s ease-out;
  animation-delay: var(--ripple-delay, 0ms);
}

.sd-cell.is-win {
  animation: sd-win 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  animation-delay: var(--d, 0ms);
}

.sd-key.is-press {
  animation: sd-press 0.2s ease;
}

.sd-key.is-pop,
.sd-tool.is-pop .sd-tool-icon {
  animation: sd-pop 0.34s cubic-bezier(0.2, 1.8, 0.4, 1);
}

@keyframes sd-intro {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

@keyframes sd-pop {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sd-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes sd-nope {
  50% {
    transform: scale(0.9);
  }
}

@keyframes sd-hint {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 212, 59, 0.9);
    transform: scale(1);
  }
  30% {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px rgba(255, 212, 59, 0.6);
  }
  100% {
    box-shadow: 0 0 0 16px rgba(255, 212, 59, 0);
    transform: scale(1);
  }
}

@keyframes sd-ripple {
  0% {
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes sd-ripple-cell {
  40% {
    transform: scale(1.08);
  }
}

@keyframes sd-win {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18) rotate(-4deg);
    background: linear-gradient(180deg, #ffe066, #f5a70a);
    color: #3a2600;
  }
  100% {
    transform: scale(1);
  }
}

@keyframes sd-press {
  50% {
    transform: scale(0.9);
  }
}

@keyframes sd-card-in {
  from {
    transform: scale(0.8) translateY(12px);
    opacity: 0;
  }
}

@keyframes sd-bob {
  50% {
    transform: translateY(-5px) rotate(-3deg);
  }
}

@keyframes sd-trophy {
  from {
    transform: scale(0.2) rotate(-25deg);
    opacity: 0;
  }
}

@keyframes sd-heart-out {
  0% {
    fill: var(--red);
    transform: scale(1.2);
  }
  100% {
    fill: #4b3c52;
    transform: scale(1);
  }
}

/* ---------- Desktop: board left, controls right ---------- */
@media (min-width: 760px) {
  :root {
    --board: clamp(360px, calc(100vw - 420px), 500px);
  }

  .sd-play {
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    gap: 18px;
  }

  .sd-panel {
    width: 300px;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    border-radius: 24px;
    background: linear-gradient(180deg, #212233, #1a1b28);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 10px 24px rgba(0, 0, 0, 0.35);
  }

  .sd-pad {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .sd-key {
    min-height: 80px;
    border-radius: 18px;
  }

  .sd-key-digit {
    font-size: 38px;
  }

  .sd-pad.is-notes .sd-key-digit {
    font-size: 26px;
  }

  .sd-key-count {
    font-size: 12px;
  }
}

/* ---------- Narrow phones ---------- */
@media (max-width: 759px) {
  .sd-hud {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "chips chips";
    padding: 7px 8px 8px 12px;
  }

  .sd-chips {
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 4px;
  }

  .sd-chip {
    padding: 0 9px;
    gap: 4px;
  }

  .sd-chip strong {
    font-size: 15px;
  }

  .sd-help {
    display: none;
  }
}

@media (max-width: 380px) {
  .sd-shell {
    padding: 8px 6px 10px;
  }

  :root {
    --board: calc(100vw - 12px);
  }

  .sd-brand {
    font-size: 18px;
  }

  .sd-brand-icon {
    width: 26px;
    height: 26px;
  }

  .sd-chip {
    padding: 0 7px;
    min-height: 32px;
  }

  .sd-chip svg {
    width: 14px;
    height: 14px;
  }

  .sd-chip strong {
    font-size: 13px;
  }

  .sd-chip-diff {
    font-size: 12px;
  }

  .sd-new {
    padding: 0 12px;
    font-size: 14px;
  }

  .sd-pad {
    gap: 2px;
  }

  .sd-key {
    border-radius: 10px;
  }

  .sd-key-digit {
    font-size: 24px;
  }

  .sd-card {
    padding: 18px 14px 16px;
  }
}

@media (max-width: 360px) {
  .sd-long {
    display: none;
  }

  .sd-short {
    display: inline;
  }
}

@media (max-width: 340px) {
  .sd-pad {
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .sd-key {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
