:root {
  color-scheme: dark;
  --bg: #030613;
  --panel: #090d18;
  --panel-soft: #111827;
  --line: rgba(132, 224, 255, 0.18);
  --text: #f7f2e8;
  --muted: #a9b4c2;
  --red: #ff334b;
  --orange: #ff9b3d;
  --yellow: #ffd166;
  --green: #28f6d5;
  --cyan: #28f6d5;
  --magenta: #ff3fb4;
  --copper: #ff9b3d;
  --state: var(--cyan);
  --state-rgb: 40, 246, 213;
  --meter-x: 50%;
  --needle-angle: 0deg;
  --spark-level: 1;
  --flame-level: 1;
  --flare-level: 0;
  --sprite-position: 57.143%;
  --closeness: 1;
  --overheat: 0;
  --under-tension: 0;
  --string-tension: 0.5;
  --resonance: 1;
  --frame-progress: 0.5;
  --stage-brightness: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(3, 6, 19, 0.26), rgba(3, 6, 19, 0.82)),
    url("assets/outlaw-neon-roadhouse-bg.webp") center / cover fixed no-repeat,
    #000;
  color: var(--text);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Segoe UI Condensed", "Roboto Condensed", Arial, sans-serif;
  letter-spacing: 0;
  overscroll-behavior-y: none;
}

body[data-build="appstore"] .demo-panel {
  display: none !important;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -18%;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 63, 180, 0.18), transparent 19rem),
    radial-gradient(circle at 86% 26%, rgba(40, 246, 213, 0.16), transparent 22rem),
    linear-gradient(115deg, transparent 22%, rgba(40, 246, 213, 0.09) 41%, transparent 58%),
    linear-gradient(245deg, transparent 20%, rgba(255, 155, 61, 0.08) 46%, transparent 68%);
  mix-blend-mode: screen;
  opacity: 0.9;
  animation: neonBreath 8s ease-in-out infinite alternate;
}

body::after {
  background:
    radial-gradient(circle, rgba(40, 246, 213, 0.8) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 63, 180, 0.58) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 155, 61, 0.7) 0 1px, transparent 1.6px);
  background-size: 92px 92px, 137px 137px, 173px 173px;
  background-position: 0 0, 28px 18px, 53px 63px;
  opacity: 0.18;
  animation: dustRise 18s linear infinite;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  position: relative;
  z-index: 1;
  container-type: inline-size;
  width: min(100vw, 430px);
  max-width: 100vw;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(12px, calc(env(safe-area-inset-top, 0px) + 10px))
    max(10px, calc(env(safe-area-inset-right, 0px) + 10px))
    max(14px, calc(env(safe-area-inset-bottom, 0px) + 12px))
    max(10px, calc(env(safe-area-inset-left, 0px) + 10px));
  background:
    radial-gradient(circle at 82% 8%, rgba(40, 246, 213, 0.14), transparent 18rem),
    radial-gradient(circle at 12% 34%, rgba(255, 63, 180, 0.13), transparent 16rem),
    linear-gradient(180deg, rgba(3, 6, 19, 0.82), rgba(3, 6, 19, 0.92)),
    rgba(3, 6, 19, 0.86);
  overflow: hidden;
  box-shadow:
    0 0 52px rgba(40, 246, 213, 0.14),
    0 0 96px rgba(255, 63, 180, 0.09);
  isolation: isolate;
}

.app-shell[data-state="way-low"],
.app-shell[data-state="way-high"] {
  --state: var(--red);
  --state-rgb: 255, 43, 31;
}

.app-shell[data-state="low"],
.app-shell[data-state="high"] {
  --state: var(--orange);
  --state-rgb: 255, 138, 0;
}

.app-shell[data-state="almost-low"],
.app-shell[data-state="almost-high"] {
  --state: var(--yellow);
  --state-rgb: 255, 209, 102;
}

