:root {
  --ink: #4a3f4f;
  --ink-soft: #85798a;
  --card: rgba(255, 251, 246, 0.94);
  --line: #eadfd4;
  --accent: #ff9d6c;
  --accent-deep: #f07f48;
  --blue: #7ab8ef;
  --red: #ff6b7a;
  --font: 'M PLUS Rounded 1c', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6e9df; color: var(--ink); font-family: var(--font); }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(250, 236, 226, 0.25); overflow-y: auto; }
.card {
  width: min(440px, 100%); background: var(--card); border-radius: 28px; padding: 28px 28px 22px;
  box-shadow: 0 20px 60px rgba(120, 80, 60, 0.18), 0 2px 0 #fff inset; backdrop-filter: blur(8px);
}
h1 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: 0.02em; line-height: 1.1; color: var(--accent-deep); }
h1 span { color: var(--blue); margin-left: 4px; }
h2 { margin: 0 0 14px; font-size: 22px; }
.sub { margin: 6px 0 18px; color: var(--ink-soft); font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], .field input:not([type]), .field input[readonly] {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--blue); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--ink-soft); margin: -4px 0 16px; line-height: 1.6; }
.err { color: var(--red); font-size: 13px; margin: 10px 0 0; }

.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.maps button { font: inherit; font-weight: 800; font-size: 14px; padding: 10px 8px; border-radius: 14px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.maps button span { font-size: 18px; }
.maps button.on { border-color: var(--accent); background: #fff3ea; box-shadow: 0 0 0 2px var(--accent) inset; }
.card.wide { width: min(820px, 100%); }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.account { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 6px 12px 6px 6px; font-size: 13px; font-weight: 700; }
.account img { width: 34px; height: 34px; border-radius: 50%; background: var(--line); }
.home-link { color: inherit; text-decoration: none; }
.linkbtn { font: inherit; font-size: 12px; background: none; border: 0; padding: 0; color: var(--ink-soft); cursor: pointer; text-decoration: underline; }
.login-box { text-align: center; padding: 18px 0 8px; }
.login-box p { font-size: 14px; color: var(--ink-soft); margin: 0 0 16px; }
.btn.google { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #3c4043; border: 2px solid var(--line); text-decoration: none; font-size: 17px; padding: 12px 22px; box-shadow: 0 4px 0 var(--line); }
.btn.google:hover { border-color: #c9d6ea; }
.setup-note { margin-top: 16px !important; background: #fff4e0; border-radius: 12px; padding: 10px 12px; text-align: left; font-size: 13px !important; color: var(--ink) !important; }
.setup-note code { background: #fff; padding: 1px 6px; border-radius: 6px; }
.lobby-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; margin-top: 6px; }
.dress { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.preview-wrap { align-self: start; display: grid; gap: 8px; justify-items: center; }
#preview { width: 150px; height: 230px; border-radius: 18px; background: linear-gradient(#dfeefa, #f7efe6); display: block; }
.ghost-btn { padding: 6px 12px !important; font-size: 12px !important; background: #fff !important; color: var(--ink) !important; border: 2px solid var(--line) !important; }
.dress-controls .field { margin-bottom: 9px; }
.dress-controls .field > span { margin-bottom: 4px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { font: inherit; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.chips button.on { border-color: var(--accent); background: #fff3ea; }
.colors.sm { gap: 5px; }
.colors.sm button { width: 24px; height: 24px; border-width: 2px; }
.keys-wrap { margin-top: 14px; }
.keys-wrap summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
@media (max-width: 760px) { .lobby-grid { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .dress { grid-template-columns: 1fr; } #preview { width: 100%; } }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
  box-shadow: 0 0 0 2px var(--line); transition: transform .12s;
}
.colors button:hover { transform: scale(1.08); }
.colors button.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.1); }

.btn { font: inherit; font-weight: 800; border: 0; cursor: pointer; border-radius: 16px; padding: 12px 18px; font-size: 16px; transition: transform .1s, filter .1s; }
.btn:active { transform: translateY(2px); }
.btn.primary { width: 100%; background: var(--accent); color: #fff; font-size: 20px; padding: 14px; box-shadow: 0 5px 0 var(--accent-deep); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { width: 100%; background: transparent; color: var(--ink-soft); margin-top: 6px; }
.btn.small { padding: 10px 14px; font-size: 14px; background: var(--blue); color: #fff; white-space: nowrap; }
.invite { display: flex; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
#pause .btn.primary { margin-bottom: 18px; }

.keys { margin-top: 18px; padding-top: 14px; border-top: 2px dashed var(--line); font-size: 12.5px; color: var(--ink-soft); display: grid; gap: 5px; }
kbd { display: inline-block; font: inherit; font-size: 11px; font-weight: 700; background: #fff; border: 2px solid var(--line); border-bottom-width: 3px; border-radius: 7px; padding: 0 6px; margin-right: 2px; color: var(--ink); }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; }
#heal-glow { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(95, 227, 154, 0.35) 100%); transition: opacity .3s; }
#heal-msg { position: absolute; left: 50%; bottom: 150px; transform: translate(-50%, 8px); background: rgba(95, 227, 154, .92); color: #fff; font-weight: 800; font-size: 18px; padding: 6px 18px; border-radius: 999px; opacity: 0; transition: opacity .2s, transform .2s; text-shadow: 0 1px 2px rgba(20, 90, 50, .4); }
#heal-msg.show { opacity: 1; transform: translate(-50%, 0); animation: healPulse 1s ease-in-out infinite; }
@keyframes healPulse { 50% { transform: translate(-50%, -3px) scale(1.05); } }
.heal-info { color: #2f9e62; }
#vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 90, 110, 0.55) 100%); transition: opacity .25s; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 7px; }
#crosshair i { position: absolute; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1.5px rgba(74, 63, 79, 0.55); transition: transform .08s; }
#crosshair i:nth-child(1) { width: 3px; height: 8px; left: -1.5px; top: calc(-8px - var(--gap)); }
#crosshair i:nth-child(2) { width: 3px; height: 8px; left: -1.5px; top: var(--gap); }
#crosshair i:nth-child(3) { width: 8px; height: 3px; top: -1.5px; left: calc(-8px - var(--gap)); }
#crosshair i:nth-child(4) { width: 8px; height: 3px; top: -1.5px; left: var(--gap); }
#crosshair b { position: absolute; width: 4px; height: 4px; left: -2px; top: -2px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px rgba(74, 63, 79, 0.55); }

#hitmarker { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; opacity: 0; transform: rotate(45deg) scale(.8); }
#hitmarker::before, #hitmarker::after { content: ''; position: absolute; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1.5px rgba(74, 63, 79, .6); }
#hitmarker::before { left: 17.5px; top: 0; width: 3px; height: 38px; clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%, 0 65%, 100% 65%, 100% 100%, 0 100%); }
#hitmarker::after { top: 17.5px; left: 0; height: 3px; width: 38px; clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 0 0, 65% 0, 100% 0, 100% 100%, 65% 100%); }
#hitmarker.show { animation: hm .22s ease-out; }
#hitmarker.head::before, #hitmarker.head::after { background: #ffd35c; }
#hitmarker.kill { width: 52px; height: 52px; margin: -26px 0 0 -26px; }
#hitmarker.kill::before { left: 24px; width: 4px; height: 52px; background: #ff4f63; clip-path: none; }
#hitmarker.kill::after { top: 24px; height: 4px; width: 52px; background: #ff4f63; clip-path: none; }
#hitmarker.kill.show { animation: hm .45s ease-out; }

.dmg-num { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 24px; color: #fff; pointer-events: none; white-space: nowrap;
  text-shadow: 0 2px 0 rgba(60, 40, 50, .55), 0 0 6px rgba(60, 40, 50, .35); will-change: transform; }
.dmg-num.head { color: #ffd35c; font-size: 28px; }
.dmg-num.pop { animation: dmgPop .18s ease-out; }
@keyframes dmgPop { 0% { font-size: 34px; } }
.enemy-hp { position: absolute; left: 0; top: 0; width: 64px; height: 8px; background: rgba(40, 30, 40, .45); border-radius: 999px; overflow: hidden; pointer-events: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); }
.enemy-hp .fill, .enemy-hp .lag { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 999px; }
.enemy-hp .lag { background: #fff; transition: width .4s ease-out; }
.enemy-hp .fill { background: #8fd6a0; transition: width .08s; }
.enemy-hp .fill.low { background: #ff6b7a; }
@keyframes hm { 0% { opacity: 1; transform: rotate(45deg) scale(1.25); } 100% { opacity: 0; transform: rotate(45deg) scale(.9); } }

#center-msg { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-weight: 800; font-size: 20px; color: var(--accent-deep); background: var(--card); padding: 6px 18px; border-radius: 999px; opacity: 0; transition: opacity .2s; white-space: nowrap; }
#center-msg.show { opacity: 1; }

#banner { position: absolute; left: 50%; top: 70px; transform: translate(-50%, -10px); background: var(--card); padding: 10px 20px; border-radius: 999px; font-weight: 800; font-size: 16px; box-shadow: 0 8px 24px rgba(120, 80, 60, .15); opacity: 0; transition: opacity .3s, transform .3s; white-space: nowrap; }
#banner.show { opacity: 1; transform: translate(-50%, 0); }

#feed { position: absolute; right: 18px; top: 18px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
#feed div { background: rgba(255, 251, 246, .88); padding: 6px 12px; border-radius: 12px; font-size: 14px; font-weight: 700; animation: feedIn .2s ease-out; box-shadow: 0 3px 10px rgba(120, 80, 60, .1); }
#feed div.me { box-shadow: 0 0 0 2.5px var(--accent); }
#feed .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
@keyframes feedIn { from { transform: translateX(20px); opacity: 0; } }

#hp { position: absolute; left: 22px; bottom: 22px; display: flex; align-items: center; gap: 12px; background: rgba(255, 251, 246, .88); padding: 10px 16px; border-radius: 999px; box-shadow: 0 6px 20px rgba(120, 80, 60, .12); }
#hp-bar { width: 180px; height: 14px; background: #efe3d8; border-radius: 999px; overflow: hidden; }
#hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8fd6a0, #b6e39b); border-radius: 999px; transition: width .15s; }
#hp-fill.low { background: linear-gradient(90deg, #ff7a88, #ffa38a); }
#hp-num { font-weight: 800; font-size: 22px; min-width: 42px; text-align: right; }

#ammo { position: absolute; left: 22px; bottom: 84px; background: rgba(255, 251, 246, .88); padding: 8px 16px 10px; border-radius: 18px; box-shadow: 0 6px 20px rgba(120, 80, 60, .12); min-width: 130px; }
#ammo .gun-name { font-size: 11px; font-weight: 800; color: var(--ink-soft); letter-spacing: .08em; }
#ammo .count { display: flex; align-items: baseline; gap: 6px; }
#ammo-mag { font-size: 30px; font-weight: 800; line-height: 1.1; min-width: 40px; }
#ammo .max { font-size: 14px; color: var(--ink-soft); font-weight: 700; }
#ammo.low #ammo-mag { color: var(--accent-deep); }
#ammo.empty #ammo-mag { color: var(--red); }
#ammo .reload { height: 5px; background: #efe3d8; border-radius: 999px; overflow: hidden; margin-top: 4px; }
#reload-bar { height: 100%; width: 0; background: var(--blue); border-radius: 999px; }
#reload-hint { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%); font-weight: 800; font-size: 14px; color: #fff; text-shadow: 0 1px 3px rgba(40, 30, 40, .6); white-space: nowrap; }
#crosshair { transition: opacity .1s; }

#info { position: absolute; right: 22px; bottom: 22px; background: rgba(255, 251, 246, .88); padding: 10px 16px; border-radius: 16px; font-size: 13px; font-weight: 700; line-height: 1.6; text-align: right; box-shadow: 0 6px 20px rgba(120, 80, 60, .12); }
#info .muted { color: var(--ink-soft); font-weight: 500; }

#death { position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%); text-align: center; color: var(--ink); background: var(--card); padding: 18px 34px 20px; border-radius: 28px; box-shadow: 0 16px 48px rgba(120, 80, 60, .18); }
.death-title { color: var(--red); }
.death-title { font-size: 56px; font-weight: 800; }
#death-by { font-size: 20px; font-weight: 700; margin-top: 4px; }
#death-count { font-size: 16px; margin-top: 10px; opacity: .9; }

#score { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--card); padding: 22px 26px; border-radius: 24px; min-width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(120, 80, 60, .2); }
#score table { width: 100%; border-collapse: collapse; font-size: 15px; }
#score th { text-align: left; color: var(--ink-soft); font-size: 12px; padding: 4px 8px; }
#score td { padding: 7px 8px; border-top: 1.5px solid var(--line); font-weight: 700; }
#score td:nth-child(n+3), #score th:nth-child(n+3) { text-align: center; }
#score tr.me td { color: var(--accent-deep); }
#score .tag { font-size: 10px; background: #efe3d8; color: var(--ink-soft); padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }

@media (max-width: 600px) {
  #hp-bar { width: 110px; }
  .death-title { font-size: 40px; }
}
