/* =====================================================================
   HUNT DESIGN SYSTEM — every out-of-match screen uses only these tokens.
   3 button sizes · 2 card styles · 1 icon style · 1 outline · 1 shadow.
   ===================================================================== */
:root {
  /* colour */
  --ink: #12091e;           /* the one outline colour */
  --bg: #150b24;            /* darker hunter theme: deep purples and blacks, gold + red accents */
  --panel: #2c1846;
  --panel-2: #1e1033;
  --panel-hi: #6a2a6e;
  --gold: #ffd23f;
  --gold-2: #ffb800;
  --mint: #4be0c8;
  --red: #e0283f;
  --green: #4be06e;
  --blue: #3a86ff;
  --text: #ffffff;
  --text-dim: #c4b4dc;
  --role-balanced: #ffb000;
  --role-tank: #ff7b39;
  --role-sniper: #19b6a6;
  --role-controller: #e0a03a;
  --role-trapper: #6f9a3a;
  --role-assassin: #9d4dff;
  /* shape */
  --line: 4px;               /* the one outline thickness */
  --radius: 18px;
  --radius-sm: 12px;
  --drop: 0 5px 0 var(--ink);      /* the one shadow */
  --drop-press: 0 1px 0 var(--ink);
  /* type */
  --font: "Lilita One", "Arial Black", system-ui, sans-serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* motion */
  --ease-out: cubic-bezier(.2, .9, .3, 1.15);
  --t-screen: 260ms;
  --t-press: 90ms;
  /* safe areas (notch / home indicator) */
  --sa-t: max(8px, env(safe-area-inset-top));
  --sa-r: max(10px, env(safe-area-inset-right));
  --sa-b: max(8px, env(safe-area-inset-bottom));
  --sa-l: max(10px, env(safe-area-inset-left));
  /* scale with the short side of the screen so phones and iPads both fit
     (2vw keeps upright phones from getting desktop-sized controls on a narrow screen) */
  --u: clamp(5px, min(1.35vh, 2vw), 10px);
  /* text never shrinks below these, however small --u gets: labels / things a player must read */
  --t-xs: 11px;
  --t-sm: 12px;
  /* smallest touch target on phones and tablets */
  --tap: 44px;
}

/* ---------- buttons: sm / md / lg ---------- */
.btn {
  font-family: var(--font); color: var(--ink); background: var(--gold);
  border: var(--line) solid var(--ink); border-radius: var(--radius-sm); box-shadow: var(--drop);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  line-height: 1; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: transform var(--t-press) ease-out, box-shadow var(--t-press) ease-out, filter .15s;
  position: relative;
}
.btn-sm { font-size: max(var(--t-sm), calc(var(--u) * 1.6)); padding: calc(var(--u) * .5) calc(var(--u) * 1.2); }
.btn-md { font-size: max(var(--t-sm), calc(var(--u) * 2.2)); padding: calc(var(--u) * .8) calc(var(--u) * 2); }
.btn-lg { font-size: calc(var(--u) * 4.2); padding: calc(var(--u) * 1.1) calc(var(--u) * 4); border-radius: var(--radius); }
.btn.alt { background: var(--panel-2); color: var(--text); }
.btn.mint { background: var(--mint); }
.btn.red { background: var(--red); color: var(--text); }
.btn.pressed, .btn:active { transform: translateY(4px) scale(.96, .92); box-shadow: var(--drop-press); }
.btn.released { animation: btn-bounce 260ms var(--ease-out); }
.btn[disabled] { filter: grayscale(.8) brightness(.8); pointer-events: none; }
@keyframes btn-bounce { 0% { transform: scale(.96, .92); } 55% { transform: scale(1.06, 1.04); } 100% { transform: none; } }

/* ---------- cards: A (solid panel) / B (art card with coloured backdrop) ---------- */
.card-a { background: var(--panel); border: var(--line) solid var(--ink); border-radius: var(--radius); box-shadow: var(--drop); }
.card-b {
  --card-col: var(--panel-hi);
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--card-col) 85%, #fff 15%), var(--card-col) 55%, color-mix(in srgb, var(--card-col) 60%, var(--ink) 40%));
  border: var(--line) solid var(--ink); border-radius: var(--radius); box-shadow: var(--drop); position: relative; overflow: visible;
}