.app-shell[data-state="perfect"] {
  --state: var(--cyan);
  --state-rgb: 40, 246, 213;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.logo {
  width: min(100%, 210px);
  height: auto;
  display: block;
  filter:
    drop-shadow(0 0 12px rgba(40, 246, 213, 0.24))
    drop-shadow(0 0 22px rgba(255, 63, 180, 0.12));
}

.top-actions {
  display: flex;
  justify-self: end;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 0;
}

.icon-button,
.demo-reset {
  border: 1px solid rgba(40, 246, 213, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(40, 246, 213, 0.14), rgba(255, 63, 180, 0.04)),
    rgba(5, 9, 22, 0.78);
  color: var(--text);
  min-height: 42px;
  min-width: 44px;
  padding: 0 8px;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.icon-button.active,
.icon-button[aria-pressed="true"],
.demo-reset:active {
  color: #021015;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(40, 246, 213, 0.45);
}

.hero-panel {
  display: grid;
  gap: 8px;
}

.character-stage {
  position: relative;
  aspect-ratio: 808 / 420;
  min-height: 0;
  border: 1px solid rgba(var(--state-rgb), 0.28);
  border-radius: 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 20%, rgba(255, 63, 180, 0.12), transparent 12rem),
    radial-gradient(circle at 36% 60%, rgba(var(--state-rgb), 0.18), transparent 16rem),
    #01030a;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 26px rgba(var(--state-rgb), 0.22),
    0 0 46px rgba(255, 63, 180, 0.08);
}

.character-stage::before,
.character-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.character-stage::before {
  z-index: 2;
  background:
    linear-gradient(105deg, transparent 18%, rgba(40, 246, 213, 0.16) 42%, transparent 66%),
    radial-gradient(circle at 37% 62%, rgba(255, 155, 61, calc(0.08 + var(--flame-level) * 0.16)), transparent 12%),
    radial-gradient(circle at 55% 42%, rgba(var(--state-rgb), calc(var(--resonance) * 0.16)), transparent 22%),
    linear-gradient(90deg, rgba(0, 0, 0, calc(var(--under-tension) * 0.32)), transparent 48%, rgba(255, 58, 20, calc(var(--overheat) * 0.18)));
  mix-blend-mode: screen;
  opacity: calc(0.32 + var(--closeness) * 0.28 + var(--overheat) * 0.22);
  background-size: 180% 100%, auto, auto, auto;
  animation: stageSweep 9s ease-in-out infinite alternate;
  transition: opacity 180ms ease, background 180ms ease;
}

.character-stage::after {
  z-index: 7;
  background:
    radial-gradient(ellipse at 40% 76%, rgba(40, 246, 213, calc(var(--resonance) * 0.18)), transparent 24%),
    radial-gradient(ellipse at 18% 60%, rgba(255, 155, 61, calc(var(--flame-level) * 0.12)), transparent 18%),
    radial-gradient(ellipse at 73% 37%, rgba(255, 51, 75, calc(var(--overheat) * 0.28)), transparent 26%);
  mix-blend-mode: screen;
  opacity: calc(0.12 + var(--resonance) * 0.24 + var(--overheat) * 0.24);
  transition: opacity 180ms ease;
}

.app-shell.frame-transition .character-stage::after {
  animation: frameVeil 220ms ease-out;
}

.character-rig {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform-origin: 56% 42%;
  animation: none;
  transform: none;
}

.character-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  filter:
    saturate(calc(0.84 + var(--closeness) * 0.25 + var(--overheat) * 0.2))
    contrast(calc(1.03 + var(--overheat) * 0.08))
    brightness(var(--stage-brightness));
  transform: scale(1);
  transform-origin: 56% 42%;
  animation: none;
  opacity: 0;
  transition: opacity 90ms linear, filter 220ms ease;
  will-change: opacity, filter;
}

.character-frame.frame-a {
  opacity: 1;
}

.character-frame.frame-b {
  opacity: 0;
}

.flame-system {
  display: none;
}

.app-shell[data-state="way-high"] .character-stage {
  animation: warningShake 520ms ease-in-out;
}

.app-shell[data-state="perfect"] .character-frame {
  animation: none;
  filter: saturate(1.18) contrast(1.08) brightness(1.04);
}

