/* PrisonBall Player — visual system
 * Same neon-on-near-black prison cyberpunk as PrisonBaLL Manager, so both
 * games read as one universe.
 *
 * DESIGN-TOKENS nedenfor findes i tre kopier, fordi der ikke er noget
 * build-step: her, i manager.html og i index.html (landing). Ændrer du en
 * værdi, så ret den alle tre steder — ellers driver de to spil fra hinanden
 * én farve ad gangen, og det er netop den slags drift ingen opdager.
 * (--purple bruges kun her.)
 */

:root {
  --bg0: #03030a;
  --bg1: #07070f;
  --bg2: #0d0d1a;
  --bg3: #141422;
  --panel: linear-gradient(160deg, #111120 0%, #0e0e1c 40%, #131325 100%);
  --metal: linear-gradient(160deg, #1e1e32 0%, #161626 50%, #1a1a2e 100%);
  --border: rgba(0,220,255,0.18);
  --border-hot: rgba(0,220,255,0.55);
  --cyan: #00dcff;
  --cyan-dim: rgba(0,220,255,0.35);
  --orange: #ff7700;
  --orange-dim: rgba(255,119,0,0.35);
  --red: #ff1a3e;
  --gold: #ffc200;
  --green: #00ff88;
  --purple: #cc44ff;
  --text: #b8c8d8;
  --text-bright: #e0eef8;
  --text-dim: #8494a4;
  --font-head: 'Orbitron', monospace;
  --font-body: 'Rajdhani', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}
html { overscroll-behavior-y: contain; }

body::before {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px);
  pointer-events: none; z-index: 9999;
}

/* ── Layout ───────────────────────────────────────────────────────────── */
#app { max-width: 1180px; margin: 0 auto; padding: 0 14px 90px; }

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topbar {
  position: sticky; top: 0; z-index: 60;
  background: linear-gradient(180deg, rgba(3,3,10,.98), rgba(3,3,10,.90));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  margin: 0 -14px 16px; padding: 8px 14px 0;
}
.topbar-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tb-brand {
  font-family: var(--font-head); font-weight: 900; font-size: 15px; letter-spacing: 1.5px;
  color: var(--cyan); text-shadow: 0 0 14px var(--cyan-dim);
}
.tb-stat { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); }
.tb-stat b { color: var(--text-bright); font-weight: 600; }
.tb-spacer { flex: 1; }

.nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 0 6px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 0 0 auto; background: var(--bg2); color: var(--text-dim);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 6px 6px 0 0; padding: 8px 15px;
  font-family: var(--font-head); font-size: 11px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.nav-btn:hover { color: var(--text-bright); border-color: var(--border-hot); }
.nav-btn.active {
  background: var(--metal); color: var(--cyan);
  border-color: var(--border-hot); box-shadow: 0 -2px 14px rgba(0,220,255,.18);
}

/* ── Panels & typography ──────────────────────────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; margin-bottom: 14px;
}
.panel.hot { border-color: var(--border-hot); box-shadow: 0 0 22px rgba(0,220,255,.10); }

.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title {
  font-family: var(--font-head); font-size: 13px; font-weight: 800; letter-spacing: 2px;
  color: var(--cyan); text-transform: uppercase;
}
.section-sub { font-size: 13px; color: var(--text-dim); }

h1.big {
  font-family: var(--font-head); font-size: clamp(26px, 6vw, 46px); font-weight: 900;
  letter-spacing: 3px; color: var(--text-bright);
  text-shadow: 0 0 30px var(--cyan-dim); text-align: center; margin: 26px 0 4px;
}
.tagline { text-align: center; color: var(--text-dim); letter-spacing: 3px; font-size: 12px;
  font-family: var(--font-mono); margin-bottom: 26px; text-transform: uppercase; }

.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  background: var(--metal); color: var(--text-bright);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 11px 20px; cursor: pointer;
  font-family: var(--font-head); font-size: 12px; font-weight: 700; letter-spacing: 1.2px;
  transition: all .15s;
}
.btn:hover { border-color: var(--border-hot); box-shadow: 0 0 16px rgba(0,220,255,.22); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: linear-gradient(160deg, #0d3a48, #06202b); color: var(--cyan); border-color: var(--border-hot); }
.btn.danger { color: var(--red); border-color: rgba(255,26,62,.45); }
.btn.gold { color: var(--gold); border-color: rgba(255,194,0,.45); }
.btn.sm { padding: 7px 13px; font-size: 10px; }
.btn.block { width: 100%; }

/* ── Badges, pills, stats ─────────────────────────────────────────────── */
.team-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--sz, 56px); height: var(--sz, 56px); flex: 0 0 auto;
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tc) 25%, transparent), transparent 70%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--tc) 40%, transparent);
}
.team-badge img { width: 88%; height: 88%; object-fit: contain; }

