@font-face {
  font-family: 'Fredoka';
  src: url(fonts/fredoka.woff2) format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --space: #0d0720;
  --panel: rgba(24, 13, 50, 0.88);
  --panel-solid: #1c0f3c;
  --line: rgba(190, 160, 255, 0.22);
  --line-2: rgba(190, 160, 255, 0.4);
  --text: #f4efff;
  --dim: #c0b6e0;
  --faint: #8f84b6;
  --green: #7cff6b;
  --green-d: #2fae47;
  --cyan: #4fe3ff;
  --pink: #ff6bd6;
  --gold: #ffbe2e;
  --void: #9b4dff;
  --red: #ff5e7a;
  --hp: #7cff6b;
  --sh: #4fb0ff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--space); color: var(--text); }
body {
  font-family: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  font-size: 16px; line-height: 1.35;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- screens over the game ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20; overflow: auto;
  display: grid; place-items: center; padding: max(20px, var(--safe-t)) 16px max(20px, var(--safe-b));
  background: radial-gradient(ellipse at 50% 40%, rgba(13, 7, 32, 0.25), rgba(13, 7, 32, 0.78));
}
.menu { grid-template-columns: auto; gap: 18px; align-content: center; }
@media (min-width: 900px) {
  .menu { grid-template-columns: 440px 320px; justify-content: center; align-items: center; }
  .menu .howto { width: 100%; }
}
.menu-card, .howto, .landing-card, .result-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 26px;
  box-shadow: 0 20px 60px rgba(5, 0, 20, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.menu-card { width: min(440px, calc(100vw - 32px)); padding: 26px 26px 20px; }
.logo { margin: 0; font-size: clamp(46px, 11vw, 66px); line-height: 0.92; font-weight: 700; letter-spacing: 0.01em; text-transform: uppercase; display: flex; flex-wrap: wrap; gap: 0 14px; }
.logo-a { color: var(--green); text-shadow: 0 0 22px rgba(124, 255, 107, 0.55), 0 4px 0 #1f7a33; }
.logo-b { color: #fff; text-shadow: 0 0 22px rgba(176, 120, 255, 0.6), 0 4px 0 #5b2bb5; }
.tagline { margin: 10px 0 18px; color: var(--dim); font-size: 17px; }
.me { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
#preview { width: 96px; height: 96px; flex: none; border-radius: 22px; background: radial-gradient(circle at 50% 45%, rgba(124, 255, 107, 0.18), rgba(255, 255, 255, 0.03) 70%); border: 1px solid var(--line); }
.me-fields { flex: 1; min-width: 0; }
.me-fields label { display: block; font-size: 14px; color: var(--dim); margin-bottom: 6px; }
#nameInput {
  width: 100%; font: inherit; font-size: 19px; font-weight: 600; color: var(--text);
  background: rgba(255, 255, 255, 0.07); border: 2px solid var(--line); border-radius: 14px; padding: 9px 12px;
  -webkit-user-select: text; user-select: text;
}
#nameInput:focus { border-color: var(--green); outline: none; }
.skins { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.skins button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; padding: 0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.skins button[aria-checked="true"] { border-color: #fff; transform: scale(1.12); }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 16px; background: rgba(255, 255, 255, 0.06); margin-bottom: 14px; }
.modes button { border: 0; background: transparent; border-radius: 12px; padding: 9px 0; font-weight: 600; font-size: 17px; color: var(--dim); }
.modes button[aria-checked="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3), inset 0 0 0 1px var(--line-2); }
.play {
  display: block; width: 100%; border: 0; border-radius: 18px; padding: 15px 0 13px;
  background: linear-gradient(180deg, #a2ff8f, #4fdc5e); color: #0b2a12;
  font-size: 27px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  box-shadow: 0 6px 0 #1f8a37, 0 10px 30px rgba(124, 255, 107, 0.3); transition: transform 0.06s, box-shadow 0.06s;
}
.play:hover { filter: brightness(1.05); }
.play:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f8a37, 0 6px 20px rgba(124, 255, 107, 0.3); }
.play:disabled { filter: grayscale(0.7) brightness(0.8); cursor: default; }
.ghost { border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.06); border-radius: 14px; padding: 11px 16px; font-weight: 600; }
.ghost:hover { background: rgba(255, 255, 255, 0.12); }
.link { border: 0; background: none; color: var(--cyan); font-weight: 600; padding: 6px 2px; font-size: 16px; }
.link:hover { text-decoration: underline; }
.link.small { font-size: 14px; color: var(--dim); }
.party { margin-top: 12px; text-align: center; }
.party-box { text-align: left; margin-top: 8px; padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.party-box p { margin: 0 0 10px; color: var(--dim); font-size: 14px; }
.party-link { display: flex; gap: 6px; }
.party-link input { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; -webkit-user-select: all; user-select: all; }
.party-link button { border: 0; border-radius: 10px; padding: 0 14px; background: var(--cyan); color: #04202a; font-weight: 700; }
.party-list { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 6px; }
.party-list li { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.party-list li i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.party-list li small { color: var(--faint); font-weight: 400; }
.note { min-height: 1.3em; margin: 10px 0 0; text-align: center; color: var(--gold); font-size: 15px; }
.howto { width: min(440px, calc(100vw - 32px)); padding: 18px 22px; font-size: 15px; color: var(--dim); }
.howto h2 { margin: 0 0 10px; font-size: 18px; color: var(--text); }
.howto p { margin: 10px 0 0; }
.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
kbd { display: inline-block; min-width: 24px; padding: 1px 6px; margin-right: 3px; border-radius: 7px; background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line-2); border-bottom-width: 3px; font: inherit; font-size: 13px; font-weight: 600; text-align: center; color: var(--text); }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: grid; } .desktop-only { display: none; } }
.online { position: fixed; left: calc(14px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); margin: 0; font-size: 14px; color: var(--dim); }
.online::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 7px; box-shadow: 0 0 8px var(--green); }
.corner-btn { position: fixed; top: calc(12px + var(--safe-t)); right: calc(12px + var(--safe-r)); z-index: 30; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel); font-size: 19px; display: grid; place-items: center; }
/* on narrow screens the menu scrolls: keep the sound button and the online count below the cards */
@media (max-width: 899px) {
  .menu .online, .menu .corner-btn { position: static; justify-self: center; }
  .menu .online { order: 3; }
  .menu .corner-btn { order: 4; }
}

/* ---------- landing ---------- */
.landing-card { padding: 18px 18px 12px; text-align: center; width: min(640px, calc(100vw - 24px)); }
.landing-card h2 { margin: 0 0 12px; font-size: 22px; }
#landMap { width: 100%; aspect-ratio: 1; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); border-radius: 16px; cursor: crosshair; touch-action: none; display: block; margin: 0 auto; object-fit: contain; }
.land-info { margin: 10px 0 2px; color: var(--dim); }
.land-info b { color: var(--green); font-size: 20px; }

/* ---------- the game's heads-up display ---------- */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud button, .hud canvas#minimap, .hud .slot, .hud .item { pointer-events: auto; }
.hud-tl { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: grid; gap: 8px; justify-items: start; }
.stats { display: flex; gap: 6px; }
.stats span, .zone-info, .mate, .feed li, .prompt, .action, .watch, .notice, .ammo {
  background: rgba(16, 8, 36, 0.72); border: 1px solid var(--line); border-radius: 12px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.stats span { padding: 5px 11px; font-size: 15px; color: var(--dim); }
.stats b { color: var(--text); font-size: 19px; margin-right: 3px; }
.zone-info { padding: 6px 11px; font-size: 15px; font-weight: 600; }
.zone-info:empty { display: none; }
.zone-info.warn { border-color: rgba(176, 100, 255, 0.8); color: #e3c8ff; box-shadow: 0 0 18px rgba(155, 77, 255, 0.45); }
.zone-info.out { background: rgba(120, 30, 190, 0.85); color: #fff; animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 26px rgba(190, 100, 255, 0.9); } }
.zone-info .arrow { display: inline-block; margin-left: 6px; transition: transform 0.2s; }
.mate { padding: 7px 10px; min-width: 170px; font-size: 14px; }
.mate .row { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.mate .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.mate .state { margin-left: auto; color: var(--faint); font-weight: 400; font-size: 13px; }
.mate .mbar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); margin-top: 6px; overflow: hidden; display: flex; }
.mate .mbar b { display: block; height: 100%; }
.mate.down { border-color: var(--red); }
.mate.down .state { color: var(--red); font-weight: 600; }
.hud-tr { position: absolute; right: calc(12px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: grid; gap: 8px; justify-items: end; }
#minimap { width: 168px; height: 168px; border-radius: 16px; border: 2px solid var(--line-2); background: #0b0618; cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; justify-items: end; max-width: 300px; }
.feed li { padding: 4px 10px; font-size: 14px; color: var(--dim); animation: feedIn 0.25s ease-out; transition: opacity 0.6s; }
.feed li b { color: var(--text); font-weight: 600; }
.feed li.mine { border-color: rgba(124, 255, 107, 0.6); }
.feed li.me { border-color: rgba(255, 94, 122, 0.7); }
.feed li .w { color: var(--faint); margin: 0 4px; }
.feed li.fade { opacity: 0; }
@keyframes feedIn { from { transform: translateX(20px); opacity: 0; } }
.notice { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 10px 18px; font-size: 22px; font-weight: 700; text-align: center; border-color: rgba(124, 255, 107, 0.7); color: var(--green); animation: pop 0.3s cubic-bezier(.2, 1.6, .5, 1); white-space: nowrap; }
.notice.bad { color: var(--red); border-color: rgba(255, 94, 122, 0.7); }
@keyframes pop { from { transform: translateX(-50%) scale(0.6); opacity: 0; } }
.prompt { position: absolute; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); padding: 7px 14px; font-size: 16px; font-weight: 600; white-space: nowrap; }
.prompt kbd { margin-right: 8px; }
.prompt .r { font-weight: 700; }
.action { position: absolute; left: 50%; bottom: calc(196px + var(--safe-b)); transform: translateX(-50%); padding: 7px 14px 9px; min-width: 190px; text-align: center; font-size: 15px; font-weight: 600; }
.action i { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); margin-top: 6px; overflow: hidden; }
.action b { display: block; height: 100%; width: 0; background: var(--cyan); border-radius: 3px; }
.hud-bottom { position: absolute; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; }
.bars { width: 320px; display: grid; gap: 4px; }
.bar { position: relative; height: 18px; border-radius: 9px; background: rgba(10, 4, 24, 0.75); border: 1px solid var(--line); overflow: hidden; }
.bar b { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transition: width 0.15s; }
.bar.sh { height: 10px; }
.bar.sh b { background: linear-gradient(180deg, #8ad0ff, var(--sh)); box-shadow: 0 0 10px rgba(79, 176, 255, 0.6); }
.bar.hp b { background: linear-gradient(180deg, #b6ffa8, var(--hp)); }
.bar.hp.low b { background: linear-gradient(180deg, #ffb0bd, var(--red)); }
.bar.hp.knocked b { background: repeating-linear-gradient(45deg, var(--red) 0 8px, #b8324c 8px 16px); }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #0b1a0a; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4); }
.slots { display: flex; gap: 8px; }
.slot {
  position: relative; width: 112px; height: 70px; border-radius: 14px; border: 2px solid var(--line); background: rgba(16, 8, 36, 0.78);
  display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: 4px 6px 5px; cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.slot.on { transform: translateY(-5px); border-color: var(--rc, #fff); box-shadow: 0 0 18px color-mix(in srgb, var(--rc, #fff) 45%, transparent); }
.slot canvas { width: 84px; height: 34px; }
.slot .nm { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slot .am { position: absolute; right: 7px; top: 4px; font-size: 13px; font-weight: 700; }
.slot .am.empty { color: var(--red); }
.slot .k { position: absolute; left: 7px; top: 3px; font-size: 12px; color: var(--faint); font-weight: 600; }
.slot.none canvas { opacity: 0.25; }
.items { position: absolute; right: calc(12px + var(--safe-r)); bottom: calc(12px + var(--safe-b)); display: grid; grid-template-columns: repeat(2, 58px); gap: 7px; }
.item { position: relative; width: 58px; height: 58px; border-radius: 15px; border: 2px solid var(--line); background: rgba(16, 8, 36, 0.78); display: grid; place-items: center; padding: 0; }
.item canvas { width: 34px; height: 34px; }
.item .c { position: absolute; right: 5px; bottom: 2px; font-size: 14px; font-weight: 700; }
.item .k { position: absolute; left: 6px; top: 2px; font-size: 11px; color: var(--faint); font-weight: 600; }
.item.zero { opacity: 0.38; }
.item.busy { border-color: var(--cyan); }
.ammo { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); display: flex; gap: 10px; padding: 6px 11px; font-size: 14px; font-weight: 600; }
.ammo span { display: flex; align-items: center; gap: 5px; }
.ammo i { width: 9px; height: 14px; border-radius: 3px; display: inline-block; }
.watch { position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; font-size: 16px; }
.watch button { border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.08); border-radius: 10px; min-width: 40px; height: 36px; font-size: 18px; font-weight: 600; }
.corner-btn.exit { background: rgba(16, 8, 36, 0.6); font-size: 16px; color: var(--dim); top: calc(12px + var(--safe-t)); right: calc(192px + var(--safe-r)); width: 38px; height: 38px; }
.bigmap { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; background: rgba(8, 3, 20, 0.72); }
.bigmap canvas { width: min(88vmin, 760px); height: min(88vmin, 760px); border-radius: 20px; border: 2px solid var(--line-2); }
.bigmap p { position: absolute; bottom: 14px; margin: 0; color: var(--dim); font-size: 14px; }

/* ---------- touch controls ---------- */
.touch { position: absolute; inset: 0; pointer-events: none; }
.stick { position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.06); opacity: 0; transition: opacity 0.15s; }
.stick.on { opacity: 1; }
.stick i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); box-shadow: 0 0 14px rgba(255, 255, 255, 0.25); }
#stickR i { background: rgba(255, 120, 150, 0.45); }
#stickR.fire i { background: rgba(255, 94, 122, 0.85); }
.tbtn { position: absolute; pointer-events: auto; width: 56px; height: 56px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.3); background: rgba(16, 8, 36, 0.6); font-size: 26px; font-weight: 700; display: grid; place-items: center; }
#tReload { right: calc(150px + var(--safe-r)); bottom: calc(150px + var(--safe-b)); }
#tHeal { right: calc(90px + var(--safe-r)); bottom: calc(196px + var(--safe-b)); color: var(--green); }
.tbtn.use { width: auto; height: 46px; border-radius: 23px; padding: 0 16px; font-size: 16px; left: 50%; transform: translateX(-50%); bottom: calc(160px + var(--safe-b)); background: rgba(124, 255, 107, 0.9); color: #0b2a12; border-color: transparent; }

/* small screens and phones */
@media (max-width: 760px), (max-height: 560px) {
  #minimap { width: 112px; height: 112px; border-radius: 12px; }
  .feed { max-width: 220px; }
  .feed li { font-size: 12px; padding: 3px 8px; }
  .bars { width: 220px; }
  .bar { height: 15px; }
  .bar.sh { height: 8px; }
  .slot { width: 76px; height: 52px; border-radius: 12px; padding: 2px 4px 3px; }
  .slot canvas { width: 58px; height: 24px; }
  .slot .nm { font-size: 10px; }
  .slot .am { font-size: 11px; right: 5px; top: 2px; }
  .slot .k { display: none; }
  .items { grid-template-columns: repeat(4, 46px); gap: 5px; }
  .item { width: 46px; height: 46px; border-radius: 12px; }
  .item canvas { width: 26px; height: 26px; }
  .item .k { display: none; }
  .stats span { font-size: 13px; padding: 4px 9px; }
  .stats b { font-size: 16px; }
  .zone-info { font-size: 13px; }
  .notice { font-size: 17px; top: 18%; }
  .prompt { bottom: calc(118px + var(--safe-b)); font-size: 14px; }
  .action { bottom: calc(150px + var(--safe-b)); }
  .ammo { display: none; }
}
@media (pointer: coarse) {
  .items { bottom: auto; top: calc(132px + var(--safe-t)); right: calc(12px + var(--safe-r)); grid-template-columns: repeat(2, 46px); }
  .hud-bottom { bottom: calc(8px + var(--safe-b)); }
  .prompt kbd { display: none; }
}
@media (max-width: 760px), (max-height: 560px) { .corner-btn.exit { right: calc(134px + var(--safe-r)); } }

/* ---------- results ---------- */
.result { z-index: 25; }
.result-card { width: min(460px, calc(100vw - 32px)); padding: 26px; text-align: center; }
.result-card.small { width: min(360px, calc(100vw - 32px)); }
.kicker { margin: 0; font-size: 15px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; }
.result-card h2 { margin: 6px 0 4px; font-size: clamp(30px, 7vw, 42px); line-height: 1.05; }
.result-card.win h2 { color: var(--gold); text-shadow: 0 0 24px rgba(255, 190, 46, 0.6); }
.sub { margin: 4px 0 0; color: var(--dim); }
.res-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.res-stats div { background: rgba(255, 255, 255, 0.06); border-radius: 14px; padding: 9px 4px; }
.res-stats dt { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.res-stats dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; }
.res-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-btns .play { grid-column: 1 / -1; font-size: 22px; padding: 12px 0 11px; }
.confirm { z-index: 40; background: rgba(8, 3, 20, 0.6); }

.toast { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 50; padding: 8px 16px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--line-2); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); max-width: calc(100vw - 32px); text-align: center; }
.conn { position: fixed; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%); z-index: 60; padding: 7px 14px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--gold); color: var(--gold); font-weight: 600; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-size: 20px; }