.stage-glow {
  position: absolute;
  inset: auto 12% -18% 12%;
  height: 42%;
  background: radial-gradient(circle, rgba(var(--state-rgb), 0.5), transparent 70%);
  filter: blur(22px);
  opacity: calc(0.16 + var(--closeness) * 0.52 + var(--overheat) * 0.34);
  pointer-events: none;
  z-index: 4;
}

.flame-system {
  position: absolute;
  display: none;
  left: 31.2%;
  bottom: 21.8%;
  z-index: 5;
  width: 78px;
  height: 112px;
  pointer-events: none;
  opacity: calc(0.1 + var(--spark-level) * 0.52 + var(--flare-level) * 0.18);
  filter:
    drop-shadow(0 0 calc(4px + var(--flame-level) * 16px) rgba(255, 139, 0, 0.68))
    drop-shadow(0 0 calc(2px + var(--flare-level) * 18px) rgba(255, 31, 24, 0.7));
  transform:
    translateY(calc(var(--under-tension) * 8px - var(--overheat) * 7px))
    rotate(calc(var(--overheat) * -6deg))
    scale(calc(0.42 + var(--flame-level) * 0.23 + var(--flare-level) * 0.22));
  transform-origin: 50% 88%;
  transition: opacity 180ms ease, transform 200ms ease, filter 200ms ease;
}

.flame-system::after {
  content: "";
  position: absolute;
  left: 34px;
  bottom: 11px;
  z-index: 4;
  width: 15px;
  height: 8px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(255, 248, 188, 0.96), rgba(255, 166, 28, 0.78) 42%, rgba(255, 55, 18, 0.4) 68%, transparent 80%);
  filter: blur(0.3px) drop-shadow(0 0 9px rgba(255, 154, 28, 0.72));
  opacity: calc(0.16 + var(--flame-level) * 0.58 + var(--flare-level) * 0.18);
  transform: rotate(-8deg) scale(calc(0.72 + var(--flame-level) * 0.18 + var(--flare-level) * 0.14));
  transform-origin: center;
}

.app-shell[data-state="way-low"] .flame-system {
  opacity: calc(0.05 + var(--spark-level) * 0.24);
  filter: drop-shadow(0 0 5px rgba(255, 180, 80, 0.48));
}

.app-shell[data-state="low"] .flame-system {
  opacity: calc(0.2 + var(--spark-level) * 0.5);
  filter:
    drop-shadow(0 0 calc(7px + var(--flame-level) * 18px) rgba(255, 139, 0, 0.78))
    drop-shadow(0 0 7px rgba(255, 218, 94, 0.32));
}

.app-shell[data-state="perfect"] .flame-system {
  animation: perfectFlamePop 1.15s ease-in-out infinite;
}

.app-shell[data-state="high"] .flame-system,
.app-shell[data-state="way-high"] .flame-system {
  transform:
    translateX(2px)
    translateY(calc(-6px - var(--overheat) * 8px))
    rotate(-5deg)
    scale(calc(0.46 + var(--flame-level) * 0.16 + var(--flare-level) * 0.3));
}

.app-shell[data-state="way-high"] .flame-system {
  animation: overheatFlare 520ms ease-in-out infinite alternate;
}

.flame-sprite {
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image: url("assets/flame-sprite-normalized.png");
  background-repeat: no-repeat;
  background-size: 800% 100%;
  background-position: var(--sprite-position) 0;
  transform-origin: 50% 100%;
  animation: spriteFlicker 440ms ease-in-out infinite alternate;
}

.sprite-glow {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 6px;
  height: 66px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% 70%, rgba(255, 247, 156, 0.34), rgba(255, 132, 0, 0.28) 38%, rgba(255, 31, 18, 0.18) 62%, transparent 76%);
  filter: blur(12px);
  opacity: calc(0.1 + var(--flame-level) * 0.32 + var(--flare-level) * 0.22);
  transform: scale(calc(0.7 + var(--flame-level) * 0.22 + var(--flare-level) * 0.18));
}

.flame-core,
.flame-halo {
  display: none;
  position: absolute;
  left: 28px;
  bottom: 24px;
  width: 30px;
  height: 58px;
  border-radius: 55% 45% 56% 42%;
  transform-origin: 50% 100%;
}

