:root {
  color-scheme: dark;
  --ink: #f3f5f2;
  --muted: rgba(235, 241, 238, 0.54);
  --faint: rgba(235, 241, 238, 0.16);
  --glass: rgba(12, 13, 24, 0.64);
  --glow: #c7fff0;
  --sky-1: #070811;
  --sky-2: #111126;
  --sky-3: #0a1520;
  --aurora-1: rgba(72, 128, 123, 0.18);
  --aurora-2: rgba(90, 76, 145, 0.14);
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  font-family: "Inter Variable", Inter, "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 115%, var(--sky-3), transparent 46%),
    linear-gradient(148deg, var(--sky-1), var(--sky-2));
  transition: background 1.2s ease;
}

body[data-atmosphere="tide"] {
  --glow: #b9ffea;
  --sky-1: #030d13;
  --sky-2: #08212a;
  --sky-3: #0d3740;
  --aurora-1: rgba(68, 205, 179, 0.19);
  --aurora-2: rgba(71, 114, 179, 0.14);
}

body[data-atmosphere="ember"] {
  --glow: #ffd9a3;
  --sky-1: #100809;
  --sky-2: #261113;
  --sky-3: #3b2019;
  --aurora-1: rgba(233, 138, 91, 0.18);
  --aurora-2: rgba(160, 67, 96, 0.15);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
}

.aurora {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 22% 35%, var(--aurora-1), transparent 33%),
    radial-gradient(ellipse at 82% 42%, var(--aurora-2), transparent 29%);
  filter: blur(40px);
  opacity: 0.9;
  animation: breathe 12s ease-in-out infinite alternate;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#sky.is-dragging {
  cursor: grabbing;
}

.masthead {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
  padding: 28px 34px;
  pointer-events: none;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-decoration: none;
  pointer-events: auto;
}

.wordmark__spark {
  width: 9px;
  height: 9px;
  background: var(--glow);
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  filter: drop-shadow(0 0 5px var(--glow));
}

.masthead p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.1em;
}

.welcome {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: min(680px, calc(100vw - 48px));
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -57%);
  transition: opacity 1s ease, transform 1s ease, filter 1s ease;
}

.welcome.is-hidden {
  opacity: 0;
  filter: blur(10px);
  transform: translate(-50%, -60%);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--glow);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.26em;
  transition: color 1s ease;
}

.welcome h1 {
  margin: 0;
  font-size: clamp(36px, 5.2vw, 72px);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.welcome__hint {
  margin: 26px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 10px;
  font-weight: 300;
  line-height: 1.9;
  letter-spacing: 0.04em;
}

.instrument {
  position: fixed;
  z-index: 4;
  bottom: var(--safe-bottom);
  left: 50%;
  display: grid;
  grid-template-columns: 104px 190px 1fr;
  align-items: center;
  width: min(900px, calc(100vw - 32px));
  min-height: 96px;
  padding: 12px 16px 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(17, 19, 31, 0.76), var(--glass));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36), inset 0 1px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(24px) saturate(125%);
  transform: translateX(-50%);
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding-left: 8px;
}

.counter__value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.counter__number {
  min-width: 30px;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 22px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}

.counter__max {
  color: rgba(235, 241, 238, 0.3);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.counter__label {
  color: rgba(235, 241, 238, 0.48);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 7px;
  letter-spacing: 0.2em;
}

.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 12px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.control,
.play {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.control {
  width: 58px;
  height: 64px;
  gap: 7px;
  color: var(--muted);
  border-radius: 18px;
  transition: color 180ms ease, background 180ms ease;
}

.control:hover,
.control:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.control__label {
  max-width: 54px;
  overflow: hidden;
  color: rgba(235, 241, 238, 0.5);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color 180ms ease;
}

.control:hover .control__label,
.control:focus-visible .control__label {
  color: var(--ink);
}

.icon {
  width: 20px;
  height: 20px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--play {
  fill: currentColor;
  stroke: none;
}

.icon--sound-off,
.icon--pause,
body.is-muted .icon--sound-on,
body.is-playing .icon--play {
  display: none;
}

body.is-muted .icon--sound-off,
body.is-playing .icon--pause {
  display: block;
}

.play {
  width: 64px;
  height: 72px;
  gap: 6px;
  color: var(--ink);
  border-radius: 20px;
  transition: transform 180ms ease;
}

.play__disc {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: #08100f;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 0 0 var(--glow), 0 6px 24px rgba(0, 0, 0, 0.24);
  transition: background 1s ease, box-shadow 300ms ease;
}

.play__label {
  color: rgba(235, 241, 238, 0.62);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.play:hover,
.play:focus-visible {
  transform: scale(1.06);
}

.play:hover .play__disc,
.play:focus-visible .play__disc,
body.is-playing .play__disc {
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--glow) 14%, transparent), 0 8px 28px rgba(0, 0, 0, 0.28);
}

.play:active {
  transform: scale(0.97);
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  align-items: center;
  gap: 6px;
  padding-left: 14px;
}

.action-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 58px;
  gap: 6px;
  padding: 6px 8px;
  color: rgba(235, 241, 238, 0.58);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.action-button .icon {
  width: 17px;
  height: 17px;
}

.action-button:hover,
.action-button:focus-visible {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.control:disabled,
.play:disabled,
.action-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.progress {
  position: absolute;
  right: 22px;
  bottom: 0;
  left: 22px;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--glow);
  box-shadow: 0 0 7px var(--glow);
  transition: width 80ms linear, background 1s ease;
}

.status {
  position: fixed;
  z-index: 7;
  top: 26px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 9px 14px;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.07em;
  border: 1px solid var(--faint);
  border-radius: 999px;
  background: rgba(10, 11, 18, 0.9);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -9px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.status::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 9px var(--glow);
  content: "";
}

.status.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.guide {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 4, 9, 0.5);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(10px);
  transition: opacity 250ms ease;
}

.guide.is-open {
  opacity: 1;
  pointer-events: auto;
}

.guide__card {
  position: relative;
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  padding: 38px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 26px;
  background: rgba(15, 16, 26, 0.9);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.44);
  transform: translateY(10px) scale(0.98);
  transition: transform 250ms ease;
}

