:root {
  --abyss: #04080e;
  --surface: #62c7bb;
  --song: #9fe8d5;
  --krill: #ff9c5b;
  --bone: #ded6c6;
  --alarm: #d9603f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--abyss);
  color: var(--bone);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app,
#pixi-container {
  position: fixed;
  inset: 0;
}

/* only the Pixi canvas is pinned full-viewport; the ruler canvas stays in flow */
#pixi-container canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.hud {
  position: fixed;
  z-index: 2;
  pointer-events: none;
}

/* ---- top bar ---- */
.topbar {
  top: 0;
  left: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 24px;
  padding: 16px 30px 22px;
  color: var(--bone);
  background: linear-gradient(
    180deg,
    rgba(4, 10, 18, 0.5),
    rgba(4, 10, 18, 0.16) 62%,
    rgba(4, 10, 18, 0)
  );
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tb-left .wave-mark {
  width: 30px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: var(--song);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.6;
}
.tb-zone {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 20px;
  opacity: 0.9;
}
.tb-zone .leg {
  display: block;
  font-style: normal;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0.5;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.tb-mid {
  justify-self: center;
  text-align: center;
  max-width: 40ch;
}
.compass {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.compass .pole {
  font-size: 11px;
  letter-spacing: 0.16em;
  opacity: 0.45;
}
.compass .strip {
  position: relative;
  width: min(240px, 26vw);
  height: 12px;
  background: linear-gradient(rgba(222, 214, 198, 0.32), rgba(222, 214, 198, 0.32))
      left center / 100% 1px no-repeat,
    repeating-linear-gradient(
        90deg,
        rgba(222, 214, 198, 0.22) 0 1px,
        transparent 1px 14px
      )
      center / 100% 5px no-repeat;
}
.compass .strip b {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-top-color: var(--song);
  transform: translate(-50%, -78%);
  transition: left 0.35s ease;
}
.goal {
  margin-top: 9px;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  opacity: 0.42;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
}

.tb-right {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.tb-gauge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  letter-spacing: 0.04em;
  opacity: 0.82;
}
.tb-gauge span {
  padding-left: 10px;
  border-left: 1px solid rgba(222, 214, 198, 0.22);
}
.tb-gauge .tb-ico {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: var(--bone);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
}
.tb-gauge .tb-ico .rays {
  opacity: 0.85;
}
.tb-gauge .tb-ico .tb-ico-fill {
  stroke: var(--surface);
  stroke-width: 3;
}

.tb-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.tb-score b {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--song);
}
.tb-score span {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.4;
}

/* ---- trick popup ---- */
.trickpop {
  left: 0;
  right: 0;
  top: 30%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.trickpop.show {
  opacity: 1;
  transform: translateY(0);
}
.trickpop .lbl {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 22px;
  letter-spacing: 0.02em;
  color: var(--bone);
  text-shadow: 0 2px 18px rgba(4, 10, 18, 0.8);
}
.trickpop .pts {
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--song);
  font-variant-numeric: tabular-nums;
}
.trickpop .pts b {
  color: var(--krill);
  font-weight: 600;
  margin-left: 4px;
}
.trickpop.big .lbl {
  font-size: 30px;
  color: var(--song);
}

@media (prefers-reduced-motion: reduce) {
  .trickpop {
    transition: opacity 0.3s ease;
    transform: none;
  }
}

.instruments {
  left: 26px;
  bottom: 26px;
  width: 320px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px 16px 16px;
  /* border-radius: 18px;
  background: linear-gradient(
    180deg,
    rgba(12, 26, 40, 0.72),
    rgba(6, 15, 26, 0.66)
  );
  border: 1px solid rgba(159, 232, 213, 0.12); */
  /* box-shadow: 0 12px 36px rgba(2, 6, 12, 0.42); */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.instruments .badge {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(
    circle at 34% 30%,
    rgba(98, 199, 187, 0.28),
    rgba(8, 20, 34, 0.6)
  );
  border: 1px solid rgba(159, 232, 213, 0.22);
}
.instruments .whale-mark {
  width: 34px;
  height: 34px;
}
.instruments .whale-mark path {
  fill: var(--song);
}
.instruments .whale-mark .fin {
  fill: var(--surface);
  opacity: 0.85;
}

.gauges {
  flex: 1;
  min-width: 0;
}

.meter {
  margin-bottom: 12px;
}
.meter .label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.meter .label span:first-child {
  color: var(--bone);
  opacity: 0.92;
  font-weight: 500;
}
.meter .label .pct {
  font-size: 11px;
  opacity: 0.55;
}
.meter .track {
  height: 7px;
  border-radius: 4px;
  background: rgba(222, 214, 198, 0.14);
  overflow: hidden;
}
.meter .fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: var(--bone);
  transition: width 0.25s ease, background 0.3s linear;
}
#breathFill {
  background: linear-gradient(90deg, var(--surface), var(--song));
}
#energyFill {
  background: linear-gradient(90deg, #d99a3f, #f2c96b);
}
#breathFill.low {
  background: linear-gradient(90deg, var(--alarm), #f0895f);
}

.pod {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.7;
}
.pod .pod-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--song);
  position: relative;
}
.pod .pod-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--song);
}
.pod .pod-label {
  color: var(--bone);
  opacity: 0.92;
}
.pod .dots {
  display: flex;
  gap: 5px;
}
.pod .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--song);
  opacity: 0.9;
}
.pod .draft {
  font-variant-numeric: tabular-nums;
  opacity: 0.82;
  color: var(--song);
}
.pod .draft::before {
  content: "•";
  margin: 0 7px 0 3px;
  opacity: 0.45;
  color: var(--bone);
}