.flame-core {
  background:
    radial-gradient(circle at 52% 75%, rgba(255, 255, 225, 0.95), rgba(255, 230, 77, 0.82) 22%, transparent 42%),
    radial-gradient(ellipse at 50% 52%, rgba(255, 132, 0, 0.95), rgba(255, 55, 18, 0.72) 58%, transparent 72%);
  opacity: calc(0.1 + var(--flame-level) * 0.82 + var(--overheat) * 0.2);
  animation: flameFlicker 640ms ease-in-out infinite alternate;
}

.flame-halo {
  left: 12px;
  bottom: 4px;
  width: 72px;
  height: 90px;
  background: radial-gradient(ellipse at 40% 62%, rgba(255, 128, 0, 0.36), rgba(255, 42, 18, 0.18) 42%, transparent 74%);
  filter: blur(12px);
  opacity: calc(0.1 + var(--flame-level) * 0.52 + var(--overheat) * 0.3);
}

.spark {
  position: absolute;
  left: 30px;
  bottom: 50px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #fff4a8;
  box-shadow: 0 0 10px rgba(255, 230, 122, 0.9);
  opacity: calc(0.15 + var(--spark-level) * 0.7);
  animation: sparkPop 780ms ease-in-out infinite;
}

.spark-two {
  left: 48px;
  bottom: 66px;
  animation-delay: -220ms;
}

.spark-three {
  left: 22px;
  bottom: 72px;
  animation-delay: -420ms;
}

.smoke {
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 68%);
  filter: blur(14px);
  opacity: 0.28;
  pointer-events: none;
  animation: smokeDrift 5s linear infinite;
}

.smoke-one {
  left: 18%;
  top: 20%;
}

.smoke-two {
  right: 14%;
  top: 10%;
  animation-delay: -2s;
}

.tune-overlay {
  position: relative;
  padding: 8px 10px;
  border: 1px solid rgba(var(--state-rgb), 0.36);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(3, 8, 19, 0.92), rgba(7, 14, 30, 0.62)),
    rgba(3, 6, 19, 0.74);
  box-shadow: 0 0 20px rgba(var(--state-rgb), 0.22);
  backdrop-filter: blur(8px);
}

.tune-overlay strong {
  display: block;
  margin-top: 2px;
  color: var(--state);
  font-size: 1.22rem;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(var(--state-rgb), 0.34);
}

.tune-overlay p {
  margin: 4px 0 0;
  color: #c8d5df;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.78rem;
}

.readout-card,
.meter-panel,
.demo-panel,
.string-pad,
.mode-row {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(40, 246, 213, 0.08), rgba(255, 63, 180, 0.045) 52%, rgba(255, 155, 61, 0.035)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018)),
    rgba(5, 9, 22, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    0 12px 32px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.mode-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px;
}

.mode-chip {
  min-height: 36px;
  border: 1px solid rgba(40, 246, 213, 0.38);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--cyan);
  padding: 0 10px;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.mode-chip.active {
  background: rgba(40, 246, 213, 0.14);
  box-shadow: inset 0 0 14px rgba(40, 246, 213, 0.12), 0 0 16px rgba(40, 246, 213, 0.18);
}

#lockStatus {
  min-width: 0;
  color: #b7c8d6;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-sequence {
  grid-column: 1 / -1;
  color: rgba(245, 244, 234, 0.78);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readout-card {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.micro-label {
  display: block;
  color: var(--muted);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.string-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1;
}

.string-row strong {
  color: var(--cyan);
  font-size: clamp(2.55rem, 14vw, 3.8rem);
  line-height: 0.9;
  text-shadow: 0 0 18px rgba(40, 246, 213, 0.45);
}

.string-row span {
  color: var(--cyan);
  font-size: 1.5rem;
}

.string-row em {
  color: #c4c8cc;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 1rem;
  font-style: normal;
}

.selected-name {
  display: block;
  margin-top: 5px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.state-line {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.state-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--state);
  box-shadow: 0 0 18px rgba(var(--state-rgb), 0.75);
}

h1 {
  margin: 0;
  color: var(--state);
  font-size: clamp(1.24rem, 7vw, 2rem);
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(var(--state-rgb), 0.35);
}

.state-line p {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.92rem;
  text-transform: uppercase;
}

.meter-panel {
  margin-top: 8px;
  padding: 10px;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  color: #c4d3df;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.78rem;
}

.arc-meter {
  position: relative;
  height: 108px;
  margin: 0 0 8px;
}

.arc-meter svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 0 13px rgba(var(--state-rgb), 0.42));
}

