/* Blocks. Each theme ("skin") sets the scene behind the canvas and the chrome
   colours; the blocks themselves are drawn by js/render.js from js/themes.js. */

body {
  --ink: #f4f0ff;
  --ink-muted: rgba(244, 240, 255, 0.62);
  --bar: rgba(20, 10, 48, 0.45);
  --bar-border: rgba(255, 255, 255, 0.1);
  --pop: #ff5fd2;
  overflow: hidden;
  position: fixed;
  inset: 0;
  color: var(--ink);
  background: #0d0724;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Scene (theme backgrounds) ---------- */

.scene {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
}
.blob {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  will-change: transform;
}
.b1 {
  left: -25vmax;
  top: -30vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.b2 {
  right: -30vmax;
  top: 10vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
.b3 {
  left: 10vmax;
  bottom: -40vmax;
  animation: drift3 38s ease-in-out infinite alternate;
}
@keyframes drift1 {
  to {
    transform: translate(18vmax, 12vmax) scale(1.15);
  }
}
@keyframes drift2 {
  to {
    transform: translate(-16vmax, 10vmax) scale(0.9);
  }
}
@keyframes drift3 {
  to {
    transform: translate(12vmax, -14vmax) scale(1.1);
  }
}
.floor,
.motes {
  position: absolute;
  inset: 0;
  display: none;
}

/* Neon: synthwave glow with a receding grid floor. */
body[data-skin='neon'] {
  background: radial-gradient(ellipse at 50% 110%, #3a0d5e 0%, #12072e 55%, #07031a 100%);
}
body[data-skin='neon'] .b1 {
  background: radial-gradient(circle, #ff2fb0 0%, transparent 65%);
}
body[data-skin='neon'] .b2 {
  background: radial-gradient(circle, #20e3ff 0%, transparent 65%);
  opacity: 0.35;
}
body[data-skin='neon'] .b3 {
  background: radial-gradient(circle, #7b2dff 0%, transparent 65%);
}
body[data-skin='neon'] .floor {
  display: block;
  top: 58%;
  inset-inline: -50%;
  bottom: -10%;
  background:
    linear-gradient(to bottom, #07031a 0%, transparent 35%),
    repeating-linear-gradient(90deg, rgba(255, 70, 220, 0.35) 0 2px, transparent 2px 70px),
    repeating-linear-gradient(0deg, rgba(255, 70, 220, 0.35) 0 2px, transparent 2px 60px);
  transform: perspective(300px) rotateX(62deg);
  mask-image: linear-gradient(transparent, #000 30%);
  -webkit-mask-image: linear-gradient(transparent, #000 30%);
  transform-origin: 50% 0;
  animation: grid-run 3s linear infinite;
  opacity: 0.55;
}
@keyframes grid-run {
  to {
    background-position: 0 0, 0 0, 0 60px;
  }
}

/* Glass: ribbons of light over a starry night. */
body[data-skin='glass'] {
  --ink: #eafcff;
  --ink-muted: rgba(234, 252, 255, 0.6);
  --bar: rgba(4, 20, 40, 0.45);
  --pop: #5ff5c8;
  background: linear-gradient(#020a18, #071a33 60%, #0b2440);
}
body[data-skin='glass'] .b1 {
  background: linear-gradient(120deg, transparent 30%, #1ee8a0 50%, transparent 70%);
  border-radius: 40%;
  opacity: 0.4;
  filter: blur(50px);
}
body[data-skin='glass'] .b2 {
  background: linear-gradient(60deg, transparent 30%, #7a4dff 50%, transparent 70%);
  border-radius: 40%;
  opacity: 0.35;
}
body[data-skin='glass'] .b3 {
  background: radial-gradient(circle, #1a6bff 0%, transparent 60%);
  opacity: 0.25;
}
body[data-skin='glass'] .motes {
  display: block;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 28% 42%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 47% 12%, #cfe, transparent),
    radial-gradient(1px 1px at 66% 30%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 82% 8%, #fff, transparent),
    radial-gradient(1px 1px at 90% 46%, #dff, transparent),
    radial-gradient(1px 1px at 8% 64%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 38% 72%, #fff, transparent),
    radial-gradient(1px 1px at 74% 66%, #fff, transparent);
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle {
  to {
    opacity: 0.4;
  }
}

/* Wood: a warm tabletop. */
body[data-skin='wood'] {
  --ink: #3b2412;
  --ink-muted: rgba(59, 36, 18, 0.6);
  --bar: rgba(255, 250, 240, 0.55);
  --bar-border: rgba(120, 70, 20, 0.12);
  --pop: #f06a1d;
  background: radial-gradient(ellipse at 50% 30%, #fbecd2 0%, #efd3a8 60%, #d9b27c 100%);
}
body[data-skin='wood'] .b1 {
  background: radial-gradient(circle, #ffd35a 0%, transparent 60%);
  opacity: 0.7;
}
body[data-skin='wood'] .b2 {
  background: radial-gradient(circle, #ff9fb7 0%, transparent 60%);
  opacity: 0.45;
}
body[data-skin='wood'] .b3 {
  background: radial-gradient(circle, #9fe3ff 0%, transparent 60%);
  opacity: 0.45;
}

/* Hallows: autumn night with a harvest glow. The moon, castle, candles,
   bats and leaves are drawn by core/hallows.js behind everything. */
body[data-skin='hallows'] {
  --ink: #f6ead0;
  --ink-muted: rgba(246, 234, 208, 0.62);
  --bar: rgba(22, 13, 40, 0.55);
  --bar-border: rgba(232, 176, 74, 0.22);
  --pop: #ffb347;
}
body[data-skin='hallows'] .title-main {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
}
body[data-skin='hallows'] .b1 {
  background: radial-gradient(circle, #ff8a1f 0%, transparent 60%);
  left: -30vmax;
  top: auto;
  bottom: -45vmax;
  opacity: 0.22;
}
body[data-skin='hallows'] .b2 {
  background: radial-gradient(circle, #7b3dff 0%, transparent 60%);
  opacity: 0.2;
}
body[data-skin='hallows'] .b3 {
  display: none;
}

/* Calm: quiet paper, nothing moves. */
body[data-skin='calm'] {
  --ink: #2a2723;
  --ink-muted: rgba(42, 39, 35, 0.6);
  --bar: rgba(250, 248, 242, 0.7);
  --bar-border: rgba(0, 0, 0, 0.08);
  --pop: #0072b2;
  background: linear-gradient(#f1eee6, #e6e1d5);
}
body[data-skin='calm'] .blob {
  display: none;
}

body.no-effects .blob,
body.no-effects .floor,
body.no-effects .motes {
  animation: none;
}

/* ---------- Layout ---------- */

#canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: var(--app-height);
  z-index: 1;
  touch-action: none;
}

.app {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  pointer-events: none;
}
.app > * {
  pointer-events: auto;
}
.app > .stage {
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 6px;
}
.title-btn {
  appearance: none;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 12px;
  color: var(--ink);
  min-width: 0;
}
.title-btn:focus-visible {
  outline: 2px solid var(--pop);
}
.title-main {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.title-sub {
  display: block;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}
.score {
  display: flex;
  gap: 8px;
}
.chip {
  min-width: 64px;
  text-align: center;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chip small {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}
.chip b {
  display: block;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.chip.bump b {
  animation: bump 0.25s ease;
}
.chip.over b,
.chip.ahead b {
  color: var(--pop);
}
.chip-wide {
  min-width: 96px;
}
@keyframes bump {
  40% {
    transform: scale(1.25);
  }
}

.challenge {
  margin: 2px auto 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  font-weight: 700;
  font-size: 0.85rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.stage {
  flex: 1;
  position: relative;
  min-height: 0;
}

.mixing {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink-muted);
}
.mixing[hidden] {
  display: none;
}
.mixing-dots {
  display: flex;
  gap: 6px;
}
.mixing-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pop);
  animation: dot 0.9s ease-in-out infinite;
}
.mixing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.mixing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes dot {
  50% {
    transform: translateY(-10px);
    opacity: 0.5;
  }
}

.toolbar {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 6px auto 10px;
  padding: 6px;
  border-radius: 22px;
  background: var(--bar);
  border: 1px solid var(--bar-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.tool {
  appearance: none;
  border: 0;
  background: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
  padding: 6px 8px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.tool:hover {
  background: rgba(255, 255, 255, 0.08);
}
.tool:active {
  transform: scale(0.94);
}
.tool[hidden] {
  display: none;
}
.tool:disabled {
  opacity: 0.35;
  cursor: default;
}
.tool:focus-visible {
  outline: 2px solid var(--pop);
}
.tool svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tool .badge {
  font-size: 0.62rem;
  color: var(--ink-muted);
}

@media (max-width: 360px) {
  .tool {
    min-width: 52px;
    padding-inline: 4px;
  }
  .chip {
    min-width: 54px;
    padding-inline: 8px;
  }
}

/* ---------- Menu ---------- */

.menu-list {
  display: grid;
  gap: 10px;
}
.menu-card {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.menu-card:active {
  transform: scale(0.98);
}
.menu-card:focus-visible {
  outline: 3px solid var(--accent);
}
.menu-card .menu-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.menu-card b {
  display: block;
  font-size: 1.05rem;
}
.menu-card small {
  color: var(--text-muted);
}
.menu-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.menu-row .btn {
  flex: 1;
  padding-inline: 0.8em;
  white-space: nowrap;
}

.level-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}
.level-picker input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.1rem;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

/* Theme cards */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.theme-card {
  position: relative;
}
.theme-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.theme-card .face {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 96px;
  padding: 10px;
  border-radius: 16px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease;
}
.theme-card .face b {
  font-size: 0.95rem;
}
.theme-card .face.dark b {
  color: #fff;
}
.theme-card .face.light b {
  color: #2a2014;
}
.theme-card .dots {
  display: flex;
  gap: 4px;
}
.theme-card .dots i {
  width: 14px;
  height: 22px;
  border-radius: 3px 3px 7px 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.theme-card input:checked + .face {
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
  transform: scale(1.02);
}
.theme-card input:focus-visible + .face {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}

.help p {
  margin: 0 0 10px;
}
.help ul {
  padding-left: 1.2em;
  margin: 0 0 10px;
}
