:root {
  --ink: #020708;
  --ink-soft: #041013;
  --lume: #84f5e3;
  --lume-bright: #d9fff9;
  --lume-dim: rgba(132, 245, 227, 0.42);
  --gold: #ffd48a;
  --violet: #b79bff;
  --text: #d7f2ec;
  --muted: #799a96;
  --line: rgba(132, 245, 227, 0.14);
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --pad: clamp(16px, 3.2vw, 38px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(132, 245, 227, 0.25);
  color: #fff;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: var(--ink);
  outline: none;
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 30%, rgba(1, 5, 6, 0.22) 64%, rgba(1, 4, 5, 0.72) 112%),
    linear-gradient(to bottom, rgba(1, 5, 6, 0.48), transparent 14%, transparent 83%, rgba(1, 4, 5, 0.6));
}

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

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding:
    max(var(--pad), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-right))
    max(var(--pad), env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));
  pointer-events: none;
  animation: hud-in 1.2s 0.15s ease both;
}

.hud__top,
.hud__bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hud__bottom {
  align-items: flex-end;
}

.identity {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  filter: drop-shadow(0 1px 8px rgba(0, 0, 0, 0.9));
}

.identity__name {
  color: rgba(219, 255, 248, 0.88);
  font-family: var(--serif);
  font-size: 0.72rem;
  letter-spacing: 0.36em;
}

.identity__chapter {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.53rem;
  letter-spacing: 0.18em;
  white-space: nowrap;
}

.identity__chapter i {
  display: block;
  width: 14px;
  height: 1px;
  background: var(--line);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 12, 14, 0.52);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
}

.stat__mark {
  color: var(--gold);
  font-size: 0.82rem;
  transform: translateY(-1px);
  text-shadow: 0 0 12px rgba(255, 212, 138, 0.5);
  transition: transform 0.35s ease, text-shadow 0.35s ease;
}

.stat.is-pulsing .stat__mark {
  animation: mote-mark 0.65s ease;
}

.stat__value {
  color: rgba(224, 253, 247, 0.9);
  font-variant-numeric: tabular-nums;
}

.stat__slash {
  margin: 0 2px;
  color: rgba(146, 186, 181, 0.4);
}