.ruler {
  top: 0;
  right: 0;
  height: 100%;
  width: 120px;
}
.ruler canvas {
  display: block;
  width: 120px;
  height: 100%;
}

.hint {
  left: 30px;
  bottom: 150px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--song);
  opacity: 0;
  transition: opacity 0.5s ease;
  max-width: 44ch;
}
.hint.show {
  opacity: 0.82;
}

.card {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0 max(30px, 9vw);
  background: rgba(4, 8, 14, 0.87);
  transition: opacity 0.8s ease;
}
.card.gone {
  opacity: 0;
  pointer-events: none;
}
.card h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: clamp(34px, 5.4vw, 62px);
  line-height: 1.04;
  margin: 0;
  letter-spacing: -0.012em;
}
.card h1 em {
  font-style: italic;
  opacity: 0.6;
}
.card p {
  max-width: 46ch;
  font-size: 14.5px;
  line-height: 1.72;
  opacity: 0.74;
  margin: 18px 0 0;
}
.keys {
  margin-top: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 18px;
  font-size: 13px;
  align-items: baseline;
}
.keys b {
  font-weight: 500;
  color: var(--song);
  white-space: nowrap;
}
.keys span {
  opacity: 0.68;
}
.start {
  margin-top: 32px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .hint {
    transition: none;
  }
}

/* ---- splash / loading ----
   BWDX Studio bumper fades in and out, then the logo fades in and holds
   (both centred on screen); the progress bar sits just below the logo. */
.splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  background: var(--abyss);
  transition: opacity 0.55s ease;
}
.splash.lift {
  opacity: 0;
  pointer-events: none;
}
/* the logo (in normal flow) sizes the stage; the bumper overlays it */
.splash-stage {
  position: relative;
  width: min(440px, 78vw);
}
.splash-logo {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  filter: drop-shadow(0 14px 40px rgba(140, 166, 206, 0.4));
  animation: splashHold 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) 0.95s both;
}
.splash-bumper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  animation: splashFrame 1s ease 0.1s both;
}
.splash-bumper img {
  width: 86px;
  height: auto;
}
.splash-bumper span {
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--bone);
  opacity: 0.5;
}
@keyframes splashFrame {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }
  24% {
    opacity: 0.92;
    transform: scale(1);
  }
  76% {
    opacity: 0.92;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.03);
  }
}
@keyframes splashHold {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.splash-tail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  animation: splashIn 0.7s ease 1.3s forwards;
}
@keyframes splashIn {
  to {
    opacity: 1;
  }
}
.splash-word {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 15px;
  letter-spacing: 0.06em;
  opacity: 0.55;
}
/* empty in the normal case — only holds the error text if boot fails */
.splash-word:empty {
  display: none;
}
.splash-bar {
  width: 170px;
  height: 2px;
  background: rgba(222, 214, 198, 0.14);
  overflow: hidden;
}
.splash-bar i {
  display: block;
  height: 100%;
  width: 6%;
  background: var(--song);
  opacity: 0.7;
  transition: width 0.45s ease;
}
.splash.failed .splash-word {
  font-style: normal;
  font-size: 13px;
  max-width: 40ch;
  text-align: center;
  line-height: 1.6;
  color: var(--alarm);
  opacity: 0.9;
}
.splash.failed .splash-bar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .splash {
    transition: none;
  }
  .splash-logo,
  .splash-tail {
    animation: none;
    opacity: 1;
  }
  .splash-bumper {
    animation: none;
    opacity: 0;
  }
}

/* ---- pause menu ---- */
.menu {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 0 max(30px, 9vw);
  background: rgba(4, 8, 14, 0.78);
  backdrop-filter: blur(2px);
}
.menu[hidden] {
  display: none;
}
.menu h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-style: italic;
  font-size: 26px;
  margin: 0 0 14px;
  opacity: 0.82;
}
.menu button {
  appearance: none;
  background: none;
  border: 0;
  padding: 7px 0;
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.03em;
  color: var(--bone);
  opacity: 0.72;
  cursor: pointer;
  text-align: left;
  transition: opacity 0.15s ease;
}
.menu button:hover,
.menu button:focus-visible {
  opacity: 1;
  color: var(--song);
  outline: none;
}
.menu .note {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--song);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.menu .note.show {
  opacity: 0.8;
}
.menu .options {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
  opacity: 0.8;
}
.menu .options[hidden] {
  display: none;
}
.menu .options label {
  display: flex;
  align-items: center;
  gap: 12px;
}
.menu .options input[type="range"] {
  width: 180px;
  accent-color: var(--surface);
}
