* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #01030a;
  color: #f7fbff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #01030a;
}

button {
  font: inherit;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 520px;
  background: #01030a;
}

.shell:fullscreen,
.shell:-webkit-full-screen,
.album-modal:fullscreen,
.album-modal:-webkit-full-screen,
body.pseudo-fullscreen .shell {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  background: #01030a;
}

body.pseudo-fullscreen .album-modal {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.top-tools {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 10px;
  z-index: 13;
  display: flex;
  gap: 8px;
  align-items: center;
}

.language-select,
.fullscreen-button {
  height: 34px;
  border: 1px solid rgba(120, 228, 255, 0.36);
  border-radius: 8px;
  color: #d9f7ff;
  background: rgba(5, 10, 24, 0.82);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(34, 220, 255, 0.08);
}

.language-select {
  max-width: 126px;
  padding: 0 8px;
}

.fullscreen-button {
  min-width: 48px;
  padding: 0 10px;
}

.debug-toggle {
  position: absolute;
  top: auto;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 10px;
  z-index: 12;
  min-width: 56px;
  height: 34px;
  border: 1px solid rgba(120, 228, 255, 0.35);
  border-radius: 8px;
  color: #d9f7ff;
  background: rgba(5, 10, 24, 0.84);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  display: none;
}

body.debug-enabled .debug-toggle {
  display: block;
}

.debug-panel {
  position: absolute;
  top: auto;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 44px);
  left: 10px;
  z-index: 12;
  display: none;
  width: min(300px, calc(100vw - 20px));
  padding: 12px;
  border: 1px solid rgba(120, 228, 255, 0.35);
  border-radius: 8px;
  background: rgba(5, 10, 24, 0.9);
  box-shadow: 0 0 36px rgba(34, 220, 255, 0.14);
  pointer-events: auto;
}

.debug-panel.open {
  display: block;
}

.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #f7fbff;
  font-size: 13px;
  font-weight: 900;
}

.debug-head span {
  color: #94a7bf;
  font-size: 11px;
  text-transform: uppercase;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0 0;
}