/* ---------- icon style: chunky filled shapes with the ink outline (see ui/icons.js) ---------- */
.ico { width: 1.6em; height: 1.6em; display: inline-block; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* ---------- typography helpers ---------- */
.title { font-family: var(--font); color: var(--gold); -webkit-text-stroke: calc(var(--line) * .8) var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); letter-spacing: 1px; }
.outlined { font-family: var(--font); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.dot { position: absolute; top: -4px; right: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--red); border: 3px solid var(--ink); }
.dot[hidden] { display: none; }

/* ---------- screens: slide + scale in (no hard cuts) ---------- */
.ui-screen { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: rgba(14, 7, 24, .86);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }
.ui-screen.enter { animation: screen-in var(--t-screen) var(--ease-out) both; }
.ui-screen.leave { animation: screen-out 200ms ease-in both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes screen-out { to { opacity: 0; transform: translateY(16px) scale(.97); } }
.ui-head { display: flex; align-items: center; gap: calc(var(--u) * 1.2); margin-bottom: calc(var(--u) * 1); }
.ui-head .title { font-size: calc(var(--u) * 4); flex: 1; }
.ui-body { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }

/* ---------- the creator credit over menus (ui/fx.js adds #ovCredit) ----------
   Shown while a menu screen, popup or detail card is open (the store has its own line), above all of
   them, in a bottom strip they leave free. A race shows its own credit, so this one steps aside. */
.ov-credit { display: none; position: fixed; z-index: 120; left: calc(var(--sa-l) + 8px); bottom: max(3px, env(safe-area-inset-bottom)); font: 400 11px/1.2 var(--font); letter-spacing: .02em; color: var(--gold); text-shadow: 0 1px 0 var(--ink), 0 0 3px var(--ink); pointer-events: none; white-space: nowrap; }
body:has(:is(.ui-screen:not(.store-screen), .ui-pop, .detail):not([hidden]):not(.leave)) .ov-credit { display: block; }
body:has(.rc-root) .ov-credit { display: none; }
/* the lobby's own line is under the dim then: hide it so the two never show doubled */
body:has(:is(.ui-screen:not(.store-screen), .ui-pop, .detail):not([hidden]):not(.leave)):not(:has(.rc-root)) #lobby #credit { visibility: hidden; }
html body :is(.ui-screen:not(.store-screen), .ui-pop, .detail) { padding-bottom: calc(max(3px, env(safe-area-inset-bottom)) + 17px); }

/* ---------- popups ---------- */
.ui-pop { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(27, 16, 51, .6); padding: var(--sa-t) var(--sa-r) var(--sa-b) var(--sa-l); }
.ui-pop > .card-a { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: calc(var(--u) * 2); text-align: center; }
.ui-pop.enter > .card-a { animation: pop-in 280ms var(--ease-out) both; }
@keyframes pop-in { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- reward burst ---------- */
.rays { position: fixed; z-index: 60; pointer-events: none; width: 120vmin; height: 120vmin; left: 50%; top: 50%; margin: -60vmin 0 0 -60vmin;
  background: repeating-conic-gradient(rgba(255, 230, 120, .55) 0 8deg, transparent 8deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 15%, transparent 65%); mask: radial-gradient(circle, #000 15%, transparent 65%);
  animation: rays 1.1s ease-out both; }
@keyframes rays { from { opacity: 0; transform: scale(.4) rotate(0); } 25% { opacity: 1; } to { opacity: 0; transform: scale(1.1) rotate(40deg); } }
.confetti { position: fixed; z-index: 61; pointer-events: none; width: 10px; height: 14px; border: 2px solid var(--ink); border-radius: 3px; }
.flycoin { position: fixed; z-index: 62; pointer-events: none; width: 26px; height: 26px; transition: transform .7s cubic-bezier(.5, 0, .7, 1), opacity .7s; }
body.reduce-flash .rays { animation: fade-soft 1s ease-out both; background: radial-gradient(circle, rgba(255, 230, 120, .45), transparent 60%); }
@keyframes fade-soft { from { opacity: 0; } 30% { opacity: 1; } to { opacity: 0; } }

/* ---------- forms ---------- */
.field { width: 100%; font: inherit; font-family: var(--font); font-size: max(var(--t-sm), calc(var(--u) * 2.2)); padding: calc(var(--u) * 1) calc(var(--u) * 1.4); border-radius: var(--radius-sm); border: var(--line) solid var(--ink); background: #fff; color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; }
.slider { width: 100%; accent-color: var(--gold); }
.chipbtn { font-family: var(--font); color: var(--text); background: var(--panel-2); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px; cursor: pointer; }
.chipbtn.on { background: var(--gold); color: var(--ink); }
/* chips: one size everywhere, one line, scroll sideways if they don't fit */
.chipbtn { font-size: max(var(--t-sm), calc(var(--u) * 1.7)); padding: calc(var(--u) * .3) calc(var(--u) * 1.2); white-space: nowrap; flex: none; }
.chips { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.ui-head .chips { flex: 2; }

/* ---------- touch: every control is at least a thumb wide and tall ---------- */
@media (any-pointer: coarse) {
  .btn, .chipbtn { min-height: var(--tap); min-width: var(--tap); }
  .chips { gap: 8px; }
  .field { min-height: var(--tap); }
  .slider { min-height: var(--tap); }
  .ui-head { gap: 8px; }
}

/* ---------- the lobby's credit line is a button that opens Credits (ui/screens.js openCredits) ----------
   It keeps the plain small-text look; on touch an invisible pad makes it a bigger target without
   changing its box (so layout checks against the line still see the text). wireCredit
   (ui/screens.js) sizes it (--cr-up, --cr-down, --cr-side) to 44px tall, or less where other
   controls sit right above and below the line, so it never takes a tap meant for one of them. */
#lobby #credit { -webkit-appearance: none; appearance: none; background: none; border: 0; border-radius: 2px; margin: 0; padding: 0; color: inherit; line-height: 1.2; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#lobby.sp #credit { color: var(--sp-gold); line-height: 1; }
#lobby #credit:focus-visible { outline: 2px solid var(--mint, #34e7ff); outline-offset: 3px; }
@media (pointer: coarse) {
  #lobby #credit::before { content: ""; position: absolute; left: calc(-1 * var(--cr-side, 0px)); right: calc(-1 * var(--cr-side, 0px)); top: calc(-1 * var(--cr-up, 0px)); bottom: calc(-1 * var(--cr-down, 0px)); }
}
.set-credits { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: var(--tap, 44px); margin-top: 12px; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, .18); border-radius: var(--radius-sm, 6px); background: rgba(255, 255, 255, .04); color: #fff; font: 700 15px/1.1 var(--font); letter-spacing: .1em; cursor: pointer; text-align: left; }
.set-credits small { font: 600 12px/1.2 var(--font-ui, var(--font)); letter-spacing: .04em; color: var(--gold); text-align: right; }
/* the Credits card: wordmark, then who made it */
.cr-pop > .card-a { width: min(440px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 20px 16px; }
.cr-pop.enter > .card-a { animation: cr-fade 220ms ease-out both; }
@keyframes cr-fade { from { opacity: 0; } to { opacity: 1; } }
.cr-brand { width: min(300px, 80%); }
.cr-brand svg { display: block; width: 100%; height: auto; }
.cr-h { margin: 2px 0 0; font: 700 13px/1 var(--font-ui, var(--font)); letter-spacing: .3em; color: var(--text-dim, #b9b0d8); }
.cr-list { margin: 0; display: grid; gap: 10px; width: 100%; }
.cr-list > div { display: grid; gap: 2px; }
.cr-list dt { font: 600 12px/1.2 var(--font-ui, var(--font)); letter-spacing: .08em; color: var(--text-dim, #b9b0d8); }
.cr-list dd { margin: 0; font: 700 20px/1.2 var(--font); letter-spacing: .04em; color: #fff; }
.cr-list > div:first-child dd { color: var(--gold); }
@media (max-height: 420px) { .cr-pop > .card-a { gap: 6px; padding: 12px 16px 10px; } .cr-brand { width: min(240px, 60%); } .cr-list { gap: 5px; } .cr-list dd { font-size: 17px; } }
