:root {
  color-scheme: dark;
  background: #11181c;
  color: #f4efea;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --ink: #f4efea;
  --muted: #b9c5be;
  --line: #344541;
  --accent: #e1f1bc;
  --panel: #182321;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid #f4efa5; outline-offset: 4px; }
[hidden] { display: none !important; }

.site-header { border-bottom: 1px solid #2b3a3b; }
.header-inner, main { width: min(100% - 64px, 1250px); margin-inline: auto; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; font-size: 21px; font-weight: 800; letter-spacing: -.055em; text-decoration: none; }
.brand span { display: inline-block; width: 20px; aspect-ratio: 1; margin-right: 9px; border-radius: 50% 50% 50% 4px; transform: rotate(-12deg); background: #edab93; }
.brand b { color: #edab93; }
.header-divider { width: 1px; height: 17px; background: #4c5c57; }
.app-name { color: var(--muted); font-size: 14px; }

main { padding-block: 33px 40px; }
.intro { margin-bottom: 23px; }
.intro h1 { margin: 0; font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.15; font-weight: 750; letter-spacing: -.08em; }
.intro p { margin: 9px 0 0; color: var(--muted); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 245px; gap: 16px; align-items: start; }
.garden, .controls { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.garden { min-width: 0; }
.stage { position: relative; }
.field {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: block;
  width: 100%;
  min-height: 405px;
  aspect-ratio: 1.72;
  padding: 0;
  border: 0;
  border-radius: 15px 15px 0 0;
  background:
    radial-gradient(ellipse at 13% 105%, #53733a83, transparent 48%),
    radial-gradient(ellipse at 78% 41%, #244b4270, transparent 53%),
    radial-gradient(ellipse at 42% -15%, #323b5eac, transparent 66%),
    linear-gradient(167deg, #131a2c 11%, #19312f 70%, #263b2d 100%);
  cursor: crosshair;
  touch-action: manipulation;
}
.field:focus-visible { outline-offset: -5px; }
.haze, .guide-grid, .seed-bed, .blooms { position: absolute; inset: 0; pointer-events: none; }
.haze {
  opacity: .7;
  background:
    radial-gradient(ellipse at 89% 16%, #a1c7b524, transparent 25%),
    radial-gradient(ellipse at 51% 72%, #f3d58b19, transparent 30%),
    radial-gradient(ellipse at 13% 44%, #9c8cb831, transparent 30%);
}
.guide-grid {
  opacity: .65;
  background-image:
    radial-gradient(circle at center, #d7ebe232 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(100% - 1px), #e4f7e112 calc(100% - 1px));
  background-size: 24px 24px, 100% calc(100% / 8);
  mask-image: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}
.pitch-axis {
  position: absolute;
  top: 17px;
  bottom: 17px;
  left: 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 9px;
  color: #d6e4d4;
  font-size: .72rem;
  pointer-events: none;
}
.axis-line { width: 1px; height: 100%; background: linear-gradient(#e0efdfa0, #cce0c021 78%, #dfedd478); }
.first-note { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 11px; pointer-events: none; }
.first-note > span:last-child { padding: 6px 12px; color: #f4f4de; border-radius: 8px; background: #192822dc; font-size: clamp(.84rem, 2.2vw, .98rem); }
.first-note-mark { display: grid; width: 44px; height: 44px; place-items: center; color: #f5f1ca; border: 1px solid #b4d6a478; border-radius: 50%; background: #cfe68d14; font-size: 18px; }
.key-cursor { display: none; position: absolute; width: 29px; height: 29px; border: 1px dashed #faf2bc; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.field:focus-visible .key-cursor { display: block; }
.garden-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 53px; padding: 8px 16px; }
.garden-footer p { margin: 0; font-size: .83rem; color: var(--muted); }
#note-count { flex: 0 0 auto; color: #d8e7c3; font-variant-numeric: tabular-nums; font-size: .8rem; }

.controls { padding: 18px; }
.control-group + .control-group { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 18px; }
.control-group h2 { margin: 0 0 10px; font-size: .95rem; letter-spacing: -.025em; }
.flower-options, .playback-actions { display: grid; gap: 7px; }
.flower-option {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 7px 10px;
  text-align: left;
  border: 1px solid #41554d;
  border-radius: 8px;
  background: #21302b;
  font-size: .89rem;
}
.flower-option:hover { background: #2b3c34; }
.flower-option[aria-pressed="true"] { border-color: #a6c792; background: #34473a; }
.flower-swatch { position: relative; flex: 0 0 27px; aspect-ratio: 1; border-radius: 6px; background: #141e1b; }
.flower-swatch::before { content: ''; position: absolute; inset: 5px; background: var(--swatch); clip-path: var(--petal-shape); }
[data-kind="camellia"] .flower-swatch { --swatch: #f29fae; --petal-shape: polygon(50% 0, 65% 19%, 90% 13%, 87% 39%, 100% 58%, 76% 68%, 72% 94%, 49% 82%, 26% 94%, 23% 68%, 0 58%, 13% 39%, 10% 13%, 35% 19%); }
[data-kind="aster"] .flower-swatch { --swatch: #c4aaf6; --petal-shape: polygon(50% 0, 60% 37%, 95% 15%, 71% 46%, 100% 63%, 66% 63%, 67% 100%, 50% 72%, 33% 100%, 34% 63%, 0 63%, 29% 46%, 5% 15%, 40% 37%); }
[data-kind="primrose"] .flower-swatch { --swatch: #f6d888; --petal-shape: circle(45%); }
.loop-button, .reset-button { min-height: 45px; padding: 6px 10px; border: 1px solid transparent; border-radius: 8px; font-size: .9rem; font-weight: 700; }
.loop-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; color: #17251d; background: var(--accent); }
.loop-button:not(:disabled):hover { background: #f2fccf; }
.loop-button:disabled { color: #aab8aa; background: #2d3e35; }
.play-icon { display: inline-block; width: 11px; height: 12px; background: currentColor; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.loop-button[aria-pressed="true"] .play-icon { clip-path: none; width: 9px; height: 9px; border-radius: 1px; }
.reset-button { border-color: #41554d; background: transparent; font-weight: 600; }
.reset-button:not(:disabled):hover { background: #2b3c34; }
.reset-button:disabled { color: #86968c; }
.status { margin: 12px 0 0; color: #f1d09e; font-size: .79rem; }
.status:empty { display: none; }

.bloom {
  position: absolute;
  width: clamp(31px, calc(54px * var(--bloom-size)), 80px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 0 9px color-mix(in srgb, var(--color), transparent 62%));
}
.bloom-head { position: absolute; inset: 0; display: block; }
.petal {
  position: absolute;
  left: 32%;
  top: 4%;
  width: 36%;
  height: 48%;
  transform-origin: 50% 96%;
  transform: rotate(var(--angle));
  border-radius: 61% 58% 49% 51%;
  background: radial-gradient(ellipse at 43% 22%, var(--highlight), var(--color) 55%, var(--shade) 99%);
  box-shadow: inset 0 1px 1px #ffffff34;
}
.bloom-heart {
  position: absolute;
  inset: 40%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 29%, #fff7be 14%, var(--highlight) 46%, var(--shade) 91%);
  box-shadow: 0 0 4px var(--highlight);
}
.bloom.aster .petal { top: 0; left: 41%; width: 18%; height: 51%; border-radius: 72% 72% 40% 40%; }
.bloom.primrose .petal { top: 11%; left: 28%; width: 44%; height: 42%; border-radius: 62% 72% 54% 47%; }
.bloom.primrose .bloom-heart { inset: 38%; }
.bloom.primrose:not(.sample-bloom)::before {
  content: '';
  position: absolute;
  inset: 14%;
  border: 1px solid var(--highlight);
  border-radius: 50%;
  animation: ripple 720ms ease-out both;
}
.bloom.camellia:not(.sample-bloom) .bloom-head { animation: open 510ms cubic-bezier(.16, 1.56, .48, 1) both; }
.bloom.aster:not(.sample-bloom) .bloom-head { animation: whirl 690ms cubic-bezier(.16, .86, .26, 1) both; }
.bloom.primrose:not(.sample-bloom) .bloom-head { animation: unfold 660ms cubic-bezier(.17, .93, .4, 1.1) both; }
.sample-bloom { opacity: .44; }
.replayed { z-index: 2; }
.bloom.fresh { z-index: 1; }
@keyframes open { from { opacity: 0; transform: scale(.08); } 45% { opacity: 1; } to { transform: scale(1); } }
@keyframes whirl { from { opacity: 0; transform: rotate(-100deg) scale(.15); } 60% { opacity: 1; } to { transform: rotate(0) scale(1); } }
@keyframes unfold { from { opacity: 0; transform: scale(.35, .04); } 50% { opacity: 1; } to { transform: scale(1); } }
@keyframes ripple { from { opacity: .7; transform: scale(.45); } to { opacity: 0; transform: scale(2.7); } }

@media (max-width: 760px) {
  .header-inner, main { width: calc(100% - 32px); }
  .header-inner { min-height: 55px; gap: 11px; }
  main { padding-top: 24px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .field { aspect-ratio: 1.35; min-height: 305px; }
  .controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
  .control-group + .control-group { border: 0; padding: 0; margin: 0; }
  .status { grid-column: 1 / -1; margin: 0; }
  .pitch-axis { left: 10px; }
}
@media (pointer: coarse), (max-width: 460px) {
  .keyboard-help { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bloom:not(.sample-bloom) .bloom-head, .bloom.primrose:not(.sample-bloom)::before { animation: none; }
  .bloom.primrose:not(.sample-bloom)::before { display: none; }
}
