/* Vipernaut — browser client.
   Targets iPhone Safari first: everything is sized off dynamic viewport units so
   the URL bar collapsing does not resize the arena mid-game, and every scroll and
   zoom gesture is suppressed because they all conflict with steering. */

:root {
  --green: #4ce04c;
  --green-lit: #6bff6b;
  --red: #ff5c5c;
  --gold: #ffd84c;
  --cyan: #6be8ff;
  --ink: #0e0a1a;
  --panel: rgba(12, 8, 24, 0.72);
  --stroke: rgba(255, 255, 255, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1030;
  color: #fff;
  font: 500 16px/1.3 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  /* Steering is a drag. Without these, a drag scrolls the page, pulls to refresh,
     or pinch-zooms — all three make the game unplayable on a phone. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  position: fixed;
  inset: 0;
}

canvas#arena {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ HUD */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* the arena beneath must receive the steering drag */
}
#hud > * { pointer-events: auto; }

/* The bar itself must not catch touches — only its buttons. An opaque HUD
   container over the arena silently eats steering drags. */
#chrome { pointer-events: none; }
.chip, .rail-btn, #boost { pointer-events: auto; }

#chrome {
  position: absolute;
  top: calc(var(--safe-t) + 6px);
  left: calc(var(--safe-l) + 8px);
  right: calc(var(--safe-r) + 8px);
  display: flex;
  gap: 8px;
  align-items: center;
}

.chip {
  font: 700 14px/1 ui-rounded, system-ui, sans-serif;
  color: #fff;
  background: rgba(30, 22, 52, 0.85);
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
}
.chip.danger { background: #e8434a; margin-left: auto; }
.chev { opacity: 0.7; }

#board {
  position: absolute;
  top: calc(var(--safe-t) + 56px);
  left: calc(var(--safe-l) + 10px);
  width: 62%;
  max-width: 320px;
  font-weight: 800;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}
.brow { display: flex; gap: 8px; align-items: baseline; font-size: 17px; padding: 1px 0; }
.brow .bi { color: var(--green-lit); width: 26px; text-align: right; }
.brow .bn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brow .bs { font-variant-numeric: tabular-nums; }
.brow .bp { width: 18px; font-size: 13px; text-align: center; }
.brow.foe .bn, .brow.foe .bs { color: var(--red); }
.brow.ally .bn, .brow.ally .bs { color: var(--green-lit); }
.brow.lead .bn, .brow.lead .bs { color: var(--gold); }

#selfrow {
  position: absolute;
  top: calc(var(--safe-t) + 232px);
  left: calc(var(--safe-l) + 10px);
  width: 62%;
  max-width: 320px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 800;
  font-size: 17px;
  background: rgba(0, 0, 0, 0.55);
  border: 1.5px solid rgba(76, 224, 76, 0.8);
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--green-lit);
  pointer-events: none;   /* sits mid-screen, right where a thumb steers */
}
#self-rank { min-width: 34px; }
#self-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#self-score { font-variant-numeric: tabular-nums; }
/* The carried power, and the only way to be rid of it. Sits under the self row,
   clear of the boost button so a drop is never a mis-tap for a boost. */
#drop {
  /* In the thumb zone, directly above boost. Parked by the score it was a
     stretch for the hand and easy to miss mid-fight. */
  position: absolute;
  left: calc(var(--safe-l) + 26px);
  bottom: calc(var(--safe-b) + 138px);
  width: 78px;
  height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 3px solid #1a2a9e;
  border-bottom-width: 7px;
  border-radius: 16px;
  padding: 0;
  font: 900 11px/1 ui-rounded, system-ui, sans-serif;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(#3b57e8, #2b44d8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}
#drop:active { transform: translateY(3px); border-bottom-width: 4px; }
#drop-icon { font-size: 30px; line-height: 1; }

#radar {
  position: absolute;
  top: calc(var(--safe-t) + 56px);
  right: calc(var(--safe-r) + 10px);
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(10, 6, 20, 0.72);
  pointer-events: none;
}

#kills {
  position: absolute;
  top: calc(var(--safe-t) + 186px);
  right: calc(var(--safe-r) + 22px);
  background: rgba(12, 8, 24, 0.8);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  color: var(--cyan);
  pointer-events: none;
}
#kills .arrow { opacity: 0.85; }

#grace {
  position: absolute;
  top: 42%;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
}
.grace-label { font: 800 13px/1 ui-rounded, system-ui, sans-serif; color: var(--red); letter-spacing: 2px; }
#grace-count { font: 900 64px/1.1 ui-rounded, system-ui, sans-serif; color: var(--red); }

#banner {
  position: absolute;
  left: calc(var(--safe-l) + 12px);
  right: calc(var(--safe-r) + 12px);
  top: calc(var(--safe-t) + 300px);
  border-radius: 12px;
  padding: 14px 16px;
  font-weight: 700;
  background: #1f7a8c;
  pointer-events: none;
}
#banner.bad { background: #e8434a; }

