:root {
  --ink: #15142b;
  --deep: #211b46;
  --paper: #fff4de;
  --lime: #39e6c2;
  --acid: #17bfa2;
  --orange: #ff6f61;
  --sky: #5ecbff;
  --gold: #ffd45e;
  --violet: #9d70ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Courier New", monospace;
  touch-action: none;
}

button { font: inherit; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ink);
  isolation: isolate;
}

#app::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .11;
  background-image: repeating-linear-gradient(0deg, transparent 0 3px, #000 4px);
  mix-blend-mode: multiply;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) 24px max(26px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 82% 16%, rgba(94,203,255,.2), transparent 24%),
    radial-gradient(circle at 16% 82%, rgba(255,111,97,.14), transparent 28%),
    linear-gradient(155deg, rgba(33,27,70,.86), rgba(14,15,38,.98));
}

.screen.active { display: flex; }

.brand-cover {
  width: calc(100% + 48px);
  max-height: 150px;
  margin: 0 -24px 14px;
  border-top: 2px solid rgba(255,255,255,.34);
  border-bottom: 3px solid var(--violet);
  object-fit: cover;
  filter: saturate(1.08) contrast(1.04);
  box-shadow: 0 10px 30px rgba(157,112,255,.25);
}

.eyebrow {
  color: var(--lime);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .2em;
}

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

.profile-status {
  max-width: 55%;
  padding: 5px 7px;
  border: 1px solid #625a91;
  color: #aaa6c4;
  background: rgba(16,14,42,.72);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .06em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-status.online {
  border-color: var(--lime);
  color: var(--lime);
}

h1 {
  margin: 8px 0 7px;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(58px, 17vw, 88px);
  line-height: .72;
  letter-spacing: -.055em;
  color: var(--paper);
  text-shadow: 6px 6px 0 #47326d;
  transform: skewY(-3deg);
}

h1 em {
  color: var(--orange);
  font-style: normal;
  -webkit-text-stroke: 2px var(--paper);
}

.intro {
  max-width: 390px;
  margin: 12px 0 14px;
  color: #c9c8dc;
  font-size: 13px;
  line-height: 1.45;
}

.selector {
  padding: 11px;
  border: 2px solid #4a4575;
  background: rgba(16, 14, 42, .75);
  box-shadow: 7px 7px 0 rgba(0,0,0,.35);
}

.selector-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: #9f9bbd;
  font-size: 9px;
  letter-spacing: .08em;
}

.selector-title b { color: var(--lime); }

.characters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 170px;
  overflow-y: auto;
  padding: 3px;
}

.character {
  position: relative;
  aspect-ratio: 1;
  padding: 5px;
  border: 2px solid #514b7c;
  background: #d9f7ef;
  cursor: pointer;
}

.character img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.character.selected {
  border-color: var(--lime);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--lime);
  transform: translateY(-3px);
}

.character.selected::after {
  content: "P1";
  position: absolute;
  top: -8px;
  right: -5px;
  padding: 2px 4px;
  background: var(--orange);
  color: white;
  font-size: 8px;
  font-weight: bold;
}

.character.owned {
  border-color: var(--gold);
}

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

.wallet-button {
  min-height: 34px;
  padding: 7px 10px;
  border: 2px solid var(--violet);
  background: rgba(157,112,255,.16);
  color: var(--paper);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .06em;
}

.wallet-status {
  max-width: 145px;
  color: #aaa6c4;
  font-size: 8px;
  font-weight: 900;
  text-align: right;
}

.wallet-status.online { color: var(--lime); }
.wallet-status.pending { color: var(--gold); }
.wallet-status.error { color: var(--orange); }

.primary, .secondary {
  width: 100%;
  min-height: 54px;
  margin-top: 14px;
  border: 0;
  font-weight: 900;
  letter-spacing: .08em;
  cursor: pointer;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--lime);
  color: var(--ink);
  box-shadow: 7px 7px 0 #137f73;
}