.pos-badge {
  display: inline-block; min-width: 26px; text-align: center;
  border-radius: 4px; padding: 2px 6px; font-family: var(--font-head);
  font-size: 10px; font-weight: 800; letter-spacing: .5px;
  border: 1px solid currentColor;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
  padding: 4px 11px; font-size: 12px; font-family: var(--font-mono); color: var(--text-dim);
}
.pill b { color: var(--text-bright); }

.stat-tile {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; text-align: center;
}
.stat-tile .v { font-family: var(--font-head); font-size: 24px; font-weight: 900; color: var(--text-bright); line-height: 1.1; }
.stat-tile .l { font-size: 10px; letter-spacing: 1.4px; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }

.bar { height: 7px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; transition: width .35s; }

/* Where you played. One cell per patch of pitch, one sample per match-second —
   too coarse for a blur to be honest about, so it is drawn as the grid it is.
   aspect-ratio keeps the block in the arena's proportions (1408x620). */
.heatmap {
  display: grid; gap: 2px; aspect-ratio: 1408 / 620;
  margin: 10px 0 6px; padding: 4px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
}
.heatmap > i { display: block; border-radius: 2px; }

/* ── Mugshot ──────────────────────────────────────────────────────────── */
.mug {
  border-radius: 8px; border: 1px solid var(--border); background: var(--bg3);
  object-fit: cover; display: block;
}
.mug.hero { width: 132px; height: 132px; border-color: var(--border-hot); box-shadow: 0 0 26px rgba(0,220,255,.22); }
.mug.sm { width: 44px; height: 44px; }

/* ── Tables ───────────────────────────────────────────────────────────── */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; padding: 7px 8px; font-family: var(--font-head);
  font-size: 10px; letter-spacing: 1px; color: var(--text-dim);
  border-bottom: 1px solid var(--border); text-transform: uppercase;
}
table.tbl td { padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,.04); }
table.tbl tr.me { background: rgba(0,220,255,.09); }
table.tbl tr.me td { color: var(--text-bright); font-weight: 600; }
.num { font-family: var(--font-mono); text-align: right; }

/* ── Stat rows ────────────────────────────────────────────────────────── */
.statrow { display: grid; grid-template-columns: 96px 1fr 34px; gap: 9px; align-items: center; margin-bottom: 6px; }
.statrow .k { font-size: 12px; color: var(--text-dim); text-transform: capitalize; }
.statrow .n { font-family: var(--font-mono); font-size: 13px; text-align: right; color: var(--text-bright); }
.statrow .up { color: var(--green); }
.statrow .down { color: var(--red); }

/* ── Match screen ─────────────────────────────────────────────────────── */
#match-wrap { position: relative; }
#match-canvas {
  /* Starting value only — sizeCanvas() in js/match.js sets the real height so the
     canvas's INNER box (after the renderer's 16px inset on each side) carries the
     arena's proportions. Get that wrong and x and y scale differently: at 16/9 the
     world came out stretched 25% vertically and a 45° input travelled at 51°. */
  width: 100%; aspect-ratio: 1408 / 620; display: block;
  background: #05050e; border: 1px solid var(--border-hot); border-radius: 10px;
  box-shadow: 0 0 34px rgba(0,220,255,.14);
}
.match-scoreline {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.match-scoreline .sc {
  font-family: var(--font-head); font-size: 34px; font-weight: 900; color: var(--text-bright);
  letter-spacing: 3px;
}
.match-scoreline .tn { font-family: var(--font-head); font-size: 13px; letter-spacing: 1.4px; }
.match-clock { font-family: var(--font-mono); color: var(--gold); font-size: 15px; }

.match-controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.hud-bar {
  display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 13px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
}
.hud-bar b { color: var(--cyan); }
.keyhint {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px;
  color: var(--text-dim);
}
.keyhint kbd {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 7px; color: var(--text-bright); font-size: 11px;
}

/* ── Modal ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(2,2,8,.86); backdrop-filter: blur(4px);
}
.overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border-hot); border-radius: 12px;
  padding: 22px; max-width: 620px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 0 50px rgba(0,220,255,.16);
}
.modal h3 {
  font-family: var(--font-head); font-size: 15px; letter-spacing: 2px; color: var(--cyan);
  margin-bottom: 12px; text-transform: uppercase;
}
.modal-actions { display: flex; gap: 9px; margin-top: 18px; flex-wrap: wrap; }

/* ── Forms ────────────────────────────────────────────────────────────── */
input[type=text], select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-bright); padding: 10px 12px; font-family: var(--font-body); font-size: 15px; width: 100%;
}
input[type=text]:focus, select:focus { outline: none; border-color: var(--border-hot); }
label.field { display: block; margin-bottom: 13px; }
label.field > span {
  display: block; font-family: var(--font-head); font-size: 10px; letter-spacing: 1.4px;
  color: var(--text-dim); margin-bottom: 5px; text-transform: uppercase;
}

