:root {
  --ink: #e9eef2;
  --dim: #9fb0bd;
  --panel: rgba(9, 14, 20, 0.78);
  --line: rgba(255, 255, 255, 0.14);
  --navy: #38b6ff;
  --pirate: #ff4a2a;
  --gold: #ffc93a;
  --font: "Bahnschrift SemiCondensed", "Bahnschrift", "Avenir Next Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  /* Heavy poster face for the kill/death callouts (Futura is the iPhone fallback). */
  --gta: Impact, Haettenschweiler, "Futura-CondensedExtraBold", "Futura Condensed ExtraBold", "Arial Black", sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b1118; color: var(--ink);
  font-family: var(--font); -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: none; -webkit-tap-highlight-color: transparent;
}
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 0.35em; margin: 0 0.1em; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); font-family: inherit; font-size: 0.9em; text-align: center;
}

/* ---------------------------------------------------------------- loading + menu */
.logo {
  font-size: clamp(44px, 9vw, 104px); font-weight: 700; letter-spacing: 0.08em; line-height: 0.9;
  color: #f4f6f7; text-shadow: 0 3px 0 #000, 0 0 30px rgba(0, 0, 0, 0.6);
}
.logo-img { display: block; width: min(500px, 82vw); height: auto; margin: 0 0 4px -10px; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55)); }
.loading .logo-img { margin: 0 auto; width: min(560px, 80vw); }
.logo-sub {
  display: inline-block; margin-top: 8px; padding: 3px 12px; background: var(--pirate); color: #fff;
  font-weight: 700; letter-spacing: 0.4em; font-size: clamp(13px, 2vw, 20px); transform: skewX(-12deg);
}
.loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1a2a3a 0%, #070b10 75%); z-index: 50; text-align: center;
}
.load-bar { width: min(340px, 70vw); height: 4px; background: rgba(255, 255, 255, 0.12); margin-top: 34px; }
.load-bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }
.load-msg { margin-top: 12px; color: var(--dim); letter-spacing: 0.1em; font-size: 14px; }

.menu {
  position: fixed; inset: 0; display: flex; align-items: center; padding: max(16px, env(safe-area-inset-left));
  background: linear-gradient(90deg, rgba(5, 9, 14, 0.88) 0%, rgba(5, 9, 14, 0.55) 45%, rgba(5, 9, 14, 0) 75%); z-index: 20;
  overflow-y: auto; touch-action: pan-y;
}
.menu-card { width: min(560px, 100%); padding: 10px 24px; }
.tag { color: var(--dim); font-size: 17px; margin: 16px 0 22px; max-width: 30em; }
.opt { margin-bottom: 14px; }
.opt-l { display: block; font-size: 12px; letter-spacing: 0.3em; color: var(--dim); margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg4 { grid-template-columns: repeat(4, 1fr); }
.seg button {
  padding: 10px 8px; background: rgba(255, 255, 255, 0.06); color: var(--ink); border: 1px solid var(--line);
  font-size: 15px; font-weight: 600; letter-spacing: 0.06em; text-align: left;
}
.seg4 button { text-align: center; font-size: 13px; }
.seg button small { display: block; font-weight: 400; color: var(--dim); font-size: 12px; letter-spacing: 0.04em; margin-top: 2px; }
.seg button.on { background: rgba(255, 201, 58, 0.16); border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }
.play {
  margin: 10px 0 18px; width: 100%; padding: 14px; font-size: 24px; font-weight: 700; letter-spacing: 0.3em;
  background: var(--gold); color: #111; border: 0; clip-path: polygon(0 0, 100% 0, 97% 100%, 3% 100%);
}
.play:hover { filter: brightness(1.1); }
.keys { color: var(--dim); font-size: 14px; line-height: 1.9; }
.keys b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- HUD */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.tl { position: absolute; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); width: 230px; }
#minimap { display: block; width: 220px; height: 70px; background: rgba(4, 10, 16, 0.6); border: 1px solid var(--line); }
.scorebar { margin-top: 6px; background: rgba(4, 10, 16, 0.6); border: 1px solid var(--line); padding: 5px 8px; width: 220px; }
.sb-row { display: flex; align-items: center; gap: 6px; height: 20px; font-size: 14px; font-weight: 600; }
.sb-row i { width: 8px; height: 14px; display: inline-block; }
.sb-row .nm { width: 64px; letter-spacing: 0.08em; font-size: 12px; overflow: hidden; white-space: nowrap; }
.sb-row .bar { flex: 1; height: 6px; background: rgba(255, 255, 255, 0.1); }
.sb-row .bar b { display: block; height: 100%; width: 0; }
.sb-row .sc { width: 28px; text-align: right; font-size: 16px; }
.sb-time { text-align: right; font-size: 13px; color: var(--dim); letter-spacing: 0.1em; margin-top: 2px; }

