:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #171c20;
  --surface-2: #20282e;
  --surface-3: #26323a;
  --line: #34444d;
  --muted: #a9b8bf;
  --text: #f5f8f7;
  --teal: #2dd4bf;
  --blue: #64a8ff;
  --lime: #b7e45f;
  --amber: #f4b740;
  --coral: #ff6f61;
  --ink: #0b1012;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    #101214;
  background-size: 42px 42px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible {
  outline: 3px solid rgba(45, 212, 191, 0.5);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p,
span,
strong,
button {
  overflow-wrap: anywhere;
}

.app-shell {
  width: min(100% - 20px, 1540px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  display: grid;
  align-content: center;
}

.arcade-shell {
  overflow: hidden;
  border: 1px solid rgba(169, 184, 191, 0.2);
  border-radius: 8px;
  background: rgba(23, 28, 32, 0.93);
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(169, 184, 191, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(45, 212, 191, 0.48);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #11191b;
}

.brand-mark span {
  width: 20px;
  height: 20px;
  border: 3px solid var(--teal);
  box-shadow: inset 0 0 0 5px #11191b;
  transform: rotate(45deg);
}

.title-block {
  min-width: 0;
}

.eyebrow,
.hud-strip span,
.mission-grid span {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.18rem, 3.5vw, 2.28rem);
  line-height: 1.05;
}

.top-actions {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
}

.wallet-button,
.music-button {
  display: inline-grid;
  grid-template-columns: auto minmax(0, auto);
  align-items: center;
  gap: 8px;
  max-width: 150px;
  padding: 0 12px;
  border: 1px solid rgba(169, 184, 191, 0.24);
  background: var(--surface-2);
}

.music-button {
  max-width: 132px;
}

.wallet-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(244, 183, 64, 0.14);
}

.wallet-button.connected .wallet-dot {
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(183, 228, 95, 0.14);
}

.music-icon {
  position: relative;
  width: 14px;
  height: 16px;
  border-left: 3px solid var(--teal);
  border-top: 3px solid var(--teal);
  transform: skewY(-10deg);
}

.music-icon::before,
.music-icon::after {
  position: absolute;
  bottom: -4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal);
  content: "";
}

.music-icon::before {
  left: -6px;
}

.music-icon::after {
  right: -4px;
}

.music-button.muted .music-icon,
.music-button.missing .music-icon {
  border-color: var(--muted);
}

.music-button.muted .music-icon::before,
.music-button.muted .music-icon::after,
.music-button.missing .music-icon::before,
.music-button.missing .music-icon::after {
  background: var(--muted);
}

#walletLabel,
#musicLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-layout {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.stage-card,
.side-panel > section,
.action-panel {
  border: 1px solid rgba(169, 184, 191, 0.16);
  border-radius: 8px;
  background: rgba(16, 18, 20, 0.78);
}

.stage-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(390px, 1fr) auto;
  gap: 10px;
  padding: 10px;
}

.hud-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.hud-strip article {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid rgba(169, 184, 191, 0.13);
}

.hud-strip strong {
  font-size: clamp(1.28rem, 5vw, 2.1rem);
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  min-height: 390px;
  height: min(62vh, 720px);
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(169, 184, 191, 0.18);
  background: #0b1115;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.screen-banner {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  text-align: center;
  background: rgba(9, 13, 16, 0.68);
  backdrop-filter: blur(5px);
}

.screen-banner p,
.screen-banner h2,
.screen-banner span {
  max-width: 560px;
  margin: 0;
}

.screen-banner h2 {
  font-size: clamp(2rem, 8vw, 4.8rem);
  line-height: 0.98;
}

.screen-banner span {
  color: var(--muted);
  line-height: 1.4;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1.08fr 1fr;
  gap: 8px;
}

.control-button {
  min-height: 54px;
  border: 1px solid rgba(169, 184, 191, 0.18);
  background: var(--surface-2);
  font-weight: 900;
}

.control-button:active {
  background: #31414a;
}

.control-button.shield {
  display: grid;
  align-content: center;
  gap: 1px;
  background: #182422;
  border-color: rgba(45, 212, 191, 0.32);
}

.control-button small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.side-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.mission-card,
.reward-card,
.chain-card {
  padding: 13px;
}

.mission-card h2,
.reward-card h2,
.chain-card h2 {
  margin: 5px 0 0;
  font-size: clamp(1.25rem, 5vw, 1.95rem);
  line-height: 1.05;
}

.mission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mission-grid article {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(169, 184, 191, 0.13);
  background: var(--surface-2);
}

.mission-grid strong {
  font-size: 1.42rem;
}

.shield-meter,
.reward-meter {
  height: 12px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 999px;
  background: #2a3439;
  border: 1px solid rgba(169, 184, 191, 0.12);
}

.shield-meter span,
.reward-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--teal);
  transition: width 180ms ease;
}

.reward-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  background: #1f1d15;
  border-color: rgba(244, 183, 64, 0.25) !important;
}

.reward-badge {
  width: 58px;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid var(--amber);
  background:
    linear-gradient(45deg, transparent 42%, rgba(244, 183, 64, 0.88) 43% 57%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, rgba(244, 183, 64, 0.88) 43% 57%, transparent 58%),
    #171209;
}

.reward-card > .reward-meter {
  grid-column: 1 / -1;
}

.reward-card span,
.chain-card span {
  display: block;
  color: var(--muted);
  line-height: 1.38;
}

.chain-card {
  display: grid;
  gap: 9px;
}

.claim-button {
  width: 100%;
  background: #29333b;
  border: 1px solid rgba(100, 168, 255, 0.28);
  color: var(--text);
  font-weight: 900;
}

.claim-button.ready {
  background: var(--blue);
  color: var(--ink);
}

.action-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}

.action-panel .primary-button {
  grid-column: 1 / -1;
}

.primary-button {
  padding: 0 16px;
  background: var(--teal);
  color: var(--ink);
  font-weight: 950;
}

.ghost-button {
  padding: 0 16px;
  background: transparent;
  border: 1px solid rgba(169, 184, 191, 0.25);
  font-weight: 900;
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100% - 36px, 1540px);
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .topbar,
  .game-layout {
    padding: 18px;
  }

  .stage-card {
    padding: 14px;
  }

  .canvas-wrap {
    min-height: 500px;
    height: min(66vh, 760px);
  }
}

@media (min-width: 1060px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: stretch;
  }

  .stage-card {
    grid-template-rows: auto minmax(520px, 1fr) auto;
  }

  .canvas-wrap {
    height: min(70vh, 780px);
  }

  .touch-controls {
    max-width: 620px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (min-width: 1380px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 390px;
  }

  .canvas-wrap {
    height: min(72vh, 820px);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 12px, 1540px);
    align-content: start;
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .wallet-button {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  .top-actions {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .music-button {
    width: 100%;
    max-width: none;
    justify-content: center;
  }

  .game-layout {
    padding: 8px;
  }

  .stage-card {
    grid-template-rows: auto minmax(360px, 58vh) auto;
    padding: 8px;
  }

  .hud-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-strip article {
    min-height: 62px;
  }

  .canvas-wrap {
    height: auto;
    min-height: 360px;
  }

  .screen-banner {
    padding: 18px;
  }

  .touch-controls {
    grid-template-columns: 1fr 1.08fr 1fr;
  }

  .control-button {
    min-height: 52px;
  }

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

  .action-panel {
    grid-template-columns: 1fr;
  }

  .action-panel .primary-button {
    grid-column: auto;
  }
}

@media (max-width: 330px) {
  .touch-controls {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
