:root {
  color-scheme: dark;
  --bg: #070807;
  --panel: rgba(12, 14, 13, 0.78);
  --panel-strong: rgba(18, 22, 20, 0.9);
  --line: rgba(212, 227, 218, 0.16);
  --text: #f3f6ef;
  --muted: #a8b6aa;
  --silver: #d9e1dc;
  --gold: #e2bd65;
  --red: #b94747;
  --green: #55ff9a;
  --acid: #a5ff45;
  --cyan: #7ad7ff;
  --shadow: rgba(0, 0, 0, 0.48);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 25% 20%, rgba(121, 215, 255, 0.08), transparent 28rem),
    radial-gradient(circle at 78% 28%, rgba(85, 255, 154, 0.08), transparent 24rem),
    linear-gradient(135deg, #070807 0%, #10110d 48%, #070807 100%);
  color: var(--text);
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(217, 225, 220, 0.18);
  border-radius: 8px;
  background: rgba(217, 225, 220, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

button:hover,
.download-link:hover {
  transform: translateY(-1px);
  border-color: rgba(226, 189, 101, 0.62);
  background: rgba(226, 189, 101, 0.13);
}

button:active,
.download-link:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary {
  border-color: rgba(226, 189, 101, 0.78);
  background: linear-gradient(180deg, #f3d483 0%, #b77a2a 100%);
  color: #17110a;
  box-shadow: 0 0 28px rgba(226, 189, 101, 0.22);
}

.game-shell,
#gameCanvas {
  position: fixed;
  inset: 0;
}

#gameCanvas {
  width: 100vw;
  height: 100vh;
  outline: none;
}

.top-hud {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(190px, 0.7fr) minmax(280px, 1.35fr) auto;
  gap: 10px;
  align-items: stretch;
  pointer-events: none;
}

.brand-lockup,
.status-strip,
.run-stats,
.side-panel,
.modal {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 44px var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  padding: 10px 12px;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup strong {
  font-size: 16px;
  letter-spacing: 0;
}

.brand-lockup small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  position: relative;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 2px solid rgba(226, 189, 101, 0.76);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 44%, rgba(226, 189, 101, 0.92) 46% 54%, transparent 56%),
    radial-gradient(circle at 50% 50%, rgba(122, 215, 255, 0.58), transparent 34%),
    #111;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  content: "";
  background: rgba(226, 189, 101, 0.92);
}

.brand-mark::before {
  left: 7px;
  right: 7px;
  top: 13px;
  height: 2px;
}

.brand-mark::after {
  left: 14px;
  top: -7px;
  width: 2px;
  height: 42px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-radius: 8px;
  padding: 9px;
}

.meter-block {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.meter-block span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meter-block b {
  min-width: 44px;
  text-align: right;
  font-size: 12px;
}

.meter {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b94747, #ffcf6a);
  box-shadow: 0 0 16px rgba(255, 207, 106, 0.35);
}

.meter.shield i {
  background: linear-gradient(90deg, #7ad7ff, #d9e1dc);
  box-shadow: 0 0 16px rgba(122, 215, 255, 0.35);
}

.meter-block.xp .meter i {
  background: linear-gradient(90deg, #55ff9a, #a5ff45);
  box-shadow: 0 0 16px rgba(85, 255, 154, 0.32);
}

.run-stats {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 900;
}

.run-stats span {
  min-width: 72px;
  border: 1px solid rgba(217, 225, 220, 0.12);
  border-radius: 7px;
  padding: 6px 8px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
}

.side-panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 13;
  display: grid;
  width: 300px;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  overflow: hidden;
  border-radius: 8px;
  padding: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 22px));
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.side-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.panel-scrim {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.36);
  cursor: default;
}

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

.panel-scrim:hover {
  transform: none;
  border-color: transparent;
  background: rgba(0, 0, 0, 0.36);
}

.mobile-panel-toggle {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 14;
  min-width: 92px;
  min-height: 44px;
  padding: 0 14px;
  border-color: rgba(226, 189, 101, 0.42);
  background: rgba(18, 22, 20, 0.82);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.36);
}

.panel-section {
  min-height: 0;
}

.armory-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--silver);
  font-size: 13px;
  font-weight: 900;
}

.section-title b {
  color: var(--gold);
  font-size: 12px;
}

.armory-list,
.rune-list {
  display: grid;
  gap: 8px;
}