.health {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 12, 14, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.health i {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(175, 245, 233, 0.6);
  background: rgba(185, 255, 242, 0.75);
  box-shadow: 0 0 10px rgba(132, 245, 227, 0.35);
  transform: rotate(45deg);
  transition: opacity 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.health i.is-lost {
  background: transparent;
  border-color: rgba(150, 185, 181, 0.22);
  box-shadow: none;
  opacity: 0.55;
}

.health.is-hurt {
  animation: health-hurt 0.45s ease;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(2, 12, 14, 0.52);
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.icon-btn:hover {
  border-color: rgba(132, 245, 227, 0.38);
  background: rgba(9, 31, 33, 0.72);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn .icon {
  width: 16px;
  height: 16px;
  overflow: visible;
  fill: none;
  stroke: rgba(215, 250, 243, 0.85);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn .icon--sound path:first-child {
  fill: rgba(215, 250, 243, 0.85);
  stroke: none;
}

.icon-btn .sound-slash {
  display: none;
  stroke: var(--violet);
}

.icon-btn.is-muted .sound-slash {
  display: block;
}

.icon-btn.is-muted .sound-wave {
  opacity: 0.22;
}

.resonance {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 8px 14px 8px 0;
}

.resonance__label {
  color: var(--muted);
  font-size: 0.52rem;
  letter-spacing: 0.22em;
}

.echo-pips {
  display: flex;
  gap: 7px;
}

.echo-pips i {
  position: relative;
  display: block;
  width: 19px;
  height: 19px;
  border: 1px solid rgba(132, 245, 227, 0.18);
  border-radius: 50%;
  transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
}

.echo-pips i::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: rgba(132, 245, 227, 0.1);
  transition: background 0.35s ease, box-shadow 0.35s ease, transform 0.35s ease;
}

.echo-pips i.is-on {
  border-color: rgba(151, 255, 240, 0.55);
  background: rgba(132, 245, 227, 0.05);
  box-shadow: 0 0 12px rgba(132, 245, 227, 0.1);
}

.echo-pips i.is-on::after {
  background: rgba(203, 255, 247, 0.92);
  box-shadow: 0 0 9px rgba(132, 245, 227, 0.75);
}

.echo-pips i.is-charging {
  border-color: rgba(132, 245, 227, 0.3);
}

.echo-pips i.is-charging::after {
  animation: pip-charge 1.7s ease-in-out infinite;
}

.resonance.is-empty .echo-pips {
  animation: empty-shake 0.35s ease;
}

.hint {
  margin: 0 0 4px;
  color: rgba(141, 176, 172, 0.66);
  font-size: 0.52rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

.hint__dot {
  margin: 0 5px;
  color: rgba(132, 245, 227, 0.3);
}

.hint--touch {
  display: none;
}

.key {
  display: inline-block;
  padding: 3px 6px;
  border: 1px solid rgba(163, 228, 217, 0.19);
  border-radius: 4px;
  background: rgba(131, 240, 224, 0.05);
  color: rgba(211, 247, 239, 0.82);
  font: inherit;
  line-height: 1;
}

/* ---------- Chapter + toast ---------- */

.chapter {
  position: fixed;
  top: 48%;
  left: 50%;
  z-index: 7;
  width: min(560px, calc(100vw - 48px));
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-50% + 14px));
  transition: opacity 0.9s ease, transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1);
  filter: drop-shadow(0 4px 22px rgba(0, 0, 0, 0.9));
}

.chapter::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -60px -100px;
  background: radial-gradient(ellipse at center, rgba(2, 9, 11, 0.72), transparent 68%);
}

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

.chapter__kicker {
  margin: 0 0 15px;
  color: var(--lume-dim);
  font-size: 0.56rem;
  letter-spacing: 0.34em;
}

.chapter h2 {
  margin: 0;
  color: rgba(233, 255, 250, 0.97);
  font-family: var(--serif);
  font-size: clamp(2rem, 5.4vw, 3.8rem);
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 1.04;
  text-shadow: 0 0 36px rgba(132, 245, 227, 0.18);
  text-wrap: balance;
}

.chapter__quote {
  margin: 16px 0 0;
  color: rgba(190, 226, 219, 0.64);
  font-family: var(--serif);
  font-size: clamp(0.92rem, 2vw, 1.16rem);
  font-style: italic;
  letter-spacing: 0.01em;
}

.chapter__hint {
  margin: 22px 0 0;
  color: rgba(132, 245, 227, 0.54);
  font-size: 0.52rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.toast {
  position: fixed;
  bottom: max(115px, 17%);
  left: 50%;
  z-index: 8;
  padding: 8px 14px;
  border: 1px solid rgba(132, 245, 227, 0.12);
  border-radius: 999px;
  background: rgba(2, 12, 13, 0.66);
  color: rgba(210, 251, 243, 0.85);
  font-size: 0.53rem;
  letter-spacing: 0.24em;
  text-align: center;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.4s ease, transform 0.5s ease;
  white-space: nowrap;
}

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

/* ---------- Touch controls ---------- */

.touch-controls {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 11;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding:
    0 max(22px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
  pointer-events: none;
}

.joystick {
  position: relative;
  width: 108px;
  height: 108px;
  border: 1px solid rgba(132, 245, 227, 0.14);
  border-radius: 50%;
  background: rgba(3, 16, 18, 0.38);
  box-shadow: inset 0 0 36px rgba(132, 245, 227, 0.025);
  pointer-events: auto;
  touch-action: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.joystick__ring {
  position: absolute;
  inset: 17px;
  border: 1px solid rgba(132, 245, 227, 0.08);
  border-radius: 50%;
}

.joystick__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 1px solid rgba(171, 255, 242, 0.4);
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, rgba(216, 255, 248, 0.42), rgba(62, 148, 137, 0.18) 58%, rgba(6, 22, 23, 0.5));
  box-shadow: 0 0 24px rgba(132, 245, 227, 0.1);
  transform: translate(calc(var(--jx, 0) * 28px), calc(var(--jy, 0) * 28px));
  transition: transform 0.08s linear;
}

.echo-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  padding: 0;
  border: 1px solid rgba(132, 245, 227, 0.3);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(39, 99, 94, 0.45), rgba(3, 16, 18, 0.76) 66%);
  color: rgba(223, 255, 249, 0.9);
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  pointer-events: auto;
  touch-action: manipulation;
  box-shadow: 0 0 30px rgba(132, 245, 227, 0.06), inset 0 0 20px rgba(132, 245, 227, 0.03);
}

