:root {
  --night: #0b1220;
  --night-2: #101b2e;
  --ink: #cddff0;
  --ink-dim: #7f97b3;
  --dew: #a6d3ec;
  --moss: #3a574c;
  --wood: #c9a878;
  --flower: #dcc0d6;
  --line: #33507a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(6px, env(safe-area-inset-top)) 12px calc(6px + env(safe-area-inset-bottom));
}

button { font-family: inherit; -webkit-user-select: none; user-select: none; }
button, .flowers i { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--dew); outline-offset: 3px; }

/* ---------------------------------------------------------------- hud */

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 2px 2px 6px;
}

.label {
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}

.counter { flex: 1 1 auto; text-align: center; font-size: 16px; color: var(--ink); }

.sound, .ctl {
  min-height: 44px;
  border-radius: 22px;
  border: 1px solid #2c435f;
  background: #16233a;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

.sound { min-width: 44px; padding: 0 14px; }
.sound[aria-pressed="true"] { background: #1d3348; border-color: #4b7ea3; color: var(--dew); }

/* -------------------------------------------------------------- stage */

.stage {
  position: relative;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #0a111d;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: pixelated;
}

.banner {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 8px;
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 1.3;
  color: var(--dew);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
.banner.show { opacity: 1; }

.hint {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  text-shadow: 0 1px 3px rgba(6, 10, 18, 0.85);
  transition: opacity 0.7s ease;
}
.hint.faded { opacity: 0.5; }

/* start screen */

.start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  background: rgba(9, 15, 26, 0.76);
}
.start[hidden] { display: none; }

.start-card { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 320px; }

.title {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dew);
}

.lede { margin: 0; font-size: 16px; line-height: 1.45; color: var(--ink); }
.sub { margin: 0; font-size: 14px; color: var(--ink-dim); }

.begin {
  margin-top: 6px;
  min-height: 48px;
  min-width: 168px;
  border-radius: 24px;
  border: 1px solid #4b7ea3;
  background: #17263c;
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
}
.begin:active { background: #1f3550; }

/* --------------------------------------------------------------- dock */

.dock { display: flex; flex-direction: column; gap: 8px; padding: 8px 2px 0; }

.flowers {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: min(100%, 340px);
  margin: 0 auto;
}

.flowers i { position: relative; height: 44px; cursor: pointer; }

.flowers i::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #1d2b42;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background 0.55s ease, box-shadow 0.55s ease, transform 0.55s ease;
}
.flowers i.on::before {
  background: radial-gradient(circle at 38% 36%, #f7fbff, var(--flower));
  box-shadow: 0 0 7px rgba(220, 192, 214, 0.55);
}
.flowers i.now::before {
  background: radial-gradient(circle at 38% 36%, #f7fbff, var(--dew));
  box-shadow: 0 0 7px rgba(166, 211, 236, 0.6);
  transform: scale(1.18);
}

.controls { display: flex; gap: 10px; justify-content: center; }
.ctl { flex: 1 1 0; max-width: 170px; font-size: 16px; }
.ctl:active { background: #1d2d47; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-dim);
  min-height: 18px;
}
.key { display: inline-flex; align-items: center; gap: 6px; }
.key[hidden] { display: none; }

.sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.sw-dew { background: var(--dew); }
.sw-moss { background: var(--moss); }
.sw-deep { background: #17434f; }
.sw-current { background: #2a5f66; }

@media (max-height: 680px) { .legend { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
