:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --pink: #ff4f9a;
  --gold: #ffc93c;
  --text: #fff;
  --muted: #aaadbe;
  --line: rgba(255, 255, 255, 0.08);
  font-family: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 800;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  border-bottom: 2px solid #0a0a14;
  font: inherit;
  font-size: 0.92em;
}

/* ---------- Layout ---------- */
.ss-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 14px;
  width: min(900px, 100%);
  margin: 0 auto;
  align-items: start;
}
.ss-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.ss-brand {
  font-size: 30px;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: #ffe16b;
  text-shadow:
    0 2px 0 #ff7a2f,
    0 4px 0 #c43b6c,
    0 8px 14px rgba(0, 0, 0, 0.4);
  padding: 4px 4px 8px;
}
.ss-brand span {
  display: block;
  color: #ff7ec2;
  text-shadow:
    0 2px 0 #c42e8a,
    0 4px 0 #6a1d7c,
    0 8px 14px rgba(0, 0, 0, 0.4);
  margin-left: 22px;
}
.ss-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  min-width: 0;
}
.ss-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ss-chip strong {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.ss-chip-level strong {
  color: #cfc4ff;
}
.ss-chip-moves {
  background: linear-gradient(180deg, #7a57ff, #5530e6);
  border-color: rgba(255, 255, 255, 0.18);
}
.ss-chip-moves .ss-label {
  color: #e5deff;
}
.ss-chip-moves strong {
  font-size: 34px;
}
.ss-chip-moves.is-low {
  background: linear-gradient(180deg, #ff5a7a, #d62a55);
  animation: ss-pulse 0.9s ease-in-out infinite;
}
.ss-chip.bump strong {
  animation: ss-bump 0.28s ease-out;
}
.ss-starbar {
  position: relative;
  height: 12px;
  margin-top: 8px;
  border-radius: 99px;
  background: #0e0f1a;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.5);
}
.ss-starbar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #ff8a3d, #ffd23c);
  box-shadow: 0 0 10px rgba(255, 196, 60, 0.6);
  transition: width 0.4s ease-out;
}
.ss-mark {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 17px;
  color: #3b3d52;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition:
    color 0.2s,
    transform 0.3s;
}
.ss-mark.on {
  color: var(--gold);
  transform: translate(-50%, -50%) scale(1.25);
}
.ss-goal {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 2px;
}
.ss-goal-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.ss-goal-item canvas,
.ss-goal-item .ss-jelly-icon {
  width: 30px;
  height: 30px;
  flex: none;
}
.ss-goal-item.done {
  color: #7dffa0;
}
.ss-jelly-icon {
  display: inline-block;
  border-radius: 9px;
  background: linear-gradient(160deg, #ff9ad5, #ff4fa7);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -3px 0 rgba(160, 20, 90, 0.4);
}
.ss-target-icon {
  font-size: 22px;
}
.ss-side-actions {
  display: flex;
  gap: 8px;
}
.ss-icon-btn {
  flex: 1;
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  background: #2a2b3d;
  box-shadow:
    0 4px 0 #15162a,
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition:
    transform 0.08s,
    background 0.15s;
}
.ss-icon-btn svg {
  width: 22px;
  height: 22px;
}
.ss-icon-btn:hover {
  background: #34364c;
}
.ss-icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #15162a;
}

/* ---------- Board ---------- */
.ss-stage {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.ss-board-wrap {
  position: relative;
  padding: 10px;
  border-radius: 26px;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(140, 110, 255, 0.28), transparent 60%),
    linear-gradient(180deg, #2a2346, #1b1830);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.08);
  max-width: 100%;
}
.ss-board-wrap.shake {
  animation: ss-shake 0.32s ease-in-out;
}
#board {
  display: block;
  touch-action: none;
  border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#board:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}
.ss-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.ss-combo {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 3;
  pointer-events: none;
  font-size: clamp(30px, 8vw, 56px);
  font-weight: 900;
  white-space: nowrap;
  color: #fff4a8;
  -webkit-text-stroke: 2px #a4185f;
  paint-order: stroke fill;
  text-shadow:
    0 3px 0 #ff5d9e,
    0 6px 0 #a4185f,
    0 12px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}
.ss-combo.show {
  animation: ss-combo 1.05s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
}

/* ---------- Overlays ---------- */
.ss-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 26px;
  background: rgba(12, 10, 28, 0.66);
  backdrop-filter: blur(3px);
  animation: ss-fade 0.25s ease-out;
  overflow: auto;
}
.ss-overlay[hidden] {
  display: none;
}
.ss-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(360px, 100%);
  padding: 22px 20px;
  border-radius: 26px;
  background: linear-gradient(180deg, #2b2c42, #1d1e2e);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  animation: ss-pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.ss-card h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.01em;
}
.ss-card p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}
.ss-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.88;
  font-size: clamp(44px, 12vw, 64px);
  font-weight: 900;
  letter-spacing: -0.02em;
}
.ss-logo span:first-child {
  color: #ffe16b;
  text-shadow:
    0 3px 0 #ff7a2f,
    0 6px 0 #c43b6c,
    0 12px 20px rgba(0, 0, 0, 0.5);
  transform: rotate(-4deg);
}
.ss-logo span:last-child {
  color: #ff7ec2;
  text-shadow:
    0 3px 0 #c42e8a,
    0 6px 0 #6a1d7c,
    0 12px 20px rgba(0, 0, 0, 0.5);
  transform: rotate(3deg) translateX(18px);
}
.ss-hero-candies {
  display: flex;
  gap: 4px;
  margin: 4px 0;
}
.ss-hero-candies canvas {
  width: 40px;
  height: 40px;
  animation: ss-bob 1.8s ease-in-out infinite;
}
.ss-hero-candies canvas:nth-child(2n) {
  animation-delay: -0.9s;
}
.ss-hero-candies canvas:nth-child(3n) {
  animation-delay: -0.5s;
}
.ss-btn {
  min-height: 46px;
  padding: 10px 26px;
  border: 0;
  border-radius: 99px;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 0.08s,
    filter 0.15s;
}
.ss-btn:hover {
  filter: brightness(1.1);
}
.ss-btn:active {
  transform: translateY(3px);
}
.ss-btn-primary {
  background: linear-gradient(180deg, #8466ff, var(--accent));
  box-shadow:
    0 5px 0 #3d20b8,
    0 10px 20px rgba(104, 66, 255, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}
.ss-btn-primary:active {
  box-shadow: 0 2px 0 #3d20b8;
}
.ss-btn-big {
  min-width: 200px;
  min-height: 56px;
  font-size: 22px;
}
.ss-btn-secondary {
  background: #2a2b3d;
  box-shadow:
    0 4px 0 #14152a,
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.ss-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.ss-intro-goal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 18px;
  background: #15162a;
  font-size: 17px;
  font-weight: 800;
}
.ss-intro-goal .ss-goal-item canvas,
.ss-intro-goal .ss-jelly-icon {
  width: 36px;
  height: 36px;
}
.ss-intro-moves {
  font-size: 16px !important;
  color: #cfc4ff !important;
}
.ss-win-stars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  font-size: 58px;
  line-height: 1;
}
.ss-win-stars b {
  color: #34364c;
  text-shadow: 0 3px 0 #16172a;
  transform: scale(0.8);
}
.ss-win-stars b:nth-child(2) {
  font-size: 72px;
}
.ss-win-stars b.on {
  color: var(--gold);
  text-shadow:
    0 3px 0 #d67f10,
    0 0 20px rgba(255, 201, 60, 0.7);
  animation: ss-star 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
.ss-win-score {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ss-win-score span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.ss-win-score strong {
  color: #fff;
  font-size: 36px;
  font-weight: 900;
}
.ss-win-best {
  font-size: 13px !important;
}

/* ---------- Map ---------- */
.ss-card-map {
  width: min(460px, 100%);
  height: 100%;
  max-height: 520px;
  padding: 16px;
}
.ss-map-head {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
}
.ss-map-head h2 {
  font-size: 24px;
}
.ss-map-stars {
  color: var(--gold);
  font-size: 16px;
  font-weight: 900;
}
.ss-map {
  list-style: none;
  margin: 0;
  padding: 12px 6px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px 8px;
  width: 100%;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
.ss-map li {
  display: flex;
  justify-content: center;
}
.ss-map li:nth-child(12n + 7),
.ss-map li:nth-child(12n + 8),
.ss-map li:nth-child(12n + 9),
.ss-map li:nth-child(12n + 10),
.ss-map li:nth-child(12n + 11),
.ss-map li:nth-child(12n + 12) {
  transform: translateX(8px);
}
.ss-level-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 58px;
  padding: 0 0 6px;
  border: 0;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(circle at 35% 28%, #ff9ccf, #ff4f9a 55%, #c21f6d);
  box-shadow:
    0 4px 0 #8a1450,
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(120, 10, 60, 0.6);
}
.ss-level-btn .ss-lstars {
  position: absolute;
  bottom: -6px;
  font-size: 12px;
  letter-spacing: -1px;
  color: #3b3d52;
  text-shadow: 0 1px 1px #000;
}
.ss-level-btn .ss-lstars .on {
  color: var(--gold);
}
.ss-level-btn.is-current {
  background: radial-gradient(circle at 35% 28%, #c9b8ff, #7c5cff 55%, #4a24d6);
  box-shadow:
    0 4px 0 #2e158f,
    0 0 0 3px rgba(255, 255, 255, 0.8),
    0 0 18px rgba(140, 110, 255, 0.8);
  animation: ss-bob 1.4s ease-in-out infinite;
}
.ss-level-btn:disabled {
  background: #2a2b3d;
  box-shadow: 0 4px 0 #14152a;
  color: #5d6078;
  cursor: not-allowed;
  text-shadow: none;
}
.ss-level-btn:disabled svg {
  width: 18px;
  height: 18px;
}

/* ---------- Animations ---------- */
@keyframes ss-fade {
  from {
    opacity: 0;
  }
}
@keyframes ss-pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}
@keyframes ss-bump {
  40% {
    transform: scale(1.3);
  }
}
@keyframes ss-pulse {
  50% {
    transform: scale(1.04);
  }
}
@keyframes ss-bob {
  50% {
    transform: translateY(-5px);
  }
}
@keyframes ss-star {
  from {
    transform: scale(0) rotate(-40deg);
  }
  to {
    transform: scale(1);
  }
}
@keyframes ss-shake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}
@keyframes ss-combo {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3) rotate(-8deg);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1) rotate(-3deg);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -60%) scale(1) rotate(-3deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -85%) scale(0.9) rotate(-3deg);
  }
}