#rail {
  pointer-events: none;   /* the strip is decoration; the buttons are not */
  position: absolute;
  left: 0;
  top: 46%;
  background: rgba(12, 8, 24, 0.8);
  border-radius: 0 14px 14px 0;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rail-btn {
  width: 42px; height: 42px;
  font-size: 21px;
  background: none;
  border: none;
  color: #fff;
  position: relative;
}
#chat-dot {
  position: absolute; top: 4px; right: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--red);
  display: none;
}
#chat-dot.on { display: block; }

#boost {
  position: absolute;
  left: calc(var(--safe-l) + 18px);
  bottom: calc(var(--safe-b) + 24px);
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: radial-gradient(circle at 34% 30%, #ffc266, #f0921f 70%);
  font-size: 42px;
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
#boost:active, #boost.on { filter: brightness(1.25); transform: scale(0.96); }

#pops { position: absolute; inset: 0; pointer-events: none; }
.pop {
  position: absolute;
  font: 900 20px/1 ui-rounded, system-ui, sans-serif;
  color: var(--gold);
  text-shadow: 0 2px 4px #000;
  animation: rise 1s ease-out forwards;
}
@keyframes rise {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, -42px); }
}

/* --------------------------------------------------------------- overlays */

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 14, 0.86);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 16px) 18px calc(var(--safe-b) + 16px);
  z-index: 20;
}
.overlay h1 { font: 900 46px/1 ui-rounded, system-ui, sans-serif; margin: 0; letter-spacing: 1px; }
.skull { font-size: 62px; }
#death-why { opacity: 0.75; margin: 0 0 6px; }
.stats { display: flex; gap: 34px; margin: 4px 0 18px; text-align: center; }
.stats span { display: block; font: 700 11px/1 ui-rounded, system-ui, sans-serif; opacity: 0.6; letter-spacing: 1px; }
.stats b { font: 900 30px/1.3 ui-rounded, system-ui, sans-serif; }

.big {
  width: min(420px, 100%);
  border: none;
  border-radius: 14px;
  padding: 17px;
  font: 800 18px/1 ui-rounded, system-ui, sans-serif;
  color: #fff;
}
.big.green { background: #1f9d4d; }
.big.grey { background: rgba(255, 255, 255, 0.14); }

.sheet {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: rgba(20, 14, 38, 0.96);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px;
}
.sheet-head { display: flex; align-items: center; margin-bottom: 6px; }
.sheet-head h2 { font: 900 22px/1 ui-rounded, system-ui, sans-serif; margin: 0; flex: 1; }
.x { background: none; border: none; color: #fff; font-size: 20px; opacity: 0.6; }

.lbl { display: block; font: 800 11px/1 ui-rounded, system-ui, sans-serif; opacity: 0.55; letter-spacing: 1.4px; margin: 14px 0 6px; }
.soft { opacity: 0.5; font-weight: 600; }
.hint { font-size: 12px; opacity: 0.5; margin-top: 5px; }
.hint.over { color: var(--red); opacity: 1; }

input {
  width: 100%;
  font: 700 17px/1 ui-rounded, system-ui, sans-serif;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 13px;
}
input:focus { outline: 2px solid rgba(76, 224, 76, 0.7); }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }

.picker { display: flex; flex-wrap: wrap; gap: 7px; }
.opt {
  width: 46px; height: 46px;
  font-size: 25px;
  line-height: 44px;
  text-align: center;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0;
  color: #fff;
}
.opt.sel { border-color: var(--green); background: rgba(76, 224, 76, 0.16); }

/* Shared list styling for the all-time board and the full arena ranking. */
#acct-code {
  flex: 1;
  font: 800 19px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 3px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 13px;
  text-align: center;
}

.board-list { display: flex; flex-direction: column; gap: 1px; }
.board-list .r {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  font: 800 15px/1 ui-rounded, system-ui, sans-serif;
  background: rgba(255, 255, 255, 0.03);
}
.board-list .r:nth-child(odd) { background: rgba(255, 255, 255, 0.06); }
.board-list .r .n { width: 30px; color: var(--green-lit); text-align: right; }
.board-list .r .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .r .sc { font-variant-numeric: tabular-nums; }
.board-list .r.gold .who, .board-list .r.gold .sc { color: var(--gold); }
.board-list .r.me { outline: 1.5px solid var(--green); }
.board-list .empty { opacity: 0.45; font-size: 13px; padding: 8px 2px; }

#btn-play { margin-top: 20px; }
#btn-share { margin-top: 8px; }

/* ------------------------------------------------------------------ boot */

#boot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1030;
  z-index: 40;
  transition: opacity 0.35s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.boot-logo { font-size: 60px; animation: bob 1.4s ease-in-out infinite; }
.boot-text { font: 900 20px/2 ui-rounded, system-ui, sans-serif; opacity: 0.75; letter-spacing: 1px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* Short screens (landscape phones): pull the stacked HUD in. */
@media (max-height: 480px) {
  #board { top: calc(var(--safe-t) + 48px); font-size: 14px; }
  #selfrow { top: calc(var(--safe-t) + 168px); }
  #radar { width: 92px; height: 92px; }
  #boost { width: 78px; height: 78px; font-size: 34px; }
}
