:root {
  --bg: #FFFFFF;
  --fg: #000000;
  --accent: #FF6A00;
  --ink: #FFFFFF;
  --hud: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; border-radius: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 17px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

canvas#game { position: fixed; inset: 0; display: block; }

button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: none;
  overflow-y: auto;
  padding: 56px 16px 80px;
  background: var(--bg);
  z-index: 3;
}
.screen.on { display: block; }
.wrap { max-width: 1100px; margin: 0 auto; }
.screen h1 { font-size: clamp(40px, 8vw, 64px); font-weight: 800; letter-spacing: -2px; margin-top: 24px; line-height: 1; }
.screen h1 + p, #set-desc { font-size: 18px; line-height: 1.6; margin: 14px 0 36px; max-width: 680px; }

/* ---------- menu ---------- */
.brand { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.logo { font-size: clamp(48px, 10vw, 88px); font-weight: 800; letter-spacing: -3px; line-height: 1; }
.logo span { color: var(--accent); }
.btn.xh-btn { display: inline-flex; align-items: center; gap: 12px; line-height: 1; }
.xh-btn img { width: 32px; height: 32px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 56px;
}
.card {
  all: unset;
  box-sizing: border-box;
  border: 3px solid var(--fg);
  background: var(--bg);
  padding: 28px;
  min-height: 270px;
  display: flex; flex-direction: column; gap: 14px;
  cursor: pointer;
}
.card:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.card .name { font-size: 44px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.card .desc { font-size: 17px; line-height: 1.55; flex: 1; }
.card .best { font-size: 15px; font-weight: 800; letter-spacing: 1px; }
.card.soon { border-style: dashed; cursor: default; }
.card.soon:hover { background: var(--bg); border-color: var(--fg); color: var(--fg); }

.keys { margin-top: 48px; display: flex; flex-wrap: wrap; gap: 12px 56px; font-size: 15px; font-weight: 800; letter-spacing: 1px; }

.head-btns { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.tabs { display: flex; margin-top: 48px; }
.tab {
  all: unset; cursor: pointer;
  border: 3px solid var(--fg); margin-left: -3px;
  padding: 14px 28px; font-size: 18px; font-weight: 800; letter-spacing: 2px;
}
.tab:first-child { margin-left: 0; }
.tab:hover { color: var(--accent); }
.tab.sel { background: var(--fg); color: var(--ink); }
.tabs + .cards { margin-top: 24px; }
#set-view { margin: 0 0 24px; }

/* ---------- survev weapon picker ---------- */
.wpn-card {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 16px;
  border: 3px solid var(--fg); padding: 8px; max-width: 760px;
}
.wpn-card:hover, .wpn-card.open { border-color: var(--accent); }
.wpn-icon {
  width: 72px; height: 72px; background: #2b2b2b;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800;
}
.wpn-icon img { width: 64px; height: 64px; }
.wpn-info { display: flex; flex-direction: column; gap: 6px; }
.wpn-name { font-size: 20px; font-weight: 800; }
.wpn-stats { font-size: 13px; font-weight: 700; line-height: 1.5; }
.wpn-change { font-size: 14px; font-weight: 800; color: var(--accent); padding-right: 8px; }
.wpn-pick { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.wpn-group-label { font-size: 13px; font-weight: 800; letter-spacing: 2px; margin-bottom: 8px; }
.wpn-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.wpn-tile {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 3px solid transparent; padding: 4px 2px 6px;
}
.wpn-tile .wpn-icon { width: 64px; height: 64px; }
.wpn-tile .wpn-icon img { width: 56px; height: 56px; }
.wpn-tile-name { font-size: 11px; font-weight: 800; text-align: center; }
.wpn-tile:hover { border-color: var(--fg); }
.wpn-tile.sel { border-color: var(--accent); }
.bind-row { display: flex; justify-content: space-between; flex-wrap: wrap; }
.opt.bind { min-width: 120px; text-align: center; }

/* ---------- settings rows ---------- */
.link { all: unset; cursor: pointer; font-size: 17px; font-weight: 800; letter-spacing: 1px; }
.link:hover { color: var(--accent); }
#set-list, #xh-list { border-top: 3px solid var(--fg); }

.row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 20px;
  padding: 22px 0;
  border-bottom: 3px solid var(--fg);
}
.row.has-pv { grid-template-columns: 1fr 320px; }
.row-main { display: flex; flex-direction: column; gap: 14px; }
.label { font-size: 19px; font-weight: 800; letter-spacing: 1px; }
.opts { display: flex; flex-wrap: wrap; }
.opt {
  all: unset;
  border: 3px solid var(--fg);
  margin-left: -3px;
  padding: 12px 20px;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  cursor: pointer;
  position: relative;
  background: var(--bg);
}
.opt:first-child { margin-left: 0; }
.opt:hover { color: var(--accent); }
.opt.sel { background: var(--accent); color: var(--ink); border-color: var(--accent); z-index: 1; }
.opt.swatch { width: 44px; height: 44px; padding: 0; margin: 0 8px 8px 0; }
.opt.swatch.sel { border-color: var(--fg); box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 6px var(--fg); }
canvas.pv { width: 320px; height: 160px; border: 3px solid var(--fg); display: block; }
canvas.pv.tall { height: 196px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin-top: 36px; }
.btn {
  all: unset;
  border: 3px solid var(--fg);
  padding: 16px 30px;
  font-size: 18px; font-weight: 800; letter-spacing: 1px;
  cursor: pointer;
  background: var(--bg);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn:hover { background: var(--fg); border-color: var(--fg); color: var(--ink); }
.btn.danger { border-color: #d00000; color: #d00000; }
.btn.danger:hover, .btn.danger.armed { background: #d00000; border-color: #d00000; color: #ffffff; }
.note { font-size: 15px; font-weight: 800; letter-spacing: 1px; }

/* ---------- crosshair screen ---------- */
.xh-layout { display: grid; grid-template-columns: 1fr 340px; gap: 40px; align-items: start; }
.xh-label { margin-bottom: 14px; }
#xh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-bottom: 32px; }
.xh-tile {
  all: unset; box-sizing: border-box;
  aspect-ratio: 1; border: 3px solid var(--fg); background: var(--bg);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.xh-tile img { width: 64px; height: 64px; pointer-events: none; }
.xh-tile:hover { border-color: var(--accent); }
.xh-tile.sel { border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--accent); }
.xh-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 12px; }
#xh-preview {
  position: relative; width: 100%; aspect-ratio: 1;
  border: 3px solid var(--fg); background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.xh-dot { position: absolute; width: 80px; height: 80px; background: var(--accent); border-radius: 50%; }
#xh-preview-img { position: relative; pointer-events: none; }
#xh-preview:hover #xh-preview-img { visibility: hidden; }

/* ---------- hud ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--hud);
  display: none; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  border-bottom: 3px solid var(--fg);
  background: var(--bg);
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  pointer-events: none;
  z-index: 2;
}
#hud.on { display: flex; }
#hud-stats { display: flex; gap: 32px; }
.stat b { color: var(--accent); margin-left: 10px; }
.lives { display: inline-flex; gap: 5px; vertical-align: middle; margin-left: 10px; }
.lives i { width: 14px; height: 14px; border: 3px solid var(--accent); }
.lives i.full { background: var(--accent); }

#countdown-hint { position: fixed; left: 50%; transform: translateX(-50%); top: 66%; padding: 6px 12px; font-size: 14px; font-weight: 800; letter-spacing: 2px; white-space: nowrap; color: #fff; background: rgba(0,0,0,0.55); pointer-events: none; z-index: 6; }
#countdown-hint:empty { display: none; }
#countdown {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 200px; font-weight: 800; color: var(--accent);
  pointer-events: none;
  z-index: 2;
}

#gameover {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--accent);
  font-size: clamp(56px, 12vw, 120px); font-weight: 800; letter-spacing: -3px;
  opacity: 0; visibility: hidden; pointer-events: none;
  z-index: 4;
}
#gameover.on { visibility: visible; pointer-events: auto; opacity: 1; transition: opacity 0.5s linear; cursor: default; }

/* ---------- sliders ---------- */
.range { display: flex; align-items: center; gap: 20px; max-width: 560px; }
.range-val { min-width: 72px; font-size: 18px; font-weight: 800; color: var(--accent); }
.range input {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 28px; background: transparent; cursor: pointer;
}
.range input::-webkit-slider-runnable-track { height: 4px; background: var(--fg); }
.range input::-moz-range-track { height: 4px; background: var(--fg); }
.range input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -9px;
  background: var(--accent); border: 3px solid var(--fg); border-radius: 0;
}
.range input::-moz-range-thumb { width: 16px; height: 16px; background: var(--accent); border: 3px solid var(--fg); border-radius: 0; }

/* ---------- results ---------- */
.kicker { font-size: 17px; font-weight: 800; letter-spacing: 2px; }
.big { font-size: clamp(90px, 20vw, 160px); font-weight: 800; color: var(--accent); line-height: 1; letter-spacing: -5px; margin-top: 10px; }
.tag { display: inline-block; margin-top: 14px; padding: 6px 14px; background: var(--fg); color: var(--ink); font-size: 15px; font-weight: 800; letter-spacing: 2px; }
.tag.new { background: var(--accent); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  border-top: 3px solid var(--fg); border-left: 3px solid var(--fg);
  margin-top: 36px;
}
.cell { border-right: 3px solid var(--fg); border-bottom: 3px solid var(--fg); padding: 20px; }
.cell .k { font-size: 14px; font-weight: 800; letter-spacing: 1px; }
.cell .v { font-size: 34px; font-weight: 800; margin-top: 8px; }

/* ---------- phones and tablets (body.touch is only ever set there) ---------- */
#touch-exit { display: none; }
body.touch { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; touch-action: manipulation; }
body.touch canvas#game { touch-action: none; }
body.touch.in-game #touch-exit {
  all: unset; display: flex; align-items: center; justify-content: center;
  position: fixed; top: 6px; right: 6px; width: 44px; height: 44px;
  background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 20px; font-weight: 800;
  z-index: 3;
}
body.touch #hud { padding-right: 60px; }
body.touch #xh-btn, body.touch .keys, body.touch #binds-intro, body.touch #binds-list, body.touch #binds-reset { display: none; }
body.touch .screen { padding: 24px 16px 64px; }
body.touch .cards { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); margin-top: 32px; }
body.touch .card { min-height: 0; padding: 20px; }
body.touch .tabs { margin-top: 28px; }
body.touch #set-view { margin: 0 0 20px; }
body.touch .wpn-tiles { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
body.touch #countdown { font-size: 120px; }
/* A tap leaves :hover stuck on, so undo the hover styles. */
body.touch .card:hover { background: var(--bg); border-color: var(--fg); color: var(--fg); }
body.touch .tab:hover, body.touch .opt:hover, body.touch .link:hover { color: inherit; }
body.touch .tab.sel:hover { color: var(--ink); }
body.touch .opt.sel:hover { color: var(--ink); }
body.touch .btn:hover { background: var(--bg); border-color: var(--fg); color: var(--fg); }
body.touch .btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--ink); }
body.touch .btn.danger:hover { background: var(--bg); border-color: #d00000; color: #d00000; }
body.touch .btn.danger.armed, body.touch .btn.danger.armed:hover { background: #d00000; border-color: #d00000; color: #ffffff; }
body.touch .wpn-card:hover { border-color: var(--fg); }
body.touch .wpn-card.open:hover { border-color: var(--accent); }
body.touch .wpn-tile:hover { border-color: transparent; }
body.touch .wpn-tile.sel:hover { border-color: var(--accent); }

/* Narrow phones: the stats wrap onto two lines inside the same bar, so the time stays visible. */
@media (max-width: 640px) {
  body.touch #hud { padding-left: 10px; gap: 8px; font-size: 13px; letter-spacing: 0; }
  body.touch #hud-stats { flex-wrap: wrap; gap: 2px 10px; min-width: 0; line-height: 1.25; }
  body.touch #hud-right { flex-shrink: 0; }
  body.touch .stat b { margin-left: 4px; }
}

@media (max-width: 860px) {
  .row.has-pv, .xh-layout { grid-template-columns: 1fr; }
  canvas.pv { width: 100%; max-width: 420px; }
  .xh-side { position: static; max-width: 340px; }
}
@media (max-width: 640px) {
  #hud-stats { gap: 14px; }
  #hud-mode { display: none; }
}
