:root {
  --ink: #1d1a2b;
  --gold: #ffd23f;
  --purple: #b86bff;
  --pink: #ff5d8f;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd8ff; font-family: var(--font); color: #fff; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- lobby */
.lobby { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(29,26,43,0.15), rgba(29,26,43,0.55)); overflow-y: auto; }
.lobby-card { width: min(460px, 100%); background: #fffaf0; color: var(--ink); border: 4px solid var(--ink); border-radius: 26px; padding: 26px 26px 20px; box-shadow: 0 10px 0 var(--ink); text-align: center; }
.logo { margin: 0; font-size: 54px; line-height: 0.95; letter-spacing: 1px; font-weight: 900; text-transform: uppercase; }
.logo span { display: inline-block; color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.logo span:last-child { color: var(--purple); }
.logo em { font-style: normal; display: inline-block; margin: 0 8px; color: var(--pink); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; transform: rotate(-12deg); }
.tagline { margin: 10px 0 18px; font-weight: 700; color: #4a4560; }
.field { display: block; text-align: left; font-weight: 700; font-size: 14px; margin: 10px 0; }
.field input:not([type=range]) { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 18px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); }
.field input[type=range] { display: block; width: 100%; accent-color: var(--purple); }
.buttons { display: grid; gap: 10px; margin: 14px 0 10px; }
.btn { font: inherit; font-weight: 800; font-size: 16px; padding: 10px 16px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .06s, box-shadow .06s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.btn.big { font-size: 20px; padding: 14px; background: var(--gold); }
.btn.alt { background: #d9b8ff; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; text-decoration: underline; }
.join { display: flex; gap: 8px; }
.join input { flex: 1; min-width: 0; font: inherit; font-size: 17px; font-weight: 700; letter-spacing: 3px; text-transform: uppercase; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 14px; }
.error { color: #c81d4a; font-weight: 700; min-height: 1.2em; margin: 8px 0 0; }
.invite { background: #e9ffe0; border: 2px dashed #3aa55e; border-radius: 12px; padding: 8px; font-weight: 700; }
.how { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px; text-align: left; margin-top: 12px; color: #4a4560; }
kbd { display: inline-block; font: inherit; font-weight: 800; font-size: 11px; padding: 1px 6px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; color: var(--ink); box-shadow: 0 2px 0 var(--ink); margin: 0 2px; }
.rules { font-size: 12px; color: #6a6580; margin: 12px 0 0; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: 0 2px 0 var(--ink); }
#hud .menu, #hud .menu * { pointer-events: auto; }
.top { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: flex-start; }
.scores { display: flex; gap: 8px; }
.score { display: flex; flex-direction: column; align-items: center; min-width: 70px; padding: 4px 10px 6px; border: 3px solid var(--ink); border-radius: 14px; background: var(--c); color: var(--ink); text-shadow: none; box-shadow: 0 4px 0 var(--ink); }
.score span { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.score b { font-size: 26px; line-height: 1; }
.score.mine { transform: scale(1.12); outline: 3px solid #fff; outline-offset: 2px; }
.clockbox { text-align: center; padding-top: 2px; }
.clock { font-size: 34px; font-weight: 900; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.phase { font-size: 15px; font-weight: 800; white-space: nowrap; }
.phase .open { color: #e2b8ff; }
.room-code { position: absolute; top: 14px; left: 16px; font-weight: 800; font-size: 14px; opacity: 0.9; }
.feed { position: absolute; top: 14px; right: 16px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; font-weight: 700; font-size: 15px; }
.feed-line { background: rgba(29,26,43,0.55); padding: 3px 10px; border-radius: 10px; transition: opacity 1s; text-shadow: none; }
.feed-line.old { opacity: 0; }
.ko { color: var(--pink); font-weight: 900; margin: 0 4px; }

.crosshair { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%); }
.crosshair i { position: absolute; background: #fff; box-shadow: 0 0 0 2px var(--ink); border-radius: 2px; }
.crosshair i:nth-child(1) { left: 12px; top: 0; width: 3px; height: 8px; }
.crosshair i:nth-child(2) { left: 12px; bottom: 0; width: 3px; height: 8px; }
.crosshair i:nth-child(3) { top: 12px; left: 0; width: 8px; height: 3px; }
.crosshair i:nth-child(4) { top: 12px; right: 0; width: 8px; height: 3px; }
.hitmarker { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%) rotate(45deg); opacity: 0; background:
  linear-gradient(#fff,#fff) center/4px 100% no-repeat, linear-gradient(#fff,#fff) center/100% 4px no-repeat; -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px); mask: radial-gradient(circle, transparent 7px, #000 8px); }
.hitmarker.on { animation: hitm .25s ease-out; }
@keyframes hitm { from { opacity: 1; transform: translate(-50%,-50%) rotate(45deg) scale(1.3); } to { opacity: 0; transform: translate(-50%,-50%) rotate(45deg) scale(1); } }
.vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255,40,80,0.55)); }
.vignette.on { animation: vig .45s ease-out; }
@keyframes vig { from { opacity: 1; } to { opacity: 0; } }
.float-text { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 22px; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }

.portal-marker { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.portal-marker b { width: 26px; height: 26px; border: 3px solid var(--ink); border-radius: 50%; background: var(--purple); box-shadow: 0 0 14px var(--purple); animation: pulse 1s infinite alternate; }
.portal-marker span { font-weight: 800; font-size: 13px; }
.portal-marker.edge b { width: 32px; height: 32px; }
@keyframes pulse { to { transform: scale(1.2); } }

.toast { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font-weight: 900; font-size: 26px; color: var(--gold); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; opacity: 0; }
.toast.on { animation: toast 1.4s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -16px); } }
.banner { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); text-align: center; opacity: 0; }
.banner.on { animation: banner 2.8s ease-out forwards; }
.b-title { font-size: 40px; font-weight: 900; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; white-space: nowrap; }
.b-sub { font-size: 18px; font-weight: 800; }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) scale(.6); } 10% { opacity: 1; transform: translateX(-50%) scale(1.08); } 16% { transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

.bottom-left { position: absolute; left: 18px; bottom: 18px; }
.hp { position: relative; width: 240px; height: 30px; border: 3px solid var(--ink); border-radius: 15px; background: rgba(29,26,43,0.6); overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
.hp-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: #6cff7a; transition: width .15s; }
.hp span { position: relative; display: block; text-align: center; font-weight: 900; font-size: 18px; line-height: 24px; }
.carry { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 16px; border: 3px solid var(--ink); border-radius: 18px; background: rgba(29,26,43,0.55); box-shadow: 0 4px 0 var(--ink); }
.carry b { font-size: 30px; font-weight: 900; }
.carry small { font-weight: 800; font-size: 13px; opacity: 0.9; }
.carry.loaded { background: rgba(120,70,0,0.7); }
.carry.loaded b { color: var(--gold); }
.gem, .gem-s { display: inline-block; width: 22px; height: 28px; background: var(--gold); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); filter: drop-shadow(0 0 0 var(--ink)); vertical-align: middle; }
.gem-s { width: 11px; height: 14px; margin: 0 2px 0 6px; }

.center-msg { position: absolute; left: 50%; top: 68%; transform: translate(-50%, -50%); font-size: 30px; font-weight: 900; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; white-space: nowrap; animation: pulse-c .8s infinite alternate; }
@keyframes pulse-c { from { transform: translate(-50%, -50%); } to { transform: translate(-50%, -50%) scale(1.08); } }
.death { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(29,26,43,0.45); font-weight: 800; font-size: 20px; }
.death-title { font-size: 52px; font-weight: 900; color: var(--pink); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.death-lost { color: var(--gold); }
.death-timer b { font-size: 28px; }

.results { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(29,26,43,0.6); }
.results-title { font-size: 56px; font-weight: 900; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.results-list { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; text-shadow: none; }
.r-team { width: 220px; border: 3px solid var(--ink); border-radius: 16px; background: #fffaf0; color: var(--ink); overflow: hidden; box-shadow: 0 5px 0 var(--ink); }
.r-head { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--c); font-weight: 900; font-size: 18px; }
.r-row { display: flex; justify-content: space-between; padding: 6px 12px; font-size: 14px; font-weight: 700; border-top: 2px solid #eee3cf; }
.r-row.me { background: #fff1b8; }
.results-next { font-weight: 800; }

.board { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(29,26,43,0.85); border: 3px solid var(--ink); border-radius: 16px; padding: 12px 16px; text-shadow: none; }
.board table { border-collapse: collapse; font-weight: 700; }
.board th { font-size: 12px; text-transform: uppercase; opacity: 0.7; padding: 4px 12px; text-align: right; }
.board th:first-child, .board td:first-child { text-align: left; }
.board td { padding: 5px 12px; text-align: right; }
.board td i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; border: 2px solid #fff; }
.board tr.me td { color: var(--gold); }

.menu { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(29,26,43,0.5); text-shadow: none; }
.menu-card { width: min(360px, 92vw); background: #fffaf0; color: var(--ink); border: 4px solid var(--ink); border-radius: 22px; padding: 18px 20px; box-shadow: 0 8px 0 var(--ink); display: grid; gap: 10px; }
.menu-card h2 { margin: 0; font-size: 28px; text-align: center; }
.menu-card .small { margin: 0; font-size: 13px; text-align: center; color: #6a6580; }
.friends-tools { display: grid; gap: 8px; }
.friends-tools .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 900px) {
  .room-code { display: none; }
  .top { top: 8px; gap: 8px; transform: translateX(-50%) scale(0.8); transform-origin: top center; }
  .feed { top: 70px; font-size: 13px; }
  .hp { width: 160px; }
  .b-title { font-size: 28px; }
  .death-title, .results-title { font-size: 38px; }
}