.armory-list {
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.armory-item,
.rune-item,
.log-line,
.upgrade-card {
  border: 1px solid rgba(217, 225, 220, 0.13);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.armory-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px;
}

.armory-item strong,
.rune-item strong {
  display: block;
  font-size: 13px;
}

.armory-item small,
.rune-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.armory-item button {
  min-width: 70px;
  height: 38px;
  padding: 0 10px;
  font-size: 12px;
}

.rune-list {
  max-height: 152px;
  overflow: auto;
  padding-right: 3px;
}

.rune-item {
  padding: 8px;
}

.log-section {
  display: grid;
  grid-template-rows: auto 1fr;
}

.battle-log {
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.log-line {
  margin-bottom: 7px;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.center-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 50%, rgba(85, 255, 154, 0.08), transparent 22rem),
    rgba(0, 0, 0, 0.38);
}

.center-overlay.hidden {
  display: none;
}

.modal {
  width: min(760px, 100%);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 34px);
}

.hero-modal {
  background:
    linear-gradient(135deg, rgba(217, 225, 220, 0.12), rgba(0, 0, 0, 0.18)),
    var(--panel-strong);
}

.compact-modal {
  width: min(460px, 100%);
}

.kicker {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
.lead {
  margin: 0;
}

h1 {
  max-width: 12ch;
  font-size: clamp(44px, 8vw, 86px);
  line-height: 0.94;
  letter-spacing: 0;
  text-shadow: 0 0 28px rgba(122, 215, 255, 0.22);
}

h2 {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  max-width: 680px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.control-row span {
  border: 1px solid rgba(217, 225, 220, 0.16);
  border-radius: 7px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--silver);
  font-size: 13px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.modal-actions button,
.modal-actions .download-link {
  min-height: 46px;
  padding: 0 18px;
}

.upgrade-modal {
  width: min(930px, 100%);
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.upgrade-card {
  min-height: 170px;
  padding: 16px;
  text-align: left;
}

.upgrade-card strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.upgrade-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.upgrade-card b {
  display: inline-block;
  margin-top: 14px;
  color: var(--gold);
  font-size: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  margin-top: 18px;
  border-top: 1px solid rgba(217, 225, 220, 0.12);
  padding-top: 16px;
}

.result-grid span {
  color: var(--muted);
}

.result-grid b {
  color: var(--silver);
}

.touch-controls {
  position: fixed;
  inset: auto 18px 18px 18px;
  z-index: 7;
  display: none;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.touch-actions {
  display: grid;
  grid-template-columns: 74px 92px;
  gap: 10px;
  align-items: end;
  pointer-events: auto;
}

.touch-stick {
  position: relative;
  width: 116px;
  height: 116px;
  border: 1px solid rgba(217, 225, 220, 0.18);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: auto;
  touch-action: none;
}

.touch-stick i {
  position: absolute;
  left: 38px;
  top: 38px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(217, 225, 220, 0.72);
  box-shadow: 0 0 20px rgba(122, 215, 255, 0.35);
}

.touch-dash,
.touch-melee {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(226, 189, 101, 0.18);
  touch-action: none;
}

.touch-melee {
  width: 74px;
  height: 74px;
  background: rgba(122, 215, 255, 0.18);
}

@media (max-width: 1080px) {
  .top-hud {
    right: 14px;
    grid-template-columns: 1fr;
  }

  .side-panel {
    top: auto;
    left: 14px;
    width: auto;
    height: 210px;
    grid-template-columns: minmax(260px, 1fr) minmax(220px, 0.9fr) minmax(220px, 0.8fr);
    grid-template-rows: 1fr;
    transform: translateY(calc(100% + 24px));
  }

  .rune-list {
    max-height: 152px;
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .top-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .brand-lockup {
    display: none;
  }

  .status-strip {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 7px;
  }

  .meter-block {
    grid-template-columns: 38px 1fr 40px;
  }

  .run-stats {
    justify-content: stretch;
    padding: 7px;
  }

  .run-stats span {
    flex: 1;
    min-width: 0;
    padding: 6px 5px;
    font-size: 12px;
  }

  .side-panel {
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: min(72vh, 560px);
    width: auto;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(190px, 1fr) auto auto;
    transform: translateY(calc(100% + 18px));
    padding: 10px;
  }

  .side-panel.open {
    transform: translateY(0);
  }

  .mobile-panel-toggle {
    right: 18px;
    bottom: 126px;
    min-width: 84px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 13px;
  }

  .modal {
    padding: 20px;
  }

  h1 {
    font-size: 48px;
  }

  .lead {
    font-size: 14px;
  }

  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .upgrade-card {
    min-height: 118px;
  }

  .touch-controls {
    display: flex;
  }
}