.arc {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
}

.arc-red-left,
.arc-red-right {
  stroke: #ff2119;
}

.arc-orange-left,
.arc-orange-right {
  stroke: #ff8500;
}

.arc-yellow-left,
.arc-yellow-right {
  stroke: #ffee00;
}

.arc-green {
  stroke: #28f6d5;
}

.arc-needle {
  position: absolute;
  left: 50%;
  bottom: 14px;
  width: 4px;
  height: 72px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, #dffff2 58%, rgba(255, 255, 255, 0.4));
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.95);
  transform: translateX(-50%) rotate(var(--needle-angle));
  transform-origin: 50% 100%;
  transition: transform 180ms ease;
}

.arc-needle::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid #fff;
  transform: translateX(-50%);
}

.arc-pivot {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--state);
  border: 3px solid #f8fff4;
  box-shadow: 0 0 18px rgba(var(--state-rgb), 0.75);
  transform: translateX(-50%);
}

.meter-track {
  position: relative;
  height: 42px;
  margin: 4px 0 10px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 6px),
    linear-gradient(90deg, #ff334b 0%, #ff9b3d 18%, #ffd166 36%, #28f6d5 48%, #28f6d5 52%, #ffd166 64%, #ff9b3d 82%, #ff334b 100%);
  box-shadow:
    0 0 22px rgba(var(--state-rgb), 0.26),
    inset 0 0 12px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

.meter-track::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.48), transparent 44%, rgba(0, 0, 0, 0.58));
}

.meter-center {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 50%;
  width: 3px;
  background: #f7fff2;
  box-shadow: 0 0 12px #fff;
}

.meter-needle {
  position: absolute;
  left: var(--meter-x);
  bottom: 1px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 15px solid #fff;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9));
  transform: translateX(-50%);
  transition: left 170ms ease;
}

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

.readings-grid div {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(2, 6, 14, 0.84);
}

.readings-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--state);
  font-size: 1.28rem;
  line-height: 1.1;
}

.string-pad {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
  padding: 6px;
}

.string-button {
  min-width: 0;
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012)),
    rgba(4, 8, 18, 0.9);
  color: #efece4;
  cursor: pointer;
  padding: 6px 4px;
}

.string-button strong,
.string-button span,
.string-button em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.string-button strong {
  font-size: 1.36rem;
  line-height: 1;
}

.string-button span {
  color: #b8c5cf;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
}

.string-button em {
  color: #7f8c99;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.66rem;
  font-style: normal;
}

.string-button.active {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow:
    0 0 18px rgba(40, 246, 213, 0.36),
    inset 0 0 14px rgba(40, 246, 213, 0.12);
}

.string-button.manual-mode {
  border-color: rgba(255, 255, 255, 0.18);
}

.demo-panel {
  margin-top: 8px;
  padding: 10px;
}

.demo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.demo-header > div {
  min-width: 0;
}

.demo-header strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 0.82rem;
  text-transform: uppercase;
  white-space: normal;
}

.demo-slider {
  width: 100%;
  margin: 14px 0 2px;
  accent-color: var(--state);
}

.status-text {
  min-height: 24px;
  margin: 10px 2px 0;
  color: #a9b7c4;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 0.78rem;
  text-align: center;
}

@keyframes neonBreath {
  0% {
    transform: translate3d(-1.5%, 0, 0) scale(1);
    opacity: 0.72;
  }
  100% {
    transform: translate3d(1.5%, -1%, 0) scale(1.035);
    opacity: 1;
  }
}