.primary:active { transform: translate(4px,4px); box-shadow: 3px 3px 0 #137f73; }
.primary span { font-size: 24px; }

.secondary {
  margin-top: 12px;
  border: 2px solid #625a91;
  background: rgba(157,112,255,.08);
  color: var(--paper);
}
.menu-pair { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.menu-pair .secondary { margin-top:12px; min-height:42px; font-size:10px; }
.secondary.compact { margin-top:10px; min-height:38px; font-size:9px; }
.panel-title { margin:10px 0 8px; color:var(--orange); font:64px/.9 Impact,sans-serif; }
.panel-copy { color:var(--gold); font-size:12px; font-weight:900; }
.panel-list { display:grid; gap:9px; margin:15px 0; }
.panel-item {
  display:grid; grid-template-columns:1fr auto; align-items:center; gap:12px;
  padding:13px; border:2px solid #514b7c; background:rgba(16,14,42,.8);
}
.panel-item b { display:block; color:var(--paper); font-size:12px; }
.panel-item small { color:#aaa6c4; font-size:9px; }
.panel-item button { padding:9px; border:0; background:var(--lime); color:var(--ink); font:900 9px monospace; }
.panel-item button.equipped { background:var(--violet); color:white; }
.armory-item { grid-template-columns:1fr; }
.armory-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
.armory-actions button:only-child { grid-column:1/-1; }
.rank { color:var(--lime); font-weight:900; }
.legend-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:12px 0; overflow:auto; }
.legend-grid div { display:grid; grid-template-columns:32px 1fr; padding:9px; border:2px solid #514b7c; background:rgba(16,14,42,.82); }
.legend-grid b { grid-row:1/3; display:grid; place-items:center; color:var(--ink); background:var(--lime); font-size:17px; }
.legend-grid span { padding-left:8px; color:var(--paper); font-size:10px; font-weight:900; }
.legend-grid small { padding-left:8px; color:#aaa6c4; font-size:8px; }
.legend-grid .bad b { background:var(--orange); color:white; }
.mode-banner { background:var(--violet); }

.hint {
  margin: 15px 0 0;
  text-align: center;
  color: #7587a2;
  font-size: 10px;
}

#hud {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 10px;
  align-items: start;
  padding: max(14px, env(safe-area-inset-top)) 13px 8px;
  pointer-events: none;
  background: linear-gradient(rgba(21,20,43,.96), transparent);
}

.hidden { display: none !important; }
.hud-block span, .hud-center span { display: block; color: #aaa6c4; font-size: 8px; letter-spacing: .08em; }
.hud-block strong { color: var(--lime); font-size: 15px; }
.hud-block b {
  display: block;
  margin-top: 3px;
  color: var(--orange);
  font-size: 8px;
  letter-spacing: .06em;
  opacity: 0;
  transform: translateY(-3px);
  transition: .15s ease;
}
.hud-block b.show { opacity: 1; transform: translateY(0); }
.hud-block.right { text-align: right; }
.hud-block.right strong { color: var(--gold); font-size: 15px; }
.hud-block.right small { display:block; margin-top:2px; color:var(--orange); font-size:9px; }
.hud-center { text-align: center; }
.hud-center span { color: var(--paper); font-weight: bold; }
.hud-center b { display: block; margin-top: 4px; color: var(--lime); font-size: 7px; letter-spacing: .06em; }
.level-bar { height: 5px; margin-top: 5px; background: #49426e; }
.level-bar i { display: block; width: 0; height: 100%; background: var(--lime); }

#game-over { align-items: center; text-align: center; }
#game-over h2 {
  margin: 10px 0 22px;
  color: var(--orange);
  font: 72px/.9 Impact, sans-serif;
  transform: rotate(-3deg);
  text-shadow: 5px 5px 0 #47326d;
}

.result-card {
  width: 100%;
  padding: 24px;
  border: 2px solid #625a91;
  background: rgba(16,14,42,.84);
}
.result-card span, .result-card small { display: block; margin-top:5px; color: #aaa6c4; font-size: 10px; }
.result-card strong { display: block; margin: 6px 0; color: var(--lime); font-size: 44px; }

.warning {
  position: absolute;
  z-index: 8;
  top: 42%;
  left: 0;
  right: 0;
  display: none;
  padding: 14px 0;
  background: var(--orange);
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .08em;
  animation: blink .3s steps(2) infinite;
}
.warning.show { display: block; }

@media (max-height: 760px) {
  .screen {
    justify-content: flex-start;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .brand-cover {
    max-height: 92px;
    margin-bottom: 9px;
  }

  h1 {
    margin: 5px 0;
    font-size: clamp(46px, 14vw, 66px);
  }

  .intro {
    margin: 7px 0 9px;
    font-size: 11px;
    line-height: 1.3;
  }

  .selector {
    padding: 8px;
  }

  .selector-title {
    margin-bottom: 8px;
  }

  .character {
    max-height: 72px;
  }

  .primary {
    min-height: 46px;
    margin-top: 10px;
  }

  .wallet-row {
    margin-top: 7px;
  }

  .wallet-button {
    min-height: 30px;
  }

  .menu-pair .secondary {
    margin-top: 9px;
    min-height: 38px;
  }

  .secondary.compact {
    margin-top: 7px;
    min-height: 34px;
  }

  .hint {
    margin-top: 9px;
  }
}

#app.overdrive::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border: 5px solid var(--lime);
  box-shadow: inset 0 0 42px rgba(57,230,194,.32);
  animation: overdrivePulse .35s steps(2) infinite;
}

@keyframes blink { 50% { opacity: .25; } }
@keyframes overdrivePulse { 50% { border-color: var(--orange); opacity: .65; } }

@media (min-width: 521px) {
  body { background: #0c0b1c; }
  #app { box-shadow: 0 0 80px rgba(157,112,255,.22); }
}