.guide.is-open .guide__card {
  transform: translateY(0) scale(1);
}

.guide__card h2 {
  max-width: 300px;
  margin: 0 0 30px;
  font-size: 30px;
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.guide__close {
  position: absolute;
  top: 17px;
  right: 19px;
  width: 34px;
  height: 34px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 300;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.guide__close:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.guide__steps {
  display: grid;
  gap: 7px;
}

.guide__steps p {
  display: grid;
  grid-template-columns: 136px 1fr;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 9px 11px;
  color: rgba(235, 241, 238, 0.66);
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.022);
}

.guide__keys {
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide__keys i {
  color: rgba(235, 241, 238, 0.32);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 9px;
  font-style: normal;
}

kbd {
  display: inline-block;
  width: max-content;
  padding: 4px 7px;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 9px;
  text-transform: uppercase;
  border: 1px solid var(--faint);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
}

.guide__note {
  margin: 30px 0 0;
  padding-top: 20px;
  color: rgba(235, 241, 238, 0.52);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.7;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.confirm {
  position: fixed;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: min(390px, calc(100vw - 32px));
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 26px;
  background: rgba(15, 16, 25, 0.96);
  box-shadow: 0 0 0 100vmax rgba(2, 3, 8, 0.66), 0 28px 90px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(24px);
  transform: translate(-50%, -50%);
  animation: confirm-in 220ms ease-out;
}

.confirm__spark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  color: #08100f;
  font-size: 17px;
  border-radius: 14px;
  background: var(--glow);
  box-shadow: 0 0 24px color-mix(in srgb, var(--glow) 22%, transparent);
}

.confirm .eyebrow {
  margin-bottom: 10px;
}

.confirm h2 {
  margin: 0;
  font-size: 27px;
  font-weight: 300;
  line-height: 1.18;
  letter-spacing: -0.04em;
}

.confirm__copy {
  margin: 14px 0 26px;
  color: rgba(235, 241, 238, 0.56);
  font-size: 12px;
  line-height: 1.65;
}

.confirm__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.confirm button {
  min-height: 44px;
  padding: 10px 12px;
  color: rgba(235, 241, 238, 0.74);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
  font-size: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.confirm button:hover,
.confirm button:focus-visible {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.07);
  transform: translateY(-1px);
}

.confirm button:last-child {
  color: #08100f;
  border-color: var(--glow);
  background: var(--glow);
}

.confirm button:last-child:hover,
.confirm button:last-child:focus-visible {
  color: #08100f;
  background: color-mix(in srgb, var(--glow) 88%, white);
}

@keyframes breathe {
  from { transform: translate3d(-1%, -1%, 0) scale(1); }
  to { transform: translate3d(1%, 1%, 0) scale(1.08); }
}

@keyframes confirm-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (max-width: 900px) {
  .instrument {
    grid-template-columns: 82px 184px 1fr;
  }

  .counter {
    padding-left: 2px;
  }

  .actions {
    padding-left: 10px;
  }
}

@media (max-width: 680px) {
  .masthead {
    justify-content: center;
    padding: 22px;
  }

  .masthead p {
    display: none;
  }

  .instrument {
    bottom: max(10px, env(safe-area-inset-bottom));
    grid-template-columns: 42px minmax(128px, 1fr) minmax(104px, 0.76fr);
    width: calc(100vw - 20px);
    min-height: 90px;
    padding: 8px 9px 10px;
    border-radius: 22px;
  }

  .counter {
    align-items: center;
    gap: 2px;
    padding: 0;
  }

  .counter__number {
    min-width: 0;
    font-size: 19px;
  }

  .counter__max {
    display: none;
  }

  .counter__label {
    font-size: 6px;
  }

  .transport {
    gap: 0;
    padding: 0 6px;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(44px, 1fr));
    gap: 4px;
    padding-left: 8px;
  }

  .control {
    width: 44px;
    height: 62px;
    gap: 6px;
  }

  .control__label,
  .play__label {
    font-size: 7px;
  }

  .play {
    width: 52px;
    height: 66px;
  }

  .play__disc {
    width: 46px;
    height: 46px;
  }

  .action-button {
    flex-direction: row;
    height: 32px;
    gap: 4px;
    padding: 4px 6px;
    font-size: 7px;
    border-radius: 9px;
  }

  .action-button .icon {
    width: 14px;
    height: 14px;
  }

  .welcome__hint {
    font-size: 10.5px;
  }

  .confirm {
    width: calc(100vw - 32px);
    padding: 28px;
  }

  .confirm h2 {
    font-size: 24px;
  }

  .guide {
    padding: 16px;
  }

  .guide__card {
    padding: 32px 26px;
  }

  .guide__steps p {
    grid-template-columns: 116px 1fr;
    gap: 10px;
    padding: 9px;
  }
}

@media (max-height: 600px) {
  .welcome__hint { display: none; }
  .welcome { transform: translate(-50%, -63%); }
  .instrument { min-height: 74px; }
}

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