@keyframes dustRise {
  0% {
    transform: translate3d(0, 5%, 0);
    background-position: 0 0, 28px 18px, 53px 63px;
  }
  100% {
    transform: translate3d(0, -5%, 0);
    background-position: 0 -184px, 28px -256px, 53px -346px;
  }
}

@keyframes stageSweep {
  0% {
    background-position: 120% 0, center, center, center;
  }
  100% {
    background-position: -20% 0, center, center, center;
  }
}

@keyframes frameVeil {
  0% {
    opacity: 0;
  }
  42% {
    opacity: 0.64;
  }
  100% {
    opacity: 0;
  }
}

@keyframes perfectFlamePop {
  0%,
  100% {
    transform: translateY(0) scale(calc(0.46 + var(--flame-level) * 0.18)) rotate(-1deg);
  }
  50% {
    transform: translateY(-2px) scale(calc(0.5 + var(--flame-level) * 0.2)) rotate(2deg);
  }
}

@keyframes perfectHeadBob {
  0%,
  100% {
    transform: translateX(-5px) translateY(0) rotate(-2.3deg) scale(1.03);
  }
  50% {
    transform: translateX(5px) translateY(2px) rotate(2.3deg) scale(1.035);
  }
}

@keyframes characterSway {
  0%,
  100% {
    transform: translateX(-4px) rotate(-1.65deg) scale(1.025);
  }
  50% {
    transform: translateX(4px) translateY(1px) rotate(1.65deg) scale(1.03);
  }
}

@keyframes warningShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes smokeDrift {
  0% {
    transform: translateY(28px) scale(0.84);
    opacity: 0;
  }
  30% {
    opacity: 0.28;
  }
  100% {
    transform: translateY(-72px) scale(1.5);
    opacity: 0;
  }
}

@keyframes flameFlicker {
  0% {
    transform: translateX(-1px) rotate(-4deg) scaleY(calc(0.72 + var(--flame-level) * 0.36));
  }
  100% {
    transform: translateX(2px) rotate(5deg) scaleY(calc(0.82 + var(--flame-level) * 0.46 + var(--overheat) * 0.24));
  }
}

@keyframes spriteFlicker {
  0% {
    transform: translateX(-1px) translateY(1px) rotate(-1.5deg) scaleX(0.98);
    filter: saturate(1.04) brightness(0.96);
  }
  100% {
    transform: translateX(1px) translateY(-2px) rotate(1.8deg) scaleX(1.04);
    filter: saturate(1.18) brightness(1.08);
  }
}

@keyframes overheatFlare {
  0% {
    filter:
      drop-shadow(0 0 calc(8px + var(--flame-level) * 22px) rgba(255, 139, 0, 0.72))
      drop-shadow(0 0 calc(10px + var(--flare-level) * 28px) rgba(255, 31, 24, 0.72));
  }
  100% {
    filter:
      drop-shadow(0 0 calc(12px + var(--flame-level) * 26px) rgba(255, 178, 36, 0.86))
      drop-shadow(0 0 calc(18px + var(--flare-level) * 34px) rgba(255, 31, 24, 0.82));
  }
}

@keyframes sparkPop {
  0%,
  100% {
    transform: translate(0, 0) scale(0.75);
  }
  50% {
    transform: translate(8px, -9px) scale(calc(0.8 + var(--spark-level) * 0.55));
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .character-stage::before,
  .flame-sprite,
  .spark,
  .smoke {
    animation: none !important;
  }
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: start center;
    padding: 24px;
  }

  .app-shell {
    min-height: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding:
      max(8px, calc(env(safe-area-inset-top, 0px) + 8px))
      max(8px, calc(env(safe-area-inset-right, 0px) + 8px))
      max(10px, calc(env(safe-area-inset-bottom, 0px) + 10px))
      max(8px, calc(env(safe-area-inset-left, 0px) + 8px));
  }

  .readout-card {
    grid-template-columns: 1fr;
  }

  .string-button {
    min-height: 54px;
  }
}

