:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0b0b12;
  --panel: #16161f;
  --glass: rgb(28 28 40 / 0.62);
  --glass-hi: rgb(255 255 255 / 0.06);
  --stroke: rgb(255 255 255 / 0.1);
  --stroke-strong: rgb(255 255 255 / 0.18);

  /* piano roll */
  --line: #20202b;
  --line-beat: #2b2b38;
  --line-bar: #3d3d4f;
  --row-white: #191922;
  --row-black: #121219;

  /* notes: each state also has a non-color cue (see roll.css) */
  --note: #63e6be;        /* yours to move */
  --note-sel: #ffd60a;    /* selected */
  --locked: #7d7aff;      /* given / hinted */
  --note-win: #ffd60a;
  --ghost: #ffffff22;
  --playhead: #ff375f;

  /* brand */
  --accent: #bf5af2;
  --accent-text: #d4a5ff;
  --brand: linear-gradient(135deg, #ff375f 0%, #bf5af2 55%, #5e5ce6 100%);
  --brand-btn: linear-gradient(135deg, #d6246e 0%, #7c3aed 100%);

  /* text */
  --text: #f2f2f7;
  --muted: #9a9aae;

  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0; min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% -8%, rgb(255 55 95 / 0.20), transparent 60%),
    radial-gradient(800px 520px at 92% -4%, rgb(94 92 230 / 0.24), transparent 60%),
    radial-gradient(1000px 600px at 50% 110%, rgb(191 90 242 / 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 16px 48px;
}

/* --- header ------------------------------------------------------------------ */
.brand { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; }
.brand img {
  width: 44px; height: 44px; border-radius: 11px;
  box-shadow: 0 6px 20px rgb(191 90 242 / 0.45), 0 0 0 1px rgb(255 255 255 / 0.12) inset;
}
h1 {
  font: 800 30px/1.1 var(--font-round); margin: 0; letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 0%, #ffd1e0 45%, #d9c8ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub { color: var(--muted); margin: 0 0 22px; text-align: center; max-width: 640px; }
a { color: var(--accent-text); text-decoration: none; font-weight: 600; border-radius: 4px; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.sub a { white-space: nowrap; }

/* --- controls ------------------------------------------------------------------ */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; justify-content: center; }

button {
  min-height: 40px; padding: 0 16px;
  background: var(--glass-hi); color: var(--text);
  border: 1px solid var(--stroke); border-radius: 12px;
  font: 600 14px/1 var(--font); cursor: pointer;
  transition: transform 160ms var(--spring), background-color 160ms, border-color 160ms, box-shadow 160ms;
}
button:hover:not(:disabled) { background: rgb(255 255 255 / 0.11); border-color: var(--stroke-strong); }
button:active:not(:disabled) { transform: scale(0.96); }
button:disabled { opacity: 0.38; cursor: not-allowed; }
button.primary {
  background: var(--brand-btn); color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgb(191 90 242 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.25);
}
button.primary:hover:not(:disabled) { background: var(--brand-btn); filter: brightness(1.1); border-color: transparent; }

:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }

.counter { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; padding: 0 6px; }
label { color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; user-select: none; font-weight: 500; }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

input[type=text], input[type=number], input[type=search] {
  min-height: 40px; padding: 8px 12px;
  background: rgb(0 0 0 / 0.3); color: var(--text);
  border: 1px solid var(--stroke); border-radius: 10px;
  font: 15px var(--font);
  transition: border-color 160ms, box-shadow 160ms;
}
input[type=text]:focus, input[type=number]:focus, input[type=search]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgb(191 90 242 / 0.25);
}

/* a frosted panel, for toolbars and cards */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--stroke);
  box-shadow: 0 20px 50px rgb(0 0 0 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.06);
}

/* --- confetti (see confetti.js) -------------------------------------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 3px;
  animation: confetti-fall var(--d, 1.8s) cubic-bezier(0.2, 0.6, 0.4, 1) var(--delay, 0s) forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--x, 0), 105vh) rotate(var(--r, 540deg)); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .confetti { display: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .glass { background: var(--panel); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