.debug-grid div,
.debug-next {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(116, 224, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.debug-grid dt,
.debug-next span {
  display: block;
  margin: 0;
  color: #94a7bf;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.debug-grid dd,
.debug-next strong {
  display: block;
  margin: 5px 0 0;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.1;
}

.debug-next {
  margin-top: 6px;
}

.debug-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.debug-actions button {
  min-width: 0;
  height: 30px;
  border: 1px solid rgba(120, 228, 255, 0.28);
  border-radius: 8px;
  color: #06101d;
  background: #6be8ff;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.hud {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 10px;
  z-index: 5;
  width: min(370px, calc(100vw - 20px));
  pointer-events: none;
}

.hud-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hud-row > div {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(116, 224, 255, 0.28);
  background: rgba(5, 10, 24, 0.84);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(68, 219, 255, 0.08);
}

.label {
  display: block;
  color: #94a7bf;
  font-size: 10px;
  line-height: 1;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  line-height: 1;
  color: #ffffff;
}

.progress {
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #35f08f, #ffd447);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.run-status,
.combo-status,
.fever-status,
.shield-status,
.grip-status,
.size-status,
.rule-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(116, 224, 255, 0.26);
  border-radius: 8px;
  color: #bdf7ff;
  background: rgba(5, 10, 24, 0.84);
  font-size: 12px;
  font-weight: 900;
}

.run-status.danger {
  border-color: rgba(255, 56, 92, 0.58);
  color: #ffc7d0;
}

.combo-status {
  color: #ffd447;
  border-color: rgba(255, 212, 71, 0.4);
  background: rgba(34, 25, 5, 0.82);
}

.combo-status.hot {
  color: #ffffff;
  border-color: rgba(255, 212, 71, 0.78);
  box-shadow: 0 0 18px rgba(255, 212, 71, 0.22);
}

.fever-status {
  color: #c79cff;
  border-color: rgba(157, 108, 255, 0.42);
  background: rgba(25, 11, 34, 0.82);
}

.fever-status.hot {
  color: #ffffff;
  border-color: rgba(199, 156, 255, 0.82);
  box-shadow: 0 0 18px rgba(157, 108, 255, 0.28);
}

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

.choice {
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid rgba(116, 224, 255, 0.18);
  border-radius: 8px;
  background: rgba(5, 10, 24, 0.84);
  color: #e9f7ff;
  text-align: center;
}

.choice span {
  display: block;
  color: #94a7bf;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.choice strong {
  display: block;
  min-height: 18px;
  margin-top: 5px;
  font-size: 15px;
  line-height: 1;
}

.choice.add strong {
  color: #35f08f;
}

.choice.subtract strong {
  color: #ff385c;
}

.choice.multiply strong {
  color: #c79cff;
}

.choice.divide strong {
  color: #ff8a3d;
}

.choice.block strong {
  color: #d7e5f6;
}

.choice.spike strong {
  color: #ff174f;
}

.choice.slip strong {
  color: #75e8ff;
}

.choice.target strong {
  color: #ffd447;
}

.choice.quiz strong {
  color: #39f5c9;
  font-size: 17px;
}

.choice.rule strong {
  color: #ff9f1c;
  font-size: 12px;
}

.shield-status {
  color: #a7f0ff;
  border-color: rgba(91, 216, 255, 0.42);
  background: rgba(7, 25, 36, 0.82);
}

.shield-status.active {
  color: #ffffff;
  border-color: rgba(167, 240, 255, 0.84);
  box-shadow: 0 0 18px rgba(91, 216, 255, 0.28);
}

.choice.shield strong {
  color: #a7f0ff;
}

.grip-status {
  color: #9fb2c8;
  border-color: rgba(159, 178, 200, 0.28);
  background: rgba(9, 16, 28, 0.82);
}

.grip-status.active {
  color: #a8ffc8;
  border-color: rgba(53, 240, 143, 0.48);
  background: rgba(9, 31, 19, 0.84);
}

.grip-status.low {
  color: #ffe3b0;
  border-color: rgba(255, 138, 61, 0.64);
  background: rgba(42, 22, 3, 0.84);
  box-shadow: 0 0 18px rgba(255, 138, 61, 0.2);
}

.size-status {
  color: #a8ffc8;
  border-color: rgba(53, 240, 143, 0.38);
  background: rgba(9, 31, 19, 0.78);
}

.size-status.tiny {
  color: #bdf7ff;
  border-color: rgba(116, 224, 255, 0.34);
  background: rgba(5, 22, 32, 0.78);
}

.size-status.big {
  color: #ffd447;
  border-color: rgba(255, 212, 71, 0.48);
  background: rgba(34, 25, 5, 0.82);
}

.size-status.heavy {
  color: #ffe3b0;
  border-color: rgba(255, 138, 61, 0.64);
  background: rgba(42, 22, 3, 0.84);
}

.size-status.overload {
  color: #ffc7d0;
  border-color: rgba(255, 56, 92, 0.72);
  background: rgba(42, 5, 14, 0.86);
  box-shadow: 0 0 18px rgba(255, 56, 92, 0.2);
}

.rule-status {
  color: #94a7bf;
  border-color: rgba(255, 159, 28, 0.34);
  background: rgba(42, 22, 3, 0.72);
}

.rule-status.active {
  color: #ffe3b0;
  border-color: rgba(255, 159, 28, 0.76);
  box-shadow: 0 0 18px rgba(255, 159, 28, 0.2);
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  background: rgba(3, 6, 16, 0.42);
}

.overlay.hidden {
  display: none;
}

.album-modal {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background:
    radial-gradient(circle at 52% 38%, rgba(255, 246, 206, 0.08), transparent 22%),
    radial-gradient(circle at 76% 22%, rgba(57, 245, 201, 0.12), transparent 30%),
    radial-gradient(circle at 15% 78%, rgba(91, 216, 255, 0.1), transparent 30%),
    linear-gradient(180deg, rgba(0, 2, 9, 0.99), rgba(2, 5, 17, 1));
}

.album-modal.hidden {
  display: none;
}

.album-card {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  padding: clamp(14px, 2.1vw, 26px);
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.045) 0 1px, transparent 1.7px),
    radial-gradient(circle at 80% 40%, rgba(91, 216, 255, 0.06) 0 1px, transparent 1.7px);
  background-size: 118px 118px, 176px 176px;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.72);
}