@media (min-width: 481px) and (max-width: 1100px) and (orientation: portrait) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    display: grid;
    place-items: start center;
  }

  .app-shell {
    width: min(78vw, 760px);
    max-width: calc(100vw - 24px);
    height: auto;
    min-height: 0;
    max-height: calc(100dvh - 12px);
    display: flex;
    flex-direction: column;
    margin: 6px auto;
    padding:
      max(8px, calc(env(safe-area-inset-top, 0px) + 8px))
      max(8px, calc(env(safe-area-inset-right, 0px) + 8px))
      max(8px, calc(env(safe-area-inset-bottom, 0px) + 8px))
      max(8px, calc(env(safe-area-inset-left, 0px) + 8px));
    overflow: hidden;
    box-shadow:
      inset 0 0 0 2px rgba(0, 0, 0, 0.88),
      inset 0 0 0 3px rgba(40, 246, 213, 0.18),
      0 0 54px rgba(0, 0, 0, 0.86);
  }

  .topbar,
  .hero-panel,
  .mode-row,
  .string-pad {
    flex: 0 0 auto;
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 5px;
  }

  .logo {
    width: min(calc(100% - 118px), 212px);
    max-height: 58px;
  }

  .icon-button,
  .demo-reset {
    min-width: 42px;
    min-height: 42px;
  }

  .character-stage {
    aspect-ratio: 2.16 / 1;
  }

  .meter-panel {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .arc-meter {
    flex: 0 0 auto;
    min-height: 0;
    height: clamp(128px, 18dvh, 160px);
  }

  .readings-grid {
    flex: 0 0 auto;
  }

  .status-text {
    flex: 0 0 auto;
    margin-top: 7px;
  }
}

@media (max-width: 480px) and (max-height: 932px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  body {
    display: grid;
    place-items: center;
    background: #000;
  }

  body::before,
  body::after {
    opacity: 0.46;
  }

  .app-shell {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    padding:
      max(5px, calc(env(safe-area-inset-top, 0px) + 5px))
      max(6px, calc(env(safe-area-inset-right, 0px) + 6px))
      max(5px, calc(env(safe-area-inset-bottom, 0px) + 5px))
      max(6px, calc(env(safe-area-inset-left, 0px) + 6px));
    border: 0;
    border-radius: 0;
    overflow: hidden;
    box-shadow:
      inset 0 0 0 3px #000,
      inset 0 0 0 4px rgba(40, 246, 213, 0.18),
      0 0 44px rgba(0, 0, 0, 0.92);
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
    min-height: 74px;
    padding: 4px 0 6px;
    margin-bottom: 5px;
    align-items: center;
    flex: 0 0 auto;
  }

  .logo {
    width: min(calc(100vw - 118px), clamp(184px, 49vw, 212px));
    max-height: 74px;
    transform: none;
  }

  .top-actions {
    max-width: 86px;
    gap: 6px;
  }

  .icon-button,
  .demo-reset {
    min-width: 36px;
    min-height: 36px;
    padding: 0 5px;
    font-size: 0.6rem;
  }

  .hero-panel {
    flex: 0 0 auto;
    gap: 5px;
  }

  .character-stage {
    aspect-ratio: 2.04 / 1;
  }

  .tune-overlay {
    padding: 6px 8px;
  }

  .micro-label {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
  }

  .tune-overlay strong {
    margin-top: 1px;
    font-size: 1rem;
  }

  .tune-overlay p {
    margin-top: 2px;
    font-size: 0.68rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .readout-card {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr) !important;
    gap: 7px;
    padding: 7px 8px;
  }

  .string-row {
    gap: 5px;
  }

  .string-row strong {
    font-size: clamp(2.05rem, 11vw, 2.75rem);
  }

  .string-row span {
    font-size: 1.1rem;
  }

  .string-row em {
    font-size: 0.78rem;
  }

  .selected-name {
    margin-top: 2px;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }

  .state-line {
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 6px;
  }

  .state-dot {
    width: 14px;
    height: 14px;
  }

  .state-line h1 {
    font-size: clamp(1rem, 5.2vw, 1.36rem) !important;
    line-height: 0.96;
  }

  .state-line p {
    margin-top: 2px;
    font-size: 0.72rem;
  }

  .mode-row {
    flex: 0 0 auto;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
    margin-top: 6px;
    padding: 6px;
  }

  .mode-chip {
    min-height: 30px;
    padding: 0 8px;
    font-size: 0.58rem;
  }

  #lockStatus {
    font-size: 0.74rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .auto-sequence {
    font-size: 0.62rem;
    line-height: 1.05;
  }

  .string-pad {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
    margin-top: 6px;
    padding: 4px;
    overflow: hidden;
  }

  .string-button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 48px;
    padding: 4px 2px;
    border-radius: 7px;
  }

  .string-button strong {
    font-size: 1.04rem;
  }

  .string-button span {
    font-size: 0.5rem;
  }

  .string-button em {
    font-size: 0.52rem;
  }

  .meter-panel {
    flex: 0 0 auto;
    min-height: 0;
    margin-top: 6px;
    padding: 7px 9px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .meter-labels {
    font-size: 0.7rem;
  }

  .arc-meter {
    flex: 0 0 auto;
    min-height: 0;
    height: clamp(96px, 17dvh, 150px);
    margin-bottom: 4px;
  }

  .arc-needle {
    bottom: 12%;
    height: min(108px, 62%);
  }

  .arc-pivot {
    bottom: 8%;
  }

  .readings-grid {
    flex: 0 0 auto;
    gap: 6px;
  }

  .readings-grid div {
    padding: 5px 8px;
  }

  .readings-grid strong {
    margin-top: 1px;
    font-size: 1rem;
  }

  .demo-panel {
    flex: 0 0 auto;
    margin-top: 6px;
    padding: 6px 8px;
  }

  .demo-header {
    gap: 8px;
  }

  .demo-header strong {
    font-size: 0.8rem;
  }

  .demo-slider {
    margin: 6px 0 0;
  }

  .status-text {
    display: none;
  }
}