.killfeed { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(64px, env(safe-area-inset-right)); text-align: right; }
.kf {
  background: rgba(4, 10, 16, 0.6); padding: 3px 10px; margin-bottom: 4px; font-size: 14px; font-weight: 600;
  display: flex; gap: 8px; align-items: center; justify-content: flex-end; transition: opacity 0.4s;
}
.kf .how { color: var(--dim); font-size: 12px; letter-spacing: 0.08em; }
.kf.me { box-shadow: inset -3px 0 0 var(--gold); }

.cross { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: transform 0.08s; }
.cross i { position: absolute; background: rgba(255, 255, 255, 0.9); box-shadow: 0 0 2px #000; }
.cross i:nth-child(1) { width: 2px; height: 8px; left: -1px; top: -16px; }
.cross i:nth-child(2) { width: 2px; height: 8px; left: -1px; top: 8px; }
.cross i:nth-child(3) { width: 8px; height: 2px; left: -16px; top: -1px; }
.cross i:nth-child(4) { width: 8px; height: 2px; left: 8px; top: -1px; }
.cross b { position: absolute; width: 4px; height: 4px; left: -2px; top: -2px; background: #fff; border-radius: 50%; box-shadow: 0 0 2px #000; }
.cross.lunge i { background: var(--pirate); }
.cross.lunge { transform: scale(0.7); }
.cross.enemy b { background: var(--pirate); }
.hitmark { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; opacity: 0; }
.hitmark::before, .hitmark::after {
  content: ""; position: absolute; left: 14px; top: 0; width: 2px; height: 30px; background: #fff; box-shadow: 0 0 3px #000;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%, 0 65%, 100% 65%, 100% 100%, 0 100%);
}
.hitmark::before { transform: rotate(45deg); }
.hitmark::after { transform: rotate(-45deg); }
.hitmark.on { animation: hit 0.45s ease-out; }
@keyframes hit { 0% { opacity: 1; transform: scale(1.4); } 100% { opacity: 0; transform: scale(1); } }

.medals { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; }
.medal {
  font-size: 26px; font-weight: 700; letter-spacing: 0.12em; color: var(--gold); text-shadow: 0 2px 0 #000, 0 0 16px rgba(255, 180, 40, 0.5);
  animation: medal 1.9s ease-out forwards;
}
.medal small { display: block; font-size: 14px; color: #fff; letter-spacing: 0.1em; }
@keyframes medal { 0% { opacity: 0; transform: scale(1.6); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.popups { position: absolute; left: 50%; top: 56%; transform: translateX(-50%); }
.pop { color: var(--gold); font-weight: 700; font-size: 20px; text-shadow: 0 2px 0 #000; animation: pop 1.1s ease-out forwards; text-align: center; }
@keyframes pop { 0% { opacity: 0; transform: translateY(8px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.center-msg {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: clamp(28px, 6vw, 64px); font-weight: 700;
  letter-spacing: 0.15em; text-shadow: 0 3px 0 #000; text-align: center; white-space: nowrap;
}
.center-msg small { display: block; font-size: 0.35em; letter-spacing: 0.25em; color: var(--dim); }

.knives {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; background: rgba(4, 10, 16, 0.55); padding: 8px 12px; border: 1px solid var(--line);
}
.kslot { width: 46px; height: 46px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); position: relative; }
.kslot::before {
  content: ""; position: absolute; left: 21px; top: 6px; width: 5px; height: 25px; background: linear-gradient(#f2f5f7, #9aa4ab);
  clip-path: polygon(50% 0, 100% 22%, 100% 100%, 0 100%, 0 22%); opacity: 0.18;
}
.kslot::after { content: ""; position: absolute; left: 20px; top: 31px; width: 7px; height: 10px; background: #222; border: 1px solid #555; opacity: 0.18; }
.kslot.full { background: rgba(255, 201, 58, 0.12); border-color: rgba(255, 201, 58, 0.6); }
.kslot.full::before, .kslot.full::after { opacity: 1; }
.khint { font-size: 13px; letter-spacing: 0.1em; color: var(--dim); margin-left: 4px; }
.knives.flash { animation: kflash 0.5s; }
@keyframes kflash { 0%, 100% { background: rgba(4, 10, 16, 0.55); } 30% { background: rgba(255, 201, 58, 0.45); } }
.knives.empty .khint { color: var(--pirate); }

.toast {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); font-size: 18px; font-weight: 600; letter-spacing: 0.1em;
  text-shadow: 0 2px 0 #000; opacity: 0; transition: opacity 0.25s; white-space: nowrap;
}
.toast.on { opacity: 1; }
.markers { position: absolute; inset: 0; }
.mk {
  position: absolute; transform: translate(-50%, -100%); font-size: 11px; font-weight: 700; color: var(--gold); text-shadow: 0 1px 2px #000;
  text-align: center; letter-spacing: 0.05em;
}
.mk::before {
  content: ""; display: block; margin: 0 auto 2px; width: 4px; height: 14px; background: linear-gradient(#fff, var(--gold));
  clip-path: polygon(50% 0, 100% 25%, 100% 100%, 0 100%, 0 25%); transform: rotate(35deg);
}
.death {
  position: absolute; left: 50%; top: 30%; transform: translateX(-50%); text-align: center; background: rgba(60, 6, 4, 0.55);
  padding: 14px 40px; border-top: 2px solid var(--pirate); border-bottom: 2px solid var(--pirate);
}
.death-by { font-size: 13px; letter-spacing: 0.4em; color: #ffb7aa; }
.death-name { font-size: 34px; font-weight: 700; letter-spacing: 0.1em; }
.death-how { font-size: 13px; color: var(--dim); letter-spacing: 0.15em; }
.death-timer { margin-top: 6px; font-size: 13px; color: var(--dim); }
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(160, 0, 0, 0.55) 100%); opacity: 0; transition: opacity 0.3s; }
.vignette.on { opacity: 1; }

/* Kill streak toward the next Rogue Wave (under the score bar). */
.streak { margin-top: 6px; font-size: 13px; letter-spacing: 0.12em; color: var(--dim); text-shadow: 0 1px 0 #000; min-height: 16px; }
.streak b { color: #fff; font-size: 15px; }
.streak.hot i { font-style: normal; color: #5fd3ff; animation: streakpulse 0.9s ease-in-out infinite; }
@keyframes streakpulse { 50% { opacity: 0.45; } }
.center-msg .wave-you, .wave-word { color: #5fd3ff; }
.center-msg .wave-foe { color: #ff6a50; }

/* Kill callout (you got the kill): BLADED / CUTTIN' UP slams in under the medals. */
.callout {
  position: absolute; left: 50%; top: 35%; font-family: var(--gta); font-size: clamp(36px, 6.5vw, 70px); line-height: 1;
  color: #fff; -webkit-text-stroke: 1.5px #000; text-shadow: 0 3px 0 #000, 0 0 20px rgba(200, 30, 30, 0.7);
  white-space: nowrap; opacity: 0; transform: translateX(-50%) rotate(-3deg);
}
.callout.on { animation: callout 1.5s ease-out forwards; }
@keyframes callout {
  0% { opacity: 0; transform: translateX(-50%) rotate(-3deg) scale(1.9); }
  10% { opacity: 1; transform: translateX(-50%) rotate(-3deg) scale(1); }
  75% { opacity: 1; transform: translateX(-50%) rotate(-3deg) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) rotate(-3deg) translateY(-12px); }
}

/* GTA-style death cut (you got killed): the world drains to grey and pushes in,
   a dark band fades up and the word slams down; KILLED BY follows below. */
canvas#view { transform-origin: 50% 50%; }
body.cut canvas#view { filter: grayscale(1) contrast(1.15) brightness(0.78); transform: scale(1.07); transition: filter 1.1s ease-out, transform 4s ease-out; }
.cut { position: absolute; inset: 0; }
.cut-band {
  position: absolute; left: 0; right: 0; top: 50%; height: clamp(90px, 17vh, 160px); transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center; opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.65) 16%, rgba(0, 0, 0, 0.65) 84%, transparent);
  animation: cutband 0.35s ease-out 0.45s forwards;
}
.cut-band span {
  font-family: var(--gta); font-size: clamp(56px, 11vw, 128px); line-height: 1; letter-spacing: 0.02em; white-space: nowrap;
  color: #c8161d; -webkit-text-stroke: 2px #000; text-shadow: 0 4px 0 #000, 0 0 26px rgba(0, 0, 0, 0.8);
  opacity: 0; animation: cuttext 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) 0.5s forwards;
}
@keyframes cutband { to { opacity: 1; } }
@keyframes cuttext { 0% { opacity: 0; transform: scale(1.7); } 100% { opacity: 1; transform: scale(1); } }
body.cut .vignette.on { background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%); }
body.cut .death { top: auto; bottom: 13%; opacity: 0; animation: cutband 0.4s ease-out 1.4s forwards; }
.topbtns { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
.topbtns button { width: 42px; height: 38px; background: rgba(4, 10, 16, 0.6); color: var(--ink); border: 1px solid var(--line); font-size: 16px; font-weight: 700; }
.clicklock {
  position: absolute; left: 50%; top: 62%; transform: translateX(-50%); background: rgba(4, 10, 16, 0.75); padding: 10px 22px;
  border: 1px solid var(--line); letter-spacing: 0.2em; font-size: 15px;
}

/* touch controls */
.touch { position: absolute; inset: 0; pointer-events: none; }
.stick {
  position: absolute; width: 130px; height: 130px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.05); left: 60px; bottom: 50px; opacity: 0.55; transition: opacity 0.2s;
}
.stick.on { opacity: 1; }
.knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, 0.4); }
.tb {
  position: absolute; pointer-events: auto; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 16, 24, 0.5); color: #fff; font-weight: 700; letter-spacing: 0.06em; touch-action: none;
}
.tb.down { background: rgba(255, 201, 58, 0.45); }
.tb-knife { width: 92px; height: 92px; right: max(26px, env(safe-area-inset-right)); bottom: 34px; font-size: 16px; }
.tb-throw { width: 70px; height: 70px; right: max(130px, calc(env(safe-area-inset-right) + 104px)); bottom: 96px; font-size: 13px; }
.tb-throw small { display: block; font-size: 15px; color: var(--gold); }
.tb-jump { width: 62px; height: 62px; right: max(40px, env(safe-area-inset-right)); bottom: 146px; font-size: 12px; }
body.touchui .knives { bottom: auto; top: max(10px, env(safe-area-inset-top)); right: 64px; padding: 4px 8px; }
body.touchui .kslot { width: 30px; height: 30px; }
body.touchui .kslot::before { left: 13px; top: 3px; height: 16px; width: 4px; }
body.touchui .kslot::after { left: 12px; top: 19px; height: 7px; width: 6px; }
body.touchui .khint { display: none; }
body.touchui .killfeed { top: 56px; }

/* ---------------------------------------------------------------- overlays */
.scores, .overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30; background: rgba(3, 6, 10, 0.55); }
.scores { pointer-events: none; }
.sc-panel, .panel { background: var(--panel); border: 1px solid var(--line); padding: 16px 22px; min-width: min(520px, 94vw); max-height: 92vh; overflow-y: auto; }
.sc-head { font-size: 22px; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { font-size: 11px; letter-spacing: 0.2em; color: var(--dim); font-weight: 600; padding: 4px 6px; text-align: right; }
td { padding: 5px 6px; text-align: right; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.l { text-align: left; }
tr.me td { background: rgba(255, 201, 58, 0.12); }
tr.t0 td:first-child { box-shadow: inset 3px 0 0 var(--navy); }
tr.t1 td:first-child { box-shadow: inset 3px 0 0 var(--pirate); }
.panel { display: flex; flex-direction: column; gap: 8px; min-width: min(380px, 94vw); }
.panel.wide { min-width: min(520px, 94vw); }
.panel h2 { margin: 0 0 6px; font-size: 34px; letter-spacing: 0.2em; text-align: center; }
.panel button { padding: 10px; background: rgba(255, 255, 255, 0.07); color: var(--ink); border: 1px solid var(--line); font-size: 15px; letter-spacing: 0.12em; }
.panel button.big { background: var(--gold); color: #111; border: 0; font-weight: 700; font-size: 18px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 14px; color: var(--dim); }
.row button { min-width: 120px; padding: 6px 10px; }
.row input { width: 160px; }
.final-sub { text-align: center; color: var(--dim); letter-spacing: 0.15em; margin-bottom: 6px; }
.rotate {
  position: fixed; inset: 0; z-index: 60; background: #070b10; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; font-size: 22px; letter-spacing: 0.1em; text-align: center; padding: 20px;
}
.rotate button { padding: 10px 18px; background: rgba(255, 255, 255, 0.08); color: var(--ink); border: 1px solid var(--line); font-size: 15px; }
.err { position: fixed; left: 8px; bottom: 8px; right: 8px; z-index: 99; background: #5b0d0d; color: #fff; padding: 8px 12px; font: 13px monospace; }

@media (max-height: 640px) {
  .logo { font-size: 64px; }
  .tag { margin: 10px 0 12px; }
  .opt { margin-bottom: 8px; }
  .keys { line-height: 1.6; font-size: 13px; }
}
@media (max-height: 520px) {
  .menu-card { padding: 4px 10px; }
  .tag { margin: 8px 0 10px; font-size: 14px; }
  .keys { display: none; }
  .play { margin: 6px 0; padding: 10px; }
  .seg button { padding: 7px 8px; }
  #minimap { width: 160px; height: 51px; }
  .tl, .scorebar { width: 160px; }
  .sb-row .nm { width: 48px; }
}
