:root {
  color-scheme: dark;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.artwork,
.background,
#fireworksCanvas {
  position: fixed;
  inset: 0;
}

.artwork {
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(180deg, #101c38 0%, #050916 58%, #02030a 100%);
}

.background {
  z-index: 0;
  background-image:
    linear-gradient(180deg, rgba(3, 7, 18, .08), rgba(0, 0, 0, .16)),
    url("assets/images/background.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

#fireworksCanvas {
  z-index: 1;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.title-panel {
  position: fixed;
  z-index: 2;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  pointer-events: none;
  color: rgba(255, 252, 239, .9);
  text-shadow: 0 1px 12px rgba(0, 0, 0, .8);
  transition: opacity 1.2s ease;
}

.title-panel h1 {
  margin: 0 0 .45rem;
  font-size: clamp(1.05rem, 2.5vw, 1.5rem);
  font-weight: 500;
  letter-spacing: .18em;
}

.title-panel p {
  margin: 0;
  font-family: system-ui, sans-serif;
  font-size: clamp(.72rem, 2vw, .86rem);
  line-height: 1.65;
  letter-spacing: .05em;
  opacity: .75;
  transition: opacity 1.2s ease, transform 1.2s ease;
}

.title-panel.is-quiet p {
  opacity: 0;
  transform: translateY(-5px);
}

.sound-toggle,
.controls {
  position: fixed;
  z-index: 3;
}

.sound-toggle {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: .55rem .8rem;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  color: rgba(255, 255, 255, .85);
  background: rgba(5, 9, 22, .42);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .18);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font: 600 .72rem/1 system-ui, sans-serif;
  letter-spacing: .05em;
}

.controls {
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .42rem;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  color: rgba(255, 255, 255, .82);
  background: rgba(5, 9, 22, .42);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .18);
  backdrop-filter: blur(8px);
  font: 600 .7rem/1 system-ui, sans-serif;
}

.type-control {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding-left: .3rem;
  white-space: nowrap;
}

.type-control select,
.control-button {
  min-height: 36px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 9px;
  color: rgba(255, 255, 255, .9);
  background: rgba(15, 24, 43, .72);
  font: inherit;
  cursor: pointer;
}

.type-control select {
  padding: 0 1.65rem 0 .55rem;
}

.type-control select option {
  color: #f4f6fa;
  background: #111a2d;
}

.control-button {
  padding: 0 .7rem;
  letter-spacing: .03em;
}

.control-button[aria-pressed="true"] {
  border-color: rgba(168, 221, 255, .55);
  color: #e9f8ff;
  background: rgba(38, 88, 120, .68);
}

.finale-button {
  color: #fff0bd;
  letter-spacing: .11em;
}

.finale-button:disabled {
  opacity: .55;
  cursor: default;
}

.sound-toggle:hover {
  background: rgba(17, 26, 48, .65);
}

.sound-toggle:focus-visible,
.control-button:focus-visible,
.type-control select:focus-visible {
  outline: 2px solid #fff1b5;
  outline-offset: 3px;
}

.sound-toggle[aria-pressed="false"] {
  opacity: .68;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 600px) {
  .title-panel {
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
  }

  .sound-label {
    font-size: .68rem;
  }

  .controls {
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 50px);
    justify-content: space-between;
    gap: .3rem;
    padding: .35rem;
  }

  .type-control {
    gap: .25rem;
    padding-left: .15rem;
  }

  .type-control select,
  .control-button {
    min-height: 38px;
    padding-left: .52rem;
    padding-right: .52rem;
    font-size: .67rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title-panel,
  .title-panel p {
    transition-duration: .01ms;
  }
}