@media (max-width: 390px) and (max-height: 820px) {
  .app-shell {
    padding:
      max(7px, calc(env(safe-area-inset-top, 0px) + 7px))
      max(8px, calc(env(safe-area-inset-right, 0px) + 8px))
      max(7px, calc(env(safe-area-inset-bottom, 0px) + 7px))
      max(8px, calc(env(safe-area-inset-left, 0px) + 8px));
  }

  .topbar {
    min-height: 52px;
    padding: 1px 0 2px;
    margin-bottom: 2px;
  }

  .logo {
    width: min(calc(100vw - 104px), 170px);
    max-height: 52px;
  }

  .character-stage {
    aspect-ratio: 2.65 / 1;
  }

  .tune-overlay {
    padding: 5px 7px;
  }

  .readout-card {
    padding: 6px 7px;
  }

  .mode-row {
    margin-top: 5px;
    padding: 5px;
  }

  .string-pad {
    margin-top: 5px;
    padding: 3px;
    gap: 3px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .string-button {
    min-height: 42px;
    padding: 3px 1px;
    border-radius: 6px;
  }

  .string-button strong {
    font-size: 0.88rem;
  }

  .string-button span {
    font-size: 0.4rem;
  }

  .string-button em {
    font-size: 0.42rem;
  }

  .arc-meter {
    flex: 0 0 auto;
    min-height: 0;
    height: 86px;
    margin-bottom: 3px;
  }

  .arc-needle {
    bottom: 11px;
    height: 58px;
  }

  .arc-pivot {
    bottom: 6px;
  }

  .meter-panel {
    flex: 0 0 auto;
    margin-top: 5px;
    padding: 5px 7px;
  }

  .readings-grid {
    gap: 4px;
  }

  .readings-grid div {
    padding: 3px 6px;
  }

  .readings-grid strong {
    font-size: 0.86rem;
  }

  .demo-panel {
    margin-top: 5px;
    padding: 5px 7px;
  }

  .demo-header strong {
    font-size: 0.68rem;
  }

  .demo-slider {
    margin-top: 4px;
  }
}

@media (max-width: 480px) and (max-height: 760px) {
  .demo-panel {
    display: none;
  }

  .meter-panel {
    padding-bottom: 8px;
  }

  .arc-meter {
    height: 74px;
  }

  .readings-grid div {
    padding: 4px 6px;
  }
}