.echo-btn__ring {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(132, 245, 227, 0.1);
  border-radius: 50%;
}

.echo-btn__label {
  transform: translateY(-4px);
}

.echo-btn__count {
  position: absolute;
  bottom: 16px;
  color: var(--lume);
  font-size: 0.56rem;
  letter-spacing: 0.05em;
}

.echo-btn:active {
  background: radial-gradient(circle at 40% 35%, rgba(75, 172, 158, 0.5), rgba(4, 22, 23, 0.85) 68%);
  transform: scale(0.96);
}

.echo-btn.is-empty {
  border-color: rgba(132, 245, 227, 0.12);
  color: rgba(197, 230, 224, 0.4);
  box-shadow: none;
}

.echo-btn.is-empty .echo-btn__count {
  color: rgba(132, 245, 227, 0.35);
}

/* ---------- Screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: screen-in 0.55s ease both;
}

.screen--title.is-leaving {
  pointer-events: none;
  animation: title-out 0.52s ease forwards;
}

.screen--title {
  overflow: hidden;
  padding: clamp(24px, 5vw, 64px);
  background:
    radial-gradient(ellipse at 50% 43%, rgba(5, 25, 27, 0.28) 0%, rgba(3, 13, 15, 0.5) 36%, rgba(1, 6, 8, 0.88) 76%, rgba(1, 5, 6, 0.96) 100%);
}

.screen--title::before {
  content: "";
  position: absolute;
  inset: clamp(12px, 2.4vw, 30px);
  border: 1px solid rgba(132, 245, 227, 0.075);
  border-radius: 3px;
  pointer-events: none;
}

.screen--title::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(72vw, 760px);
  height: min(72vw, 760px);
  border-radius: 50%;
  border: 1px solid rgba(132, 245, 227, 0.035);
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 80px rgba(132, 245, 227, 0.014),
    0 0 0 160px rgba(132, 245, 227, 0.008);
}

.title-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(760px, 100%);
  text-align: center;
}

.title-mark {
  position: relative;
  width: 82px;
  height: 82px;
  margin-bottom: clamp(20px, 3.2vh, 30px);
}

.title-mark::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(158, 255, 243, 0.15), transparent 68%);
  filter: blur(5px);
}

.title-mark__orbit {
  position: absolute;
  border-radius: 50%;
}

.title-mark__orbit--one {
  inset: 8px;
  border: 1px solid rgba(132, 245, 227, 0.17);
  border-top-color: rgba(201, 255, 247, 0.6);
  border-right-color: rgba(132, 245, 227, 0.28);
  animation: orbit 13s linear infinite;
}

.title-mark__orbit--two {
  inset: 22px;
  border: 1px dashed rgba(132, 245, 227, 0.2);
  animation: orbit-reverse 9s linear infinite;
}

.title-mark__core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: #eafffa;
  box-shadow:
    0 0 8px rgba(219, 255, 249, 0.9),
    0 0 24px rgba(132, 245, 227, 0.6),
    0 0 48px rgba(132, 245, 227, 0.24);
  animation: core-breathe 4.5s ease-in-out infinite;
}

.kicker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 0;
  color: rgba(141, 194, 186, 0.7);
  font-size: 0.55rem;
  letter-spacing: 0.26em;
  line-height: 1.5;
  text-transform: uppercase;
}

.kicker > span {
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(132, 245, 227, 0.36));
}

.kicker > span:last-child {
  background: linear-gradient(90deg, rgba(132, 245, 227, 0.36), transparent);
}

.wordmark {
  margin: clamp(12px, 2vh, 20px) 0 0;
  background: linear-gradient(106deg, #f2fffc 4%, #b5fff3 42%, #63c8bc 82%, #3c8f88 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: var(--serif);
  font-size: clamp(4.1rem, 11.5vw, 8.7rem);
  font-weight: 400;
  letter-spacing: 0.075em;
  line-height: 0.86;
  text-indent: 0.075em;
  filter: drop-shadow(0 0 32px rgba(132, 245, 227, 0.12));
  animation: title-rise 1.4s 0.08s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.wordmark span {
  opacity: 0.68;
}

.tagline {
  margin: clamp(25px, 4.4vh, 40px) 0 0;
  color: rgba(181, 217, 210, 0.62);
  font-family: var(--serif);
  font-size: clamp(1.02rem, 2.3vw, 1.38rem);
  line-height: 1.55;
  letter-spacing: 0.01em;
  animation: title-rise 1.4s 0.22s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.tagline em {
  color: rgba(219, 254, 247, 0.88);
  font-weight: 400;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 50px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
}

.btn:focus-visible,
.icon-btn:focus-visible,
.echo-btn:focus-visible {
  outline: 1px solid var(--lume-bright);
  outline-offset: 4px;
}

.btn--primary {
  border: 1px solid rgba(204, 255, 248, 0.72);
  background: linear-gradient(180deg, rgba(220, 255, 250, 0.97), rgba(135, 231, 216, 0.9));
  color: #031312;
  box-shadow:
    0 0 0 1px rgba(132, 245, 227, 0.08),
    0 10px 34px rgba(60, 181, 166, 0.12),
    inset 0 1px rgba(255, 255, 255, 0.7);
}

.btn--primary:hover {
  background: linear-gradient(180deg, #effffd, #9af5e5);
  box-shadow:
    0 0 0 1px rgba(132, 245, 227, 0.16),
    0 14px 42px rgba(60, 181, 166, 0.22),
    0 0 26px rgba(132, 245, 227, 0.16);
  transform: translateY(-2px);
}

.btn--primary:active {
  transform: translateY(0) scale(0.985);
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.22s ease;
}

.btn:hover svg {
  transform: translateX(2px);
}

.btn--ghost {
  border: 1px solid rgba(132, 245, 227, 0.16);
  background: rgba(7, 25, 26, 0.35);
  color: rgba(194, 231, 224, 0.75);
}

.btn--ghost:hover {
  border-color: rgba(132, 245, 227, 0.35);
  background: rgba(12, 38, 38, 0.58);
  color: var(--lume-bright);
}

.screen--title .btn--primary {
  margin-top: clamp(30px, 5vh, 46px);
  padding-right: 28px;
  animation: title-rise 1.4s 0.34s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.title-notes {
  margin-top: clamp(24px, 4vh, 36px);
  color: rgba(129, 166, 161, 0.59);
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  line-height: 1.8;
  text-transform: uppercase;
  animation: title-rise 1.4s 0.44s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.title-notes p {
  margin: 0;
}

.title-notes .key {
  margin: 0 2px;
  font-size: 0.48rem;
}

.title-notes__soft {
  color: rgba(111, 151, 146, 0.42);
  letter-spacing: 0.18em;
}

.title-notes__touch {
  display: none;
}

.title-foot {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 18px));
  left: 50%;
  z-index: 1;
  margin: 0;
  color: rgba(119, 158, 153, 0.38);
  font-family: var(--serif);
  font-size: 0.72rem;
  font-style: italic;
  letter-spacing: 0.035em;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ---------- Modal ---------- */

