:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --line: #2f3148;
  --accent: #6842ff;
  --accent-hi: #8c6dff;
  --text: #fff;
  --muted: #aaadbe;
  --secondary: #2a2b3d;
  --danger: #ff4a5e;
  font-family:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px 12px 12px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
button {
  font: inherit;
}
:focus-visible {
  outline: 3px solid #b9a6ff;
  outline-offset: 2px;
}

.fd {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

/* ---------- top bar ---------- */
.fd-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fd-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: none;
}
.fd-logo {
  width: 38px;
  height: 38px;
  flex: none;
  filter: drop-shadow(0 3px 6px rgb(0 0 0 / 0.45));
}
.fd-brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.01em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff 25%, #ffd1a1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fd-hud {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #26273a, #1d1e2d);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.08),
    0 3px 10px rgb(0 0 0 / 0.3);
}
.chip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip strong {
  font-size: 1.12rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.chip-score {
  background: linear-gradient(180deg, #7a58ff, #5a36ec);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.25),
    0 4px 14px rgb(104 66 255 / 0.4);
}
.chip-score span {
  color: #e2dbff;
}
.chip-score strong.bump {
  animation: bump 0.28s ease-out;
}
@keyframes bump {
  40% {
    transform: scale(1.25);
  }
}
.chip-next {
  padding-right: 6px;
}
.chip-next canvas {
  width: 32px;
  height: 32px;
  display: block;
}
.fd-actions {
  display: flex;
  gap: 6px;
  flex: none;
}
.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.1),
    0 3px 0 #1a1b29;
  cursor: pointer;
  transition:
    transform 0.12s,
    background 0.12s;
}
.icon-btn:hover {
  background: #35374f;
}
.icon-btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.1);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
}
.icon-btn[aria-pressed="false"] .snd-on,
.icon-btn[aria-pressed="true"] .snd-off {
  display: none;
}
.icon-btn[aria-pressed="false"] {
  color: var(--muted);
}

/* ---------- play area ---------- */
.fd-play {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 10px;
  min-width: 0;
}
.fd-side-left {
  display: none;
}
.fd-side {
  min-width: 0;
  width: 100%;
}
.side-card {
  padding: 10px 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.06),
    0 6px 18px rgb(0 0 0 / 0.3);
}
.side-card h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.evo-card canvas {
  display: block;
  width: 100%;
  height: 34px;
}
.side-tips p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}
.side-tips b {
  display: block;
  color: #fff;
  font-weight: 900;
}

.fd-stage {
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: 24px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#game {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 24px;
  cursor: pointer;
  background:
    radial-gradient(120% 70% at 50% 0%, #2c2560 0%, transparent 60%),
    linear-gradient(180deg, #1f1f38, #171829);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.06),
    0 14px 40px rgb(0 0 0 / 0.45);
}
#game:focus-visible {
  outline-offset: 3px;
}
.fd-stage.shake {
  animation: shake 0.35s ease-out;
}
@keyframes shake {
  20% {
    transform: translate(-4px, 2px);
  }
  40% {
    transform: translate(4px, -2px);
  }
  60% {
    transform: translate(-3px, 1px);
  }
  80% {
    transform: translate(2px, 0);
  }
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 24px;
  background: rgb(12 12 26 / 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 0.25s ease-out;
}
.overlay[hidden] {
  display: none;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.overlay-card {
  width: min(320px, 100%);
  padding: 20px 18px 18px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #2a2b42, #1c1d2d);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.1),
    0 20px 50px rgb(0 0 0 / 0.55);
  animation: pop-in 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
}
.overlay-fruits canvas {
  display: block;
  width: 200px;
  height: 70px;
  margin: -4px auto 4px;
}
.overlay-card h2 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 900;
  line-height: 1.1;
  background: linear-gradient(180deg, #fff 30%, #ffd1a1);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay-card > p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}
.overlay-card .overlay-hint {
  margin: 12px 0 0;
  font-size: 0.78rem;
}
.overlay-kicker {
  margin: 0 0 2px !important;
  color: #ff8a9a !important;
  font-size: 1.05rem !important;
  font-weight: 900 !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
#over-score {
  font-size: 3rem;
  font-variant-numeric: tabular-nums;
}
.new-best {
  display: inline-block;
  margin: 4px 0 0 !important;
  padding: 3px 12px;
  border-radius: 999px;
  color: #3a2600 !important;
  background: linear-gradient(180deg, #ffe07a, #ffb52e);
  font-weight: 900 !important;
  animation: pop-in 0.4s 0.15s both cubic-bezier(0.2, 1.6, 0.4, 1);
}
.new-best[hidden] {
  display: none;
}
.over-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 14px 0 16px;
}
.over-stats div {
  display: grid;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 14px;
  background: rgb(255 255 255 / 0.05);
}
.over-stats span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.over-stats strong {
  font-size: 1.1rem;
  font-weight: 900;
}
.biggest {
  display: grid;
  justify-items: center;
}
.biggest canvas {
  width: 24px;
  height: 24px;
}
.biggest em {
  font-style: normal;
  font-size: 0.72rem;
  text-transform: capitalize;
}

.pill {
  min-height: 48px;
  padding: 0 34px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.12s;
}
.pill-primary {
  background: linear-gradient(180deg, #8166ff, var(--accent));
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.25),
    0 5px 0 #4424c4,
    0 10px 24px rgb(104 66 255 / 0.45);
}
.pill-primary:hover {
  transform: translateY(-1px);
}
.pill-primary:active {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgb(255 255 255 / 0.25),
    0 1px 0 #4424c4;
}

/* ---------- wide layout ---------- */
@media (min-width: 760px) {
  .fd-play {
    grid-template-columns: 150px auto 150px;
    align-items: start;
    justify-content: center;
    gap: 14px;
  }
  .fd-side-left {
    display: grid;
    gap: 10px;
  }
  .fd-side-left canvas {
    display: block;
    width: 96px;
    height: 96px;
    margin: 0 auto;
  }
  .evo-card canvas {
    height: auto;
    aspect-ratio: 1;
  }
  .fd-stage {
    width: auto;
  }
}
@media (max-width: 480px) {
  body {
    padding: 8px;
  }
  .fd-top {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .fd-brand h1 {
    font-size: 1.15rem;
  }
  .fd-logo {
    width: 32px;
    height: 32px;
  }
  .fd-hud {
    order: 3;
    flex-basis: 100%;
  }
  .fd-actions {
    margin-left: auto;
  }
  .chip {
    flex: 1;
    justify-content: center;
    padding: 0 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
.pill:disabled {
  opacity: 0.6;
  cursor: progress;
}
