@font-face {
  font-family: "Sora";
  src: url("fonts/sora.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #1a1030;
  --dusk: #3a1f4f;
  --plum: #6a2c62;
  --text: #fbf4f8;
  --muted: #cdbdd2;
  --petal: #ffb0cf;
  --petal-soft: #ffd3e4;
  --glass: rgba(255, 255, 255, 0.07);
  --edge: rgba(255, 255, 255, 0.14);
  --bad: #ffb4a6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--text);
  font: 300 16px/1.6 "Sora", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

a { color: var(--petal-soft); text-underline-offset: 3px; }
code { font: inherit; font-weight: 500; color: var(--petal-soft); }

#sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60vmax 44vmax at 84% 8%, rgba(255, 150, 196, 0.34), transparent 70%),
    radial-gradient(70vmax 50vmax at 8% 100%, rgba(120, 72, 190, 0.32), transparent 72%),
    linear-gradient(165deg, var(--night) 12%, var(--dusk) 62%, var(--plum) 118%);
}

#petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 48px clamp(16px, 8vw, 128px);
}

#kanji {
  position: fixed;
  right: clamp(16px, 6vw, 96px);
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  font-size: clamp(30px, 6.4vh, 60px);
  font-weight: 200;
  letter-spacing: 0.32em;
  writing-mode: vertical-rl;
  white-space: nowrap;
  color: var(--petal-soft);
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

h1 {
  margin: 0;
  max-width: 11ch;
  font-size: clamp(46px, 8.6vw, 112px);
  line-height: 1.02;
  font-weight: 200;
  letter-spacing: -0.045em;
  background: linear-gradient(100deg, #fff 30%, var(--petal-soft) 72%, var(--petal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede { margin: 22px 0 30px; max-width: 34rem; font-size: clamp(17px, 2vw, 20px); line-height: 1.5; }

.panel {
  max-width: 34rem;
  padding: 22px 24px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--edge);
  backdrop-filter: blur(16px) saturate(130%);
}

.note { margin: 0; font-size: 14px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 0; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

button:focus-visible, a:focus-visible, #screen:focus-visible {
  outline: 2px solid var(--petal-soft);
  outline-offset: 3px;
}

.primary {
  padding: 12px 26px;
  border-radius: 999px;
  background: linear-gradient(120deg, var(--petal-soft), var(--petal));
  color: #2a1230;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(255, 150, 196, 0.32);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 34px rgba(255, 150, 196, 0.5); }
.primary:active { transform: translateY(0) scale(0.985); }

.secondary {
  padding: 12px 18px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  transition: background 0.14s ease, color 0.14s ease;
}

.secondary:hover { color: var(--text); background: var(--glass); }

#status { min-height: 1.5em; margin: 12px 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
#status:empty { display: none; }
#status.bad { color: var(--bad); }

.by { margin: 26px 0 0; font-size: 13px; color: var(--muted); }

#stage { position: fixed; inset: 0; background: #000; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline-offset: -2px; }

#bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 4px;
  border-radius: 999px;
  background: rgba(32, 18, 48, 0.72);
  border: 1px solid var(--edge);
  backdrop-filter: blur(16px) saturate(130%);
  font-size: 13px;
  transition: opacity 0.22s ease;
}

#stage.idle #bar { opacity: 0; pointer-events: none; }
#stage.idle { cursor: none; }

#bar button { padding: 6px 13px; border-radius: 999px; color: var(--muted); white-space: nowrap; transition: background 0.14s ease, color 0.14s ease; }
#bar button:hover, #bar button[aria-expanded="true"] { color: var(--text); background: rgba(255, 255, 255, 0.12); }

#controls {
  position: absolute;
  inset: 12px;
  max-width: 62rem;
  margin: auto;
  overflow: auto;
  padding: 22px 26px;
  border-radius: 22px;
  background: rgba(30, 18, 46, 0.94);
  border: 1px solid var(--edge);
  backdrop-filter: blur(20px) saturate(130%);
  font-size: 13px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

#stage:has(#controls:not([hidden])) #bar { display: none; }

#controls header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#controls h2 { margin: 0; font-size: 24px; font-weight: 200; letter-spacing: -0.02em; }
#controls .close { padding: 7px 18px; border-radius: 999px; background: linear-gradient(120deg, var(--petal-soft), var(--petal)); color: #2a1230; font-weight: 500; }
#controls .pads { margin: 10px 0 18px; color: var(--muted); }
#controls .padline { margin: 0; overflow-wrap: anywhere; }
#controls .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 22px 30px; align-items: start; }
#controls .row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 6px; padding: 2px 6px; border-radius: 8px; }
#controls .row.head { font-weight: 500; color: var(--petal-soft); padding-bottom: 6px; }
#controls .row.live { background: rgba(255, 176, 207, 0.2); }
#controls .bind { padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.07); color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
#controls .bind:hover { background: rgba(255, 255, 255, 0.16); }
#controls .bind.unset { color: var(--muted); }
#controls .bind.listening { background: var(--petal); color: #2a1230; }
#controls .stick { display: flex; align-items: center; gap: 8px; margin: 8px 6px 0; color: var(--muted); }
#controls .stick input { accent-color: var(--petal); }
#controls footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
#controls footer .grow { flex: 1; }
#controls footer button { padding: 6px 13px; border-radius: 999px; color: var(--muted); }
#controls footer button:hover { color: var(--text); background: rgba(255, 255, 255, 0.12); }
#controlsnote { min-height: 1.4em; }
#controlsnote.bad { color: var(--bad); }

@media (max-width: 720px) {
  #kanji { display: none; }
  #bar { font-size: 12px; }
  #bar button { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
