:root {
  color-scheme: dark;
  --night: #10060a;
  --cream: #f8e7c1;
  --gold: #e6c36a;
  --gold-soft: #f3de9a;
  --ink: #1a090e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(122, 24, 40, 0.55), transparent 52%),
    radial-gradient(ellipse at 90% 110%, rgba(180, 130, 40, 0.16), transparent 40%),
    #070306;
  color: var(--cream);
  font-family: Padauk, "Noto Sans Myanmar", "Myanmar Text", sans-serif;
  line-height: 1.55;
}

button { font: inherit; color: inherit; }

img { max-width: 100%; display: block; }

button:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 2px;
}

.shell {
  width: min(480px, 100%);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.boot {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(120, 24, 40, 0.5), transparent 48%),
    rgba(7, 3, 6, 0.94);
}

.boot[hidden] { display: none !important; }

.boot img {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 0 24px rgba(230, 195, 106, 0.4);
}

.boot h1 {
  margin: 0;
  font-family: Cinzel, Palatino, "Times New Roman", serif;
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cream);
}

.boot-line { margin: 0; }

.boot-bar {
  width: min(140px, 40vw);
  height: 3px;
  border-radius: 999px;
  background: rgba(230, 195, 106, 0.25);
  overflow: hidden;
  display: block;
}

.boot-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  background: var(--gold);
  animation: load 0.9s ease infinite;
}

@keyframes load {
  from { transform: translateX(-120%); }
  to { transform: translateX(320%); }
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.mast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px 0;
}

.crest {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold);
  flex: none;
}

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

.brand strong {
  display: block;
  font-family: Cinzel, Palatino, "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.brand span {
  display: block;
  color: var(--gold);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sound {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(230, 195, 106, 0.55);
  background: #2a0c14;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 0 0 9px;
}

.sound i {
  width: 3px;
  height: 8px;
  border-radius: 99px;
  background: var(--gold-soft);
  display: block;
}

.sound i:nth-child(2) { height: 14px; }
.sound i:nth-child(3) { height: 10px; }

.sound.is-muted i { opacity: 0.25; }
.sound.is-muted i:nth-child(2) { opacity: 1; height: 16px; transform: rotate(28deg); }

.rail {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 8px 6px 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar { display: none; }

.rail::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 16px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(230, 195, 106, 0.9), transparent);
}

.bulb {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  min-width: 58px;
  border: 0;
  background: transparent;
  color: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}

.glass {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7a3142, #240810 72%);
  box-shadow: inset 0 0 0 1px rgba(230, 195, 106, 0.45);
}

.bulb.is-on .glass {
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 35% 30%, #fff6d0, #e6c36a 46%, #8d6118 78%);
  box-shadow: 0 0 12px #e6c36a;
}