.choice-grid { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; cursor: pointer; transition: all .15s; text-align: left;
}
.choice:hover { border-color: var(--border-hot); }
.choice.sel { border-color: var(--border-hot); background: rgba(0,220,255,.09); box-shadow: 0 0 16px rgba(0,220,255,.16); }
.choice .t { font-family: var(--font-head); font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--text-bright); }
.choice .d { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.35; }

/* ── Log / news ───────────────────────────────────────────────────────── */
.logrow { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 14px; display: flex; gap: 10px; }
.logrow .tag {
  font-family: var(--font-head); font-size: 9px; letter-spacing: 1px; padding: 2px 6px;
  border-radius: 3px; border: 1px solid currentColor; height: fit-content; flex: 0 0 auto; min-width: 62px; text-align: center;
}
.logrow .tx { flex: 1; }
.logrow .wk { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); flex: 0 0 auto; }

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--metal); border: 1px solid var(--border-hot); border-radius: 8px;
  padding: 12px 20px; color: var(--text-bright); font-size: 14px; z-index: 500;
  opacity: 0; pointer-events: none; transition: all .25s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Sub tabs ─────────────────────────────────────────────────────────── */
.subtabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.subtab {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 13px; cursor: pointer; color: var(--text-dim);
  font-family: var(--font-head); font-size: 10px; font-weight: 700; letter-spacing: 1px;
}
.subtab.active { color: var(--cyan); border-color: var(--border-hot); background: var(--metal); }

/* ── Misc ─────────────────────────────────────────────────────────────── */
.dim { color: var(--text-dim); }
.bright { color: var(--text-bright); }
.gold { color: var(--gold); }
.green { color: var(--green); }
.red { color: var(--red); }
.cyan { color: var(--cyan); }
.orange { color: var(--orange); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hidden { display: none !important; }

@media (max-width: 620px) {
  body { font-size: 16px; }
  #app { padding: 0 10px 80px; }
  .mug.hero { width: 104px; height: 104px; }
  .match-scoreline .sc { font-size: 26px; }
}

/* ── The cage ─────────────────────────────────────────────────────────────── */
#fight-shell { position: relative; }
#fight-canvas {
  width: 100%; display: block; background: #05050e;
  border: 1px solid rgba(255,26,62,.55); border-radius: 10px;
  box-shadow: 0 0 34px rgba(255,26,62,.16);
}
.cage-head {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 10px; flex-wrap: wrap;
}
.cage-head .vs {
  font-family: var(--font-head); font-size: 22px; font-weight: 900;
  color: var(--red); letter-spacing: 3px;
}
.cage-log {
  margin-top: 10px; max-height: 118px; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
}
.cage-log div { padding: 1px 0; }
.cage-log div.big { color: var(--red); font-weight: 700; }

/* ── The wing ────────────────────────────────────────────────────────────
   Read-only by design: in PrisonBaLL Manager the block is something you
   arrange, and here it is something that happens to you. */
.wing-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cell {
  flex: 1 1 130px; min-width: 130px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px; position: relative;
}
.cell .n {
  position: absolute; top: 5px; right: 7px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; color: var(--text-dim);
}
.cell.yours { border-color: var(--border-hot); box-shadow: 0 0 14px rgba(0,220,255,.15); }
.cell.hole { border-color: rgba(255,26,62,.45); background: rgba(255,26,62,.05); }
.cell.hole .n { color: var(--red); }
.cell.hole.empty { opacity: .45; }
.bunk { display: flex; align-items: center; gap: 7px; margin-top: 3px; font-size: 13px; cursor: pointer; }
.bunk .mug.sm { width: 26px; height: 26px; }
.bunk b { font-weight: 600; }