/* ---------- Narrow screens: HUD on top ---------- */
@media (max-width: 719px) {
  body {
    padding: 8px;
  }
  .ss-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .ss-side {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 6px;
  }
  .ss-brand {
    display: none;
  }
  .ss-chip {
    padding: 6px 10px;
    border-radius: 14px;
  }
  .ss-chip strong {
    font-size: 19px;
  }
  .ss-chip-moves strong {
    font-size: 22px;
  }
  .ss-label {
    font-size: 9px;
  }
  .ss-starbar {
    height: 8px;
    margin-top: 5px;
  }
  .ss-mark {
    font-size: 13px;
  }
  .ss-chip-goal {
    grid-column: 1 / 3;
  }
  .ss-goal-item {
    font-size: 15px;
  }
  .ss-goal-item canvas,
  .ss-goal-item .ss-jelly-icon {
    width: 24px;
    height: 24px;
  }
  .ss-side-actions {
    grid-column: 3;
  }
  .ss-icon-btn {
    height: 44px;
  }
  .ss-board-wrap {
    padding: 6px;
    border-radius: 20px;
  }
  .ss-map {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px 4px;
  }
  .ss-map li {
    transform: none !important;
  }
  .ss-level-btn {
    width: 48px;
    height: 52px;
    font-size: 18px;
  }
  .ss-help {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