.bulb .name {
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.bulb.is-on .name { color: var(--gold-soft); }

main {
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.view[hidden] { display: none !important; }

.stage-view.is-on {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  user-select: none;
  -webkit-user-select: none;
}

.sheet.is-on {
  display: block;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-pad {
  padding: 8px 14px 28px;
  min-width: 0;
}

.sheet-pad h2,
.veil h2,
.place-copy h3,
.instrument-body h3,
.subhead {
  margin: 4px 0 8px;
  line-height: 1.3;
  font-size: clamp(22px, 6vw, 28px);
}

.place-copy h3,
.instrument-body h3,
.subhead { font-size: 20px; }

.lead, .place-copy p, .instrument-body p, .sheet-pad > p, .cues p {
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.song-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 8px 10px 0;
  scrollbar-width: none;
}

.song-row::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  max-width: 148px;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: 14px;
  border: 1px solid rgba(230, 195, 106, 0.4);
  background: rgba(28, 8, 14, 0.88);
  text-align: left;
}

.chip b, .chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 128px;
}

.chip small { color: var(--gold); font-size: 11px; }

.chip.is-on {
  background: linear-gradient(180deg, #f3de9a, #c8963c);
  color: var(--ink);
  border-color: transparent;
}

.chip.is-on small { color: #5c3d12; }

.chip.is-locked { opacity: 0.55; }

.voice-line {
  margin: 0;
  padding: 4px 12px 0;
  color: var(--gold);
  font-size: 12px;
}

.song-blurb {
  margin: 0;
  padding: 2px 12px 0;
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.song-blurb[hidden] { display: none !important; }

.hud {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 0;
  min-width: 0;
}

.hud p {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(20, 6, 10, 0.78);
  border: 1px solid rgba(230, 195, 106, 0.32);
}

.hud span {
  display: block;
  font-size: 10px;
  color: var(--gold);
}

.hud strong {
  display: block;
  font-size: clamp(14px, 4.2vw, 20px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.hud small { font-size: 10px; color: var(--cream); }

.pause-key {
  width: 42px;
  height: 44px;
  flex: none;
  border-radius: 12px;
  border: 1px solid rgba(230, 195, 106, 0.5);
  background: #3a1020;
  color: var(--cream);
}

.pause-key:disabled { opacity: 0.4; }

.playfield {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 10px 0;
}

.arena {
  position: relative;
  flex: 1;
  min-height: 120px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(230, 195, 106, 0.45);
  background: #14060c;
}

.arena canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.count-in {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 38%;
  text-align: center;
  font-size: clamp(48px, 16vw, 72px);
  line-height: 1;
  color: #f8e7b0;
  text-shadow: 0 0 18px rgba(230, 195, 106, 0.85);
  pointer-events: none;
}

.count-in[hidden] { display: none !important; }

.judge {
  position: absolute;
  z-index: 2;
  left: 8px;
  right: 8px;
  top: 16%;
  text-align: center;
  font-size: clamp(22px, 7vw, 32px);
  color: #f8e7b0;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.judge.is-on { animation: pop 0.55s ease; }

@keyframes pop {
  0% { opacity: 0; transform: translateY(8px); }
  20% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}

.arena.is-miss { animation: missFlash 0.35s ease; }

@keyframes missFlash {
  from { box-shadow: inset 0 0 36px rgba(160, 20, 40, 0.65); }
  to { box-shadow: inset 0 0 0 rgba(160, 20, 40, 0); }
}

.veil-wrap {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.veil-wrap[hidden] { display: none !important; }

.veil {
  width: min(100%, 340px);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(32, 10, 16, 0.95), rgba(12, 4, 8, 0.95)) padding-box,
    linear-gradient(180deg, #f3de9a, #8a6a2f) border-box;
  border: 1px solid transparent;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.veil h2 { font-size: clamp(22px, 6vw, 28px); }

.veil ul { margin: 0 0 6px; padding-left: 18px; }
.veil li { font-size: 13px; line-height: 1.35; }

.veil li { margin: 0 0 6px; }

.gold-action, .quiet-action {
  width: 100%;
  min-height: 48px;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
}

.gold-action {
  border: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f8e7b0, #d7a441 55%, #a67c2d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 8px 16px rgba(0, 0, 0, 0.28);
}

.quiet-action {
  border: 1px solid rgba(230, 195, 106, 0.65);
  background: transparent;
  color: var(--cream);
}

.gold-action:active, .quiet-action:active { transform: translateY(1px); }

.gold-action:disabled, .quiet-action:disabled { opacity: 0.45; }

.veil .gold-action, .veil .quiet-action, .instrument-body .gold-action, .instrument-body .quiet-action, .sheet-pad > .gold-action {
  margin-top: 8px;
}

.veil h2 { margin: 2px 0 6px; }
.veil li { margin: 0 0 4px; }

.end-ring {
  width: 84px;
  height: 84px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), rgba(230, 195, 106, 0.18) 0);
}

.end-ring span {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #14080e;
  font-family: Cinzel, Palatino, "Times New Roman", serif;
  font-size: 28px;
  color: #f8e7b0;
}

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.end-stats p {
  margin: 0;
  min-width: 0;
  padding: 6px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
}

.end-stats span { display: block; font-size: 11px; color: var(--gold); }
.end-stats b { display: block; font-size: 18px; line-height: 1.2; }

.unlock-line { margin: 8px 0 0; color: var(--gold-soft); font-size: 14px; }
.unlock-line:empty { display: none; }

.lane-keys {
  display: flex;
  gap: 8px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  touch-action: none;
}

.lane-keys button {
  flex: 1;
  min-width: 0;
  height: 58px;
  border-radius: 16px;
  border: 1px solid rgba(243, 222, 154, 0.75);
  background: linear-gradient(180deg, #f3de9a, #c4923a 58%, #7a5a22);
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  touch-action: none;
}

.lane-keys button:nth-child(2) { background: linear-gradient(180deg, #f6d0a4, #d4894a 60%, #7a4320); }
.lane-keys button:nth-child(3) { background: linear-gradient(180deg, #f0c2c8, #c45d6e 60%, #6e2434); }
.lane-keys button:nth-child(4) { background: linear-gradient(180deg, #f7e7b4, #e0b44a 55%, #8a6230); }
.lane-keys button.is-down { transform: translateY(2px); filter: brightness(1.12); }
.lane-keys.on-beat button { box-shadow: 0 0 0 1px rgba(255, 246, 214, 0.85); }
.lane-keys.is-idle { opacity: 0.55; }

.place {
  margin: 0 0 12px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(230, 195, 106, 0.5);
  background: #16080e;
}

.place img {
  width: 100%;
  height: 148px;
  object-fit: cover;
}

.place.is-locked img { filter: grayscale(0.65) brightness(0.55); }

.place-copy { padding: 12px; min-width: 0; }

.lock-badge { display: none; color: #e7c9a2; font-size: 12px; }
.place.is-locked .lock-badge { display: inline-block; }

.instrument {
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin: 0 0 14px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(230, 195, 106, 0.4);
  background: rgba(22, 8, 14, 0.9);
}

.instrument img {
  width: 92px;
  min-height: 120px;
  height: auto;
  align-self: stretch;
  object-fit: cover;
  border-radius: 12px;
  flex: none;
}

.instrument-body { flex: 1; min-width: 0; }

.hero {
  margin: 0 0 12px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(230, 195, 106, 0.5);
}

.hero img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.cues {
  list-style: none;
  margin: 0 0 16px;
  padding: 0 0 0 16px;
  border-left: 2px solid rgba(230, 195, 106, 0.55);
}

.cues li {
  position: relative;
  margin: 0 0 14px;
  padding-left: 12px;
}

.cues li::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.cues h3 { margin: 0 0 4px; font-size: 18px; }

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid rgba(230, 195, 106, 0.2);
}

.score-row b, .score-row span { min-width: 0; overflow-wrap: anywhere; }
.score-row span { text-align: right; font-size: 13px; }

.empty-line { margin: 8px 0 0; }

.noscript { margin: 8px 10px 0; color: var(--gold-soft); }

@media (max-height: 760px) {
  .song-blurb, .voice-line { display: none !important; }
}

@media (max-height: 560px) {
  .bulb .name { display: none; }
  .crest { width: 28px; height: 28px; }
  .mast { padding-top: 4px; }
  .brand strong { font-size: 16px; }
  .rail { padding-top: 4px; padding-bottom: 4px; }
  .song-row { padding-top: 4px; }
  .chip { min-height: 36px; padding: 4px 8px; }
  .hud { padding-top: 4px; }
  .hud p { padding: 2px 4px; }
  .playfield { padding-top: 4px; }
  .arena { min-height: 0; }
  .lane-keys { padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .lane-keys button { height: 46px; }
}

@media (max-height: 430px) {
  .boot img { width: 64px; height: 64px; }
  .boot h1 { font-size: 24px; }
  .lane-keys button { height: 42px; }
  .place img, .hero img { height: 110px; }
  .song-row { display: none; }
  .hud, .playfield { padding-top: 2px; }
  .veil { padding: 8px 10px; }
  .veil .kicker, .veil ul { display: none; }
  .veil h2 { font-size: 16px; line-height: 1.2; margin: 0 0 6px; }
  .veil .gold-action, .veil .quiet-action { min-height: 36px; padding: 6px 10px; margin-top: 0; }
}

@media (max-width: 340px) {
  .hud span { font-size: 9px; }
  .lane-keys { gap: 6px; }
  .lane-keys button { height: 52px; font-size: 16px; }
  .instrument { gap: 8px; padding: 8px; }
  .instrument img { width: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-bar::after, .judge.is-on, .arena.is-miss { animation: none; }
}