.screen--modal {
  z-index: 30;
  padding: 24px;
  background: rgba(1, 5, 6, 0.62);
  backdrop-filter: blur(7px) saturate(0.8);
  -webkit-backdrop-filter: blur(7px) saturate(0.8);
}

.panel {
  position: relative;
  width: min(480px, 100%);
  padding: clamp(28px, 5vw, 46px);
  overflow: hidden;
  border: 1px solid rgba(132, 245, 227, 0.16);
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(63, 145, 135, 0.15), transparent 50%),
    linear-gradient(160deg, rgba(7, 23, 25, 0.97), rgba(2, 10, 12, 0.98));
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.55),
    inset 0 1px rgba(255, 255, 255, 0.04);
  text-align: center;
  animation: panel-in 0.45s cubic-bezier(0.2, 0.75, 0.2, 1) both;
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18%;
  right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(132, 245, 227, 0.5), transparent);
}

.panel .kicker {
  margin-bottom: 15px;
}

.panel h2 {
  max-width: 360px;
  margin: 0 auto;
  color: rgba(235, 255, 251, 0.97);
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.08;
  text-wrap: balance;
}

.panel__text {
  max-width: 320px;
  margin: 15px auto 0;
  color: rgba(164, 199, 192, 0.68);
  font-family: var(--serif);
  font-size: 1rem;
  font-style: italic;
  line-height: 1.55;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 26px 0 4px;
  padding: 18px 0;
  border-top: 1px solid rgba(132, 245, 227, 0.09);
  border-bottom: 1px solid rgba(132, 245, 227, 0.09);
}

