/* The fonts come with the game (css/fonts, each under the SIL Open Font License), so playing never contacts another website. */
@font-face { font-family: 'Bungee'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/bungee.woff2') format('woff2'); }
@font-face { font-family: 'Creepster'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/creepster.woff2') format('woff2'); }
@font-face { font-family: 'Rubik'; font-style: normal; font-weight: 300 900; font-display: swap; src: url('fonts/rubik.woff2') format('woff2'); }

:root {
  --panel: rgba(20, 13, 38, .95); --line: rgba(255, 255, 255, .12);
  --text: #f4f0ff; --muted: #b3a9d6; --green: #7CFC4A; --gold: #FFD23F; --red: #ff5a5a;
  --p1: #ff7a59; --p2: #5ab0ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #0b0716; overflow: hidden; color: var(--text);
  font-family: 'Rubik', 'Trebuchet MS', Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
html { touch-action: manipulation; }   /* no double-tap zoom on phones */
body { display: flex; align-items: center; justify-content: center; position: fixed; inset: 0; overscroll-behavior: none; }
canvas {
  display: block; width: min(100vw, calc(100vh * 16 / 9)); width: min(100vw, calc(100dvh * 16 / 9)); height: auto; aspect-ratio: 16 / 9;
  background: #000; cursor: crosshair; touch-action: none;
}

/* ---- Menus ---- */
.overlay {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 3, 14, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 20;
}
.overlay.show { display: flex; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 24px 28px 20px;
  width: 100%; max-width: 760px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; text-align: center;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
}
.panel.wide { max-width: 1060px; }
.panel.small { max-width: 560px; }
h1 {
  font-family: 'Creepster', Impact, fantasy; font-weight: 400; color: var(--green);
  font-size: clamp(48px, 8vw, 86px); line-height: .95; margin: 0 0 4px; letter-spacing: 3px;
  text-shadow: 0 5px 0 #1d4d12, 0 0 34px rgba(124, 252, 74, .35);
}
h1.red { color: var(--red); text-shadow: 0 5px 0 #5a1414, 0 0 34px rgba(255, 90, 90, .35); }
h2 { font-family: 'Bungee', sans-serif; font-weight: 400; margin: 0; font-size: 30px; color: var(--gold); }
.lead { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 6px auto 14px; max-width: 580px; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.btn {
  font-family: 'Bungee', sans-serif; font-size: 18px; padding: 13px 26px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--green); color: #10210a; box-shadow: 0 5px 0 #3c8a1e; transition: transform .06s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #3c8a1e; }
.btn.alt { background: #3d3163; color: var(--text); box-shadow: 0 5px 0 #241b40; }
.btn.gold { background: var(--gold); color: #3a2a00; box-shadow: 0 5px 0 #b8901c; }
.btn:disabled { background: #2a2440; color: #7d73a0; box-shadow: 0 4px 0 #1a1530; cursor: default; filter: none; transform: none; }
.btn.eq:disabled { background: rgba(255, 210, 63, .14); color: var(--gold); box-shadow: inset 0 0 0 1.5px var(--gold); }
.btn.small { font-size: 12px; padding: 9px 8px; border-radius: 10px; flex: 1; box-shadow: 0 3px 0 #3c8a1e; }
.btn.small.gold { box-shadow: 0 3px 0 #b8901c; }
.btn.small.alt { box-shadow: 0 3px 0 #241b40; }
.btn.small.p1:not(:disabled) { outline: 2px solid var(--p1); outline-offset: -2px; }
.btn.small.p2:not(:disabled) { outline: 2px solid var(--p2); outline-offset: -2px; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; cursor: pointer; margin-top: 12px; font-family: inherit; }
.link.armed { color: var(--red); font-weight: 800; text-decoration: none; }

.coin {
  display: inline-block; width: .95em; height: .95em; border-radius: 50%; vertical-align: -0.12em; margin-right: .3em;
  background: radial-gradient(circle at 35% 35%, #fff6c8 0 18%, #ffcf3a 20% 62%, #b07c12 66%);
}
.ptag { display: inline-block; font-family: 'Bungee'; font-size: 11px; padding: 2px 6px; border-radius: 6px; margin-right: 6px; color: #10101a; vertical-align: 1px; }
.ptag.p1 { background: var(--p1); }
.ptag.p2 { background: var(--p2); }
.ptag.p3 { background: #ffd23f; }
.ptag.p4 { background: #c78bff; }
.btn.small.p3:not(:disabled) { outline: 2px solid #ffd23f; outline-offset: -2px; }
.btn.small.p4:not(:disabled) { outline: 2px solid #c78bff; outline-offset: -2px; }

/* ---- Wi-Fi ---- */
.netcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 6px 0 8px; text-align: left; }
.netcol { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.netcol h3 { font-family: 'Bungee'; font-weight: 400; font-size: 16px; margin: 0; color: var(--green); }
.netcol p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; flex: 1; }
.joinrow { display: flex; gap: 8px; }
.joinrow input {
  flex: 1; min-width: 0; font-family: 'Bungee'; font-size: 22px; letter-spacing: 6px; text-align: center; padding: 8px 10px; border-radius: 12px;
  border: 2px solid #4a3f78; background: #1a1430; color: var(--gold); -webkit-user-select: text; user-select: text;
}
.joinrow input:focus { outline: none; border-color: var(--gold); }
.hostnote { display: none; font-size: 12px !important; color: #ffd98a !important; }
.neterr { color: #ff8a7a; font-weight: 800; font-size: 14px; min-height: 1em; margin: 6px 0; }
.nethelp { font-size: 13px; color: var(--muted); background: rgba(255, 210, 63, .08); border: 1px solid rgba(255, 210, 63, .25); border-radius: 12px; padding: 10px 12px; line-height: 1.45; }
.joincode { font-family: 'Bungee'; font-size: 16px; color: var(--muted); margin: 10px 0 2px; }
.joincode b { display: block; font-size: 54px; letter-spacing: 10px; color: var(--gold); font-weight: 400; line-height: 1.1; }
.lplayers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.lp { display: flex; align-items: center; gap: 4px; background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 10px 12px; font-size: 14px; text-align: left; }
.lp.empty { opacity: .45; }
.lpc { margin-left: auto; font-family: 'Bungee'; color: var(--gold); font-size: 13px; }
.owners { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.owners .ptag { font-size: 9px; padding: 1px 5px; margin-right: 2px; }
.wallet.me { box-shadow: inset 0 0 0 2px var(--gold); }
#shopNote { margin-top: 10px; text-align: center; }

.mode { display: inline-flex; background: rgba(0, 0, 0, .3); border-radius: 14px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.mode button { font-family: 'Bungee'; font-size: 14px; border: 0; border-radius: 10px; padding: 9px 18px; cursor: pointer; background: transparent; color: var(--muted); }
.mode button.active { background: var(--green); color: #10210a; }

.controls { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(4, auto); grid-auto-flow: column; gap: 7px 22px; text-align: left; margin: 0 auto 12px; max-width: 600px; font-size: 13.5px; color: #ddd6f5; }
.controls em { font-style: normal; color: var(--muted); margin-left: 6px; }
.controls .padrow { grid-column: 1 / -1; grid-row: 5; text-align: center; color: var(--muted); }   /* game controller help (js/gamepad.js) */
.kc {
  display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 2px; border-radius: 6px;
  background: #2e2550; border: 1px solid #4a3f78; border-bottom-width: 3px; font-family: 'Bungee'; font-size: 10px; text-align: center; color: #fff;
}
.wallets { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; font-size: 15px; color: var(--muted); }
.wallets b { color: var(--gold); font-family: 'Bungee'; font-weight: 400; }
.wallets.big { font-size: 24px; margin: 10px 0; }
.wallet { font-family: 'Bungee'; font-size: 20px; color: var(--gold); background: rgba(0, 0, 0, .3); padding: 6px 14px; border-radius: 12px; }

.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 14px 0 2px; }
.lvl {
  font-family: inherit; color: var(--text); text-align: left; cursor: pointer; border-radius: 16px; padding: 12px 14px;
  background: linear-gradient(160deg, #3a2a64, #241a40); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px;
  transition: transform .08s, border-color .15s;
}
.lvl:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--green); }
.lvl.locked { opacity: .5; cursor: default; }
.lvl .lnum { font-family: 'Bungee'; font-size: 11px; color: var(--green); }
.lvl .lname { font-family: 'Bungee'; font-size: 17px; }
.lvl .lblurb { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.lvl .lcheck { font-size: 12px; color: var(--gold); font-weight: 800; margin-top: 2px; }

/* ---- Shop ---- */
.shophead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; text-align: left; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.card { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.card.equipped { border-color: rgba(255, 210, 63, .6); }
.card img { width: 100%; height: 70px; object-fit: contain; background: radial-gradient(ellipse at center, rgba(255, 255, 255, .08), transparent 70%); border-radius: 10px; }
.cname { font-family: 'Bungee'; font-size: 14px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.price { font-size: 13px; color: var(--gold); white-space: nowrap; }
.price.free { color: var(--green); font-size: 10px; }
.cdesc { font-size: 12.5px; color: var(--muted); line-height: 1.35; min-height: 34px; }
.stats { display: flex; flex-direction: column; gap: 3px; }
.stat { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 6px; font-size: 11px; color: #cfc6ee; }
.stat i { display: block; height: 7px; border-radius: 4px; background: linear-gradient(90deg, var(--c) var(--v), rgba(255, 255, 255, .08) var(--v)); }
.buyrow { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }
.btn.small.sell { flex: 0 0 auto; background: #5a2f3a; color: #ffd6dc; box-shadow: 0 3px 0 #3a1a22; }
.shopsec { grid-column: 1 / -1; font-family: 'Bungee'; font-size: 18px; color: var(--gold); text-align: left; margin: 10px 2px -2px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.shopsec:first-child { margin-top: 0; }
.shopsec span { font-family: 'Rubik', sans-serif; font-size: 12.5px; color: var(--muted); font-weight: 500; }

.stats3 { display: flex; gap: 10px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.stats3 div { background: rgba(255, 255, 255, .05); border-radius: 14px; padding: 12px 16px; min-width: 130px; }
.stats3 b { display: block; font-family: 'Bungee'; font-weight: 400; font-size: 26px; color: var(--gold); }
.stats3 span { font-size: 12px; color: var(--muted); }

/* ---- Touch buttons ---- */
#touch { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
#touch.show { display: block; }
.tb {
  position: absolute; pointer-events: auto; touch-action: none; width: 70px; height: 70px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .12); color: #fff; font-family: 'Bungee'; font-size: 15px;
}
.tb.on { background: rgba(255, 255, 255, .32); }
/* anchored to the screen corners (and clear of the notch on phones) */
.t-left { left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); }
.t-right { left: calc(104px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); }
.t-down { left: calc(70px + env(safe-area-inset-left)); bottom: calc(102px + env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 13px; }
.t-jump { right: calc(118px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); }
.t-fire { right: calc(18px + env(safe-area-inset-right)); bottom: calc(62px + env(safe-area-inset-bottom)); width: 90px; height: 90px; background: rgba(255, 80, 80, .25); }
.t-swap { right: calc(132px + env(safe-area-inset-right)); bottom: calc(112px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
.t-pause { right: calc(16px + env(safe-area-inset-right)); top: calc(16px + env(safe-area-inset-top)); width: 48px; height: 48px; font-size: 13px; }
/* the grenade button shows the kind you'll throw and how many you have; the small one next to it switches kind */
.t-nade { right: calc(31px + env(safe-area-inset-right)); bottom: calc(166px + env(safe-area-inset-bottom)); width: 64px; height: 64px; background: rgba(255, 210, 63, .2); }
.t-nade .nimg { position: absolute; inset: 7px 12px 15px; background: center / contain no-repeat; pointer-events: none; }
.t-nade .ncount { position: absolute; right: 9px; bottom: 5px; font-size: 13px; pointer-events: none; }
.t-nade.empty { opacity: .45; }
.t-ntype { right: calc(104px + env(safe-area-inset-right)); bottom: calc(178px + env(safe-area-inset-bottom)); width: 46px; height: 46px; font-size: 10px; }

/* ---- Phones ---- */
#rotate { display: none; position: fixed; inset: 0; z-index: 40; background: #0b0716; color: var(--text); align-items: center; justify-content: center; text-align: center; font-family: 'Bungee'; font-size: 20px; padding: 30px; line-height: 1.4; }
.rotphone { width: 46px; height: 76px; border: 4px solid var(--green); border-radius: 10px; margin: 0 auto 18px; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (pointer: coarse) { body.ingame #rotate { display: flex; } }
/* short screens (phones on their side): smaller menus so everything fits */
@media (max-height: 520px) {
  .overlay { padding: 8px calc(8px + env(safe-area-inset-right)) 8px calc(8px + env(safe-area-inset-left)); }
  .panel { padding: 12px 16px 12px; border-radius: 16px; max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  h1 { font-size: 40px; }
  h2 { font-size: 22px; }
  .lead { font-size: 13px; margin: 4px auto 8px; line-height: 1.35; }
  .btn { font-size: 15px; padding: 10px 18px; }
  .row { margin-top: 10px; }
  .mode { margin-bottom: 8px; }
  .mode button { padding: 7px 14px; font-size: 13px; }
  .levels { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; margin-top: 8px; }
  .lvl { padding: 8px 10px; border-radius: 12px; }
  .lvl .lname { font-size: 14px; }
  .lvl .lblurb { font-size: 11px; }
  .joincode b { font-size: 40px; }
  .lplayers { margin: 6px 0; gap: 6px; }
  .lp { padding: 7px 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
  .card { padding: 8px; gap: 4px; }
  .card img { height: 46px; }
  .cdesc { min-height: 0; font-size: 11.5px; }
  .shophead { margin-bottom: 8px; }
}
@media (max-height: 520px) and (pointer: coarse) { .controls { display: none; } }   /* keyboard help, not needed on phones */

@media (max-width: 640px) { .controls { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; } .controls .padrow { grid-row: auto; text-align: left; } }
