
:root {
  color-scheme: dark;
  --bg: #120d20;
  --panel: rgba(31, 23, 52, 0.9);
  --panel-2: rgba(45, 33, 72, 0.94);
  --text: #fffafc;
  --muted: #c9c0da;
  --pink: #ff4fc8;
  --purple: #8f6cff;
  --cyan: #34e6ff;
  --yellow: #ffe45e;
  --danger: #ff5b75;
  --radius: 24px;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 10% 10%, rgba(255,79,200,.18), transparent 30%),
    radial-gradient(circle at 85% 20%, rgba(52,230,255,.16), transparent 35%),
    linear-gradient(160deg, #171128, #0d0918 70%);
  color: var(--text);
  overflow: hidden;
}

button, input {
  font: inherit;
}

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

.app-shell {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 10px;
}

.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(24, 17, 41, .74);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-star {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 27px;
  background: linear-gradient(135deg, var(--pink), var(--purple), var(--cyan));
  box-shadow: 0 0 30px rgba(143,108,255,.55);
}

h1 {
  font-size: clamp(1.12rem, 2.6vw, 1.75rem);
  line-height: 1;
  margin: 0 0 5px;
}

.brand p {
  color: var(--muted);
  margin: 0;
  font-size: .88rem;
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  font-size: 23px;
  background: rgba(255,255,255,.08);
}

.workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.12);
  background:
    radial-gradient(circle at 50% 45%, rgba(66,38,98,.34), transparent 42%),
    #06040c;
  box-shadow: inset 0 0 60px rgba(52,230,255,.04), 0 18px 40px rgba(0,0,0,.25);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.start-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  color: rgba(255,255,255,.78);
  transition: opacity .25s ease;
}

.start-hint span {
  font-size: clamp(50px, 8vw, 90px);
  filter: drop-shadow(0 0 18px rgba(255,79,200,.75));
}

.start-hint strong {
  font-size: clamp(25px, 4vw, 46px);
}

.start-hint.hidden {
  opacity: 0;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 20px);
  background: rgba(255,255,255,.94);
  color: #2a1d3e;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 3;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.controls {
  min-height: 0;
  overflow-y: auto;
  border-radius: var(--radius);
  padding: 13px;
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.11);
  scrollbar-width: thin;
}

.control-group + .control-group {
  margin-top: 15px;
}

.control-group h2 {
  font-size: 1rem;
  margin: 0 0 8px;
  color: #f4ecff;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.choice {
  min-height: 68px;
  padding: 8px 5px;
  border-radius: 17px;
  background: rgba(255,255,255,.07);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-weight: 800;
  font-size: .72rem;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}

.choice > span:first-child:not(.swatch) {
  font-size: 24px;
}

.choice:active,
.action-button:active {
  transform: scale(.94);
}

.choice.active {
  background: rgba(143,108,255,.24);
  border-color: rgba(255,255,255,.82);
  box-shadow: 0 0 18px rgba(143,108,255,.25);
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.75);
}

.swatch.rainbow {
  background: conic-gradient(#ff4fc8, #ffe45e, #34e6ff, #8f6cff, #ff4fc8);
}

.swatch.pink { background: #ff4fc8; }
.swatch.purple { background: #8f6cff; }
.swatch.cyan { background: #34e6ff; }
.swatch.yellow { background: #ffe45e; }
.swatch.surprise {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff5b75, #ffe45e, #34e6ff, #8f6cff);
  color: white;
  font-weight: 900;
}

.slider-group {
  margin: 15px 0;
  padding: 12px;
  border-radius: 17px;
  background: rgba(255,255,255,.055);
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  margin-bottom: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--pink);
}


.replay-panel {
  margin: 15px 0 10px;
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,79,200,.12), rgba(52,230,255,.09));
  border: 1px solid rgba(255,255,255,.09);
}

.replay-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.replay-heading strong {
  font-size: .95rem;
}

.mini-toggle {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  font-size: .72rem;
  font-weight: 900;
}

.mini-toggle.active {
  background: linear-gradient(135deg, rgba(255,79,200,.7), rgba(143,108,255,.72));
  box-shadow: 0 0 18px rgba(255,79,200,.2);
}

.speed-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.speed-choice {
  min-height: 42px;
  padding: 7px 4px;
  border-radius: 13px;
  background: rgba(255,255,255,.07);
  border: 2px solid transparent;
  font-size: .68rem;
  font-weight: 900;
}

.speed-choice.active {
  border-color: rgba(255,255,255,.8);
  background: rgba(143,108,255,.26);
}

.action-button.replay {
  background: linear-gradient(135deg, rgba(52,230,255,.42), rgba(143,108,255,.7), rgba(255,79,200,.58));
}

.magic-particle {
  position: absolute;
  width: 9px;
  height: 9px;
  pointer-events: none;
  z-index: 4;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 8px currentColor, 0 0 14px currentColor;
  animation: magicParticle .5s ease-out forwards;
}

@keyframes magicParticle {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.15) rotate(150deg);
  }
}

.confetti-piece {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 16px;
  border-radius: 4px;
  pointer-events: none;
  z-index: 5;
  animation: confettiFall var(--duration) cubic-bezier(.18,.7,.28,1) forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift), calc(100vh + 70px)) rotate(var(--spin));
  }
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding-bottom: 3px;
}

.action-button {
  min-height: 68px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.085);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 900;
  font-size: .76rem;
}

.action-button > span:first-child {
  font-size: 25px;
}

.action-button.save {
  background: linear-gradient(135deg, rgba(255,79,200,.75), rgba(143,108,255,.78));
}

.action-button.danger {
  background: rgba(255,91,117,.17);
}

.action-button.holding {
  animation: pulseHold .55s linear infinite alternate;
}

@keyframes pulseHold {
  to { transform: scale(.92); background: rgba(255,91,117,.5); }
}

@media (max-width: 850px) {
  body { overflow: auto; }
  .app-shell { min-height: 100dvh; height: auto; }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(54dvh, 1fr) auto;
  }
  .canvas-wrap {
    min-height: 54dvh;
  }
  .controls {
    overflow: visible;
  }
  .choice-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 520px) {
  .app-shell { padding: 6px; gap: 6px; }
  .topbar { min-height: 58px; border-radius: 17px; }
  .brand-star { width: 39px; height: 39px; font-size: 23px; }
  .brand p { display: none; }
  .icon-button { width: 42px; height: 42px; }
  .workspace { gap: 6px; grid-template-rows: 52dvh auto; }
  .canvas-wrap, .controls { border-radius: 18px; }
  .controls { padding: 10px; }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .choice { min-height: 62px; }
}


/* Prevent accidental text highlighting on touch devices */
html,
body,
button,
label,
span,
strong,
h1,
h2,
p,
div {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