.modal-stats div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-stats div + div {
  border-left: 1px solid rgba(132, 245, 227, 0.08);
}

.modal-stats span {
  color: rgba(119, 158, 153, 0.6);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
}

.modal-stats strong {
  color: rgba(221, 255, 248, 0.9);
  font-size: 1.02rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.07em;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 28px;
}

.panel__actions .btn {
  min-width: 148px;
}

.panel__keys {
  margin: 24px 0 0;
  color: rgba(108, 143, 138, 0.45);
  font-size: 0.48rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.panel__keys span {
  margin: 0 7px;
  color: rgba(132, 245, 227, 0.2);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 30px;
  background: var(--ink);
  color: var(--text);
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  :root {
    --pad: 14px;
  }

  .identity__chapter {
    font-size: 0.47rem;
    gap: 6px;
    max-width: 48vw;
  }

  .identity__chapter i {
    width: 8px;
  }

  .identity__name {
    font-size: 0.62rem;
  }

  .top-actions {
    gap: 5px;
  }

  .stat,
  .health {
    height: 32px;
    padding: 0 9px;
  }

  .health {
    gap: 6px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
  }

  .icon-btn .icon {
    width: 14px;
    height: 14px;
  }

  .screen--title {
    padding: 24px 22px;
  }

  .screen--title::after {
    width: 130vw;
    height: 130vw;
  }

  .screen--title::before {
    inset: 10px;
  }

  .title-mark {
    width: 66px;
    height: 66px;
  }

  .kicker {
    gap: 9px;
    font-size: 0.48rem;
    letter-spacing: 0.2em;
  }

  .kicker > span {
    width: 18px;
  }

  .wordmark {
    font-size: clamp(3.1rem, 13vw, 4.9rem);
    letter-spacing: 0.05em;
    text-indent: 0.05em;
  }

  .tagline {
    margin-top: 24px;
    font-size: 1rem;
  }

  .title-notes {
    margin-top: 24px;
    font-size: 0.48rem;
    letter-spacing: 0.08em;
  }

  .title-notes__soft {
    display: none;
  }

  .title-notes__touch {
    display: block;
  }

  .title-notes p:not(.title-notes__touch):not(.title-notes__soft) {
    display: none;
  }

  .title-foot {
    font-size: 0.65rem;
  }

  .chapter {
    top: 45%;
  }

  .chapter__hint {
    margin-top: 17px;
    font-size: 0.46rem;
    letter-spacing: 0.16em;
  }

  .toast {
    bottom: max(132px, 19%);
    max-width: calc(100vw - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.48rem;
  }

  .panel {
    border-radius: 16px;
  }

  .panel__actions {
    flex-direction: column;
  }

  .panel__actions .btn {
    width: 100%;
  }
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }

  .hud__bottom {
    display: none;
  }

  .hint--desktop,
  .hint--touch {
    display: none;
  }

  .title-notes__touch {
    display: block;
  }

  .title-notes > p:not(.title-notes__touch):not(.title-notes__soft) {
    display: none;
  }

  .stat,
  .health {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(2, 12, 14, 0.7);
  }
}

@media (max-height: 640px) and (pointer: coarse) {
  .joystick {
    width: 88px;
    height: 88px;
  }

  .joystick__knob {
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    transform: translate(calc(var(--jx, 0) * 22px), calc(var(--jy, 0) * 22px));
  }

  .echo-btn {
    width: 70px;
    height: 70px;
  }

  .echo-btn__count {
    bottom: 12px;
  }
}

@media (max-width: 390px) {
  .identity__chapter {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat {
    padding: 0 8px;
    gap: 5px;
    font-size: 0.58rem;
  }

  .health {
    padding: 0 8px;
    gap: 5px;
  }

  .health i {
    width: 6px;
    height: 6px;
  }

  .top-actions {
    gap: 4px;
  }
}

@media (max-height: 620px) {
  .screen--title {
    padding: 16px 24px;
  }

  .title-mark,
  .title-foot,
  .title-notes__soft {
    display: none;
  }

  .wordmark {
    margin-top: 0;
    font-size: clamp(2.5rem, 9vw, 5.2rem);
    letter-spacing: 0.05em;
    text-indent: 0.05em;
  }

  .tagline {
    margin-top: 19px;
    font-size: clamp(0.92rem, 2vw, 1.12rem);
    line-height: 1.4;
  }

  .screen--title .btn--primary {
    min-height: 44px;
    margin-top: 22px;
  }

  .title-notes {
    margin-top: 17px;
    line-height: 1.65;
  }

  .screen--modal {
    align-items: flex-start;
    overflow-y: auto;
  }

  .panel {
    margin-top: 0;
    padding: 24px 28px;
    border-radius: 16px;
  }

  .panel .kicker {
    margin-bottom: 10px;
  }

  .panel h2 {
    font-size: clamp(1.7rem, 4vw, 2.25rem);
  }

  .panel__text {
    margin-top: 10px;
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .modal-stats {
    margin: 16px 0 0;
    padding: 12px 0;
  }

  .panel__actions {
    margin-top: 19px;
  }

  .panel__keys {
    margin-top: 16px;
  }
}

@media (max-height: 560px) and (pointer: coarse) {
  .hud {
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .identity__chapter {
    display: none;
  }

  .stat,
  .health,
  .icon-btn {
    height: 32px;
  }
}

@media (max-width: 360px) {
  .identity__chapter i,
  .identity__chapter #levelLabel {
    display: none;
  }
}

@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;
  }
}

/* ---------- Keyframes ---------- */

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@keyframes orbit-reverse {
  to { transform: rotate(-360deg); }
}

@keyframes core-breathe {
  0%, 100% { opacity: 0.78; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes title-out {
  from { opacity: 1; }
  to { opacity: 0; visibility: hidden; }
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hud-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes title-rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes mote-mark {
  0% { transform: scale(1) translateY(-1px); text-shadow: 0 0 12px rgba(255, 212, 138, 0.5); }
  40% { transform: scale(1.5) translateY(-1px); text-shadow: 0 0 24px rgba(255, 212, 138, 1); }
  100% { transform: scale(1) translateY(-1px); text-shadow: 0 0 12px rgba(255, 212, 138, 0.5); }
}

@keyframes health-hurt {
  0%, 100% { transform: translateX(0); border-color: var(--line); }
  25% { transform: translateX(-3px); border-color: rgba(183, 155, 255, 0.5); }
  60% { transform: translateX(3px); border-color: rgba(183, 155, 255, 0.3); }
}

@keyframes empty-shake {
  0%, 100% { transform: translateX(0); opacity: 1; }
  30% { transform: translateX(-4px); opacity: 0.5; }
  65% { transform: translateX(4px); opacity: 0.8; }
}

@keyframes pip-charge {
  0%, 100% { transform: scale(0.72); background: rgba(132, 245, 227, 0.15); }
  50% { transform: scale(1); background: rgba(174, 255, 243, 0.45); }
}