.album-card-head,
.album-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1440px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.album-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.album-card-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 0 14px;
  border-bottom: 1px solid rgba(120, 228, 255, 0.16);
  background: linear-gradient(180deg, rgba(0, 2, 9, 0.98) 72%, rgba(0, 2, 9, 0));
}

.album-card h2,
.album-card h3,
.album-card p {
  margin: 0;
}

.album-card h2 {
  color: #f7fbff;
  font-size: clamp(20px, 2.5vw, 30px);
  line-height: 1;
}

.album-card button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid rgba(120, 228, 255, 0.36);
  border-radius: 999px;
  color: #d9f7ff;
  background: rgba(5, 10, 24, 0.72);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(57, 245, 201, 0.08);
}

.album-card-head button {
  min-width: 72px;
}

.album-page {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(12px, 1.6vw, 18px);
  align-items: start;
  width: min(1220px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: clamp(12px, 1.6vh, 18px) 0 12px;
}

.album-visual {
  min-height: clamp(340px, 55vh, 520px);
  border: 1px solid rgba(120, 228, 255, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 246, 206, 0.1), transparent 18%),
    radial-gradient(circle at 50% 42%, rgba(57, 245, 201, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(4, 9, 24, 0.58), rgba(0, 2, 8, 0.84));
  box-shadow:
    0 0 90px rgba(57, 245, 201, 0.12),
    inset 0 0 90px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.album-sky {
  position: relative;
  min-height: clamp(340px, 55vh, 520px);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 246, 206, 0.56) 0 1px, transparent 1.8px),
    radial-gradient(circle at 28% 66%, rgba(91, 216, 255, 0.42) 0 1px, transparent 1.7px),
    radial-gradient(circle at 82% 24%, rgba(255, 255, 255, 0.45) 0 1px, transparent 1.6px),
    radial-gradient(circle at 68% 82%, rgba(255, 212, 71, 0.4) 0 1px, transparent 1.7px);
  background-size: 96px 96px, 134px 134px, 172px 172px, 218px 218px;
  animation: albumStars 16s linear infinite;
}

.album-sky::before,
.album-sky::after {
  content: "";
  position: absolute;
  width: 36%;
  height: 1px;
  left: -16%;
  top: 24%;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 206, 0.88), transparent);
  transform: rotate(-18deg);
  animation: albumMeteor 7s ease-in-out infinite;
}

.album-sky::after {
  top: 66%;
  animation-delay: 3.2s;
  animation-duration: 9s;
  opacity: 0.6;
}

.album-orbit {
  position: absolute;
  inset: 13%;
  border: 1px solid rgba(91, 216, 255, 0.11);
  border-radius: 50%;
  transform: rotate(-10deg);
}

.album-orbit.two {
  inset: 24% 12%;
  border-color: rgba(255, 212, 71, 0.12);
  transform: rotate(28deg);
}

.album-constellation-svg {
  position: absolute;
  top: 8%;
  left: 21%;
  width: 76%;
  height: 88%;
  filter: drop-shadow(0 0 24px rgba(57, 245, 201, 0.32));
}

.album-hero-copy {
  position: absolute;
  left: clamp(18px, 2.2vw, 32px);
  top: clamp(18px, 2.2vw, 30px);
  bottom: auto;
  z-index: 2;
  max-width: min(390px, 36%);
  padding: 0 0 0 16px;
  border-left: 2px solid rgba(255, 212, 71, 0.6);
  background: linear-gradient(90deg, rgba(0, 2, 9, 0.54), rgba(0, 2, 9, 0.24) 72%, transparent);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.86);
}

.album-constellation-line {
  stroke: rgba(91, 216, 255, 0.86);
  stroke-width: 0.68;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: albumLineTrace 1.6s ease forwards;
}

.album-constellation-star {
  fill: #fff6ce;
  stroke: #39f5c9;
  stroke-width: 0.34;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: albumStarPop 1.2s ease forwards, albumStarPulse 2.8s ease-in-out infinite;
}

.album-constellation-star.key {
  fill: #ffd447;
  stroke: #fff6ce;
}

.album-story {
  position: relative;
  align-self: stretch;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: hidden;
}

.album-index {
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(255, 212, 71, 0.28);
  border-radius: 999px;
  color: #ffd447;
  background: rgba(255, 212, 71, 0.07);
  font-size: 11px;
  font-weight: 900;
}

.album-hero-copy h3 {
  margin-top: 12px;
  color: #fff6ce;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(24px, 2.35vw, 34px);
  line-height: 1.06;
  letter-spacing: 0;
}

.album-subtitle {
  margin-top: 6px;
  color: #5bd8ff;
  font-size: clamp(14px, 1.4vw, 18px);
  font-weight: 900;
}

.album-short {
  margin-top: 10px;
  color: #ffd447;
  font-size: clamp(13px, 1.15vw, 16px);
  font-weight: 900;
}

.album-story-text {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 0 clamp(8px, 1.2vw, 16px);
  color: #d8ecff;
  font-size: clamp(14px, 1.15vw, 16px);
  line-height: 1.78;
}

.album-story-text p {
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid rgba(120, 228, 255, 0.18);
}

.album-nav {
  margin-top: 0;
  padding-top: 2px;
}

.album-nav button {
  flex: 0 0 min(220px, 48%);
  height: 42px;
}

@keyframes albumStars {
  from { background-position: 0 0, 0 0, 0 0, 0 0; }
  to { background-position: 96px 72px, -134px 94px, 172px -90px, -218px -120px; }
}

@keyframes albumMeteor {
  0%, 54% { transform: translateX(-30%) translateY(-20px) rotate(-18deg); opacity: 0; }
  60% { opacity: 0.9; }
  72% { transform: translateX(280%) translateY(120px) rotate(-18deg); opacity: 0; }
  100% { transform: translateX(280%) translateY(120px) rotate(-18deg); opacity: 0; }
}

@keyframes albumLineTrace {
  to { stroke-dashoffset: 0; }
}

@keyframes albumStarPop {
  from { opacity: 0; transform: scale(0.4); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes albumStarPulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255, 246, 206, 0.55)); }
  50% { filter: drop-shadow(0 0 10px rgba(57, 245, 201, 0.9)); }
}

@media (max-width: 820px) {
  .album-card {
    padding: 14px;
  }

  .album-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .album-card-actions {
    width: 100%;
  }

  .album-card-actions button {
    flex: 1;
  }

  .album-page {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 12px 0;
  }

  .album-visual {
    min-height: 360px;
  }

  .album-sky {
    min-height: 360px;
  }

  .album-hero-copy {
    left: 14px;
    right: 14px;
    top: 14px;
    bottom: auto;
    max-width: none;
    padding-left: 12px;
  }

  .album-constellation-svg {
    top: 30%;
    left: 4%;
    width: 92%;
    height: 65%;
  }

  .album-story {
    align-self: stretch;
  }

  .album-nav button {
    flex: 1;
  }
}

.panel {
  width: min(320px, calc(100vw - 48px));
  max-width: 320px;
  padding: 20px;
  border: 1px solid rgba(120, 228, 255, 0.35);
  border-radius: 8px;
  background: rgba(7, 11, 26, 0.88);
  box-shadow: 0 0 44px rgba(34, 220, 255, 0.18);
}

.eyebrow {
  margin: 0 0 8px;
  color: #7ae8ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

.panel p {
  margin: 0 0 16px;
  color: #d7e5f6;
  font-size: 14px;
  line-height: 1.45;
}

.panel button {
  width: 100%;
  height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  color: #06101d;
  background: #6be8ff;
  font-weight: 800;
  cursor: pointer;
}

.panel .album-button {
  height: 38px;
  border: 1px solid rgba(120, 228, 255, 0.45);
  color: #f7fbff;
  background: linear-gradient(90deg, #326dff, #35c8ff);
  font-size: 13px;
  box-shadow: 0 0 18px rgba(53, 200, 255, 0.16);
}

.panel .album-button {
  background: linear-gradient(90deg, #221905, #a57605);
  box-shadow: 0 0 18px rgba(255, 212, 71, 0.16);
}

.panel button + button {
  border: 1px solid rgba(120, 228, 255, 0.35);
  color: #d9f7ff;
  background: rgba(255, 255, 255, 0.06);
}

.panel #primaryButton {
  border: 0;
  color: #06101d;
  background: #6be8ff;
}
