/* Fredoka is self-hosted (public/fonts), so the game has no external requests. */
@font-face{font-family:Fredoka;font-weight:300 700;font-display:swap;src:url(../fonts/fredoka-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Fredoka;font-weight:300 700;font-display:swap;src:url(../fonts/fredoka-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
:root {
  --ink: #3b2f4f;
  --cream: #fff7ea;
  --peach: #ffd6b8;
  --pink: #ff8fb4;
  --violet: #8a64d6;
  --mint: #8fe3c8;
  --panel: rgba(255, 247, 234, 0.82);
  --radius: 22px;
  font-family: 'Fredoka', 'Baloo 2', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f1e2d6; color: var(--ink); }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: grid; place-items: center; z-index: 10; }
#loading { background: radial-gradient(circle at 50% 40%, #fff1dc, #f4d9c4 70%); }
.loading-card { text-align: center; width: min(360px, 80vw); }
.logo-small { font-size: 28px; font-weight: 700; margin-bottom: 18px; letter-spacing: 0.5px; }
.loading-bar { height: 12px; border-radius: 99px; background: rgba(59, 47, 79, 0.12); overflow: hidden; }
.loading-fill { height: 100%; width: 40%; border-radius: 99px; background: linear-gradient(90deg, var(--pink), var(--violet)); animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
#loading-text { margin-top: 14px; opacity: 0.7; }

#title { background: linear-gradient(180deg, rgba(60, 40, 90, 0.18), rgba(255, 220, 190, 0.05) 45%, rgba(60, 40, 90, 0.35)); pointer-events: none; }
.title-card { text-align: center; pointer-events: auto; padding: 8px 20px; animation: float-in 0.9s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes float-in { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: none; } }
.badge { display: inline-block; padding: 6px 16px; border-radius: 99px; background: var(--panel); font-weight: 600; font-size: 14px; letter-spacing: 0.6px; backdrop-filter: blur(8px); }
h1 {
  margin: 14px 0 6px; font-size: clamp(48px, 9vw, 108px); line-height: 1; font-weight: 700; color: #fff;
  text-shadow: 0 4px 0 #8a64d6, 0 8px 0 #5a3ea0, 0 14px 30px rgba(40, 20, 80, 0.45);
  letter-spacing: 1px;
}
h1 .amp { color: var(--peach); }
.tagline { font-size: clamp(16px, 2.2vw, 22px); color: #fff; text-shadow: 0 2px 10px rgba(40, 20, 80, 0.6); margin: 0 0 26px; font-weight: 500; }
.hint { color: #fff; text-shadow: 0 2px 8px rgba(40, 20, 80, 0.6); margin-top: 18px; font-size: 14px; }

.btn {
  font: inherit; font-weight: 600; font-size: 22px; color: #fff; cursor: pointer; border: 0; border-radius: 99px;
  padding: 16px 40px; background: linear-gradient(180deg, #ff9cc0, #ff6f9e); box-shadow: 0 6px 0 #c9456f, 0 12px 24px rgba(120, 30, 70, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #c9456f, 0 16px 28px rgba(120, 30, 70, 0.35); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c9456f, 0 6px 12px rgba(120, 30, 70, 0.3); }
.btn.small { font-size: 14px; padding: 8px 18px; box-shadow: 0 3px 0 #c9456f; }

kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 2px; border-radius: 7px; background: #fff; color: var(--ink); font: 600 12px/1.6 inherit; box-shadow: 0 2px 0 rgba(59, 47, 79, 0.25); text-align: center; }

.panel { position: fixed; top: 14px; padding: 12px 16px; border-radius: var(--radius); background: var(--panel); backdrop-filter: blur(10px); box-shadow: 0 8px 24px rgba(60, 40, 90, 0.18); font-size: 14px; z-index: 5; }
.hud-left { left: 14px; }
.hud-right { right: 14px; display: grid; gap: 8px; }
.hud-title { font-weight: 700; font-size: 17px; margin-bottom: 4px; }
.hud-title span { font-weight: 500; font-size: 12px; background: var(--violet); color: #fff; padding: 2px 8px; border-radius: 99px; margin-left: 6px; }
.row { display: flex; gap: 12px; opacity: 0.75; margin-bottom: 8px; }
.controls { display: grid; gap: 4px; font-size: 13px; }
.hud-right label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 500; }
.hud-right select { font: inherit; border: 2px solid rgba(59, 47, 79, 0.15); border-radius: 12px; padding: 4px 8px; background: #fff; color: var(--ink); }
.check { cursor: pointer; }
.resume { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); padding: 10px 22px; border-radius: 99px; background: var(--panel); font-weight: 600; box-shadow: 0 8px 24px rgba(60, 40, 90, 0.2); pointer-events: none; z-index: 5; }

#hud .controls-free { display: none; }
#hud.playing .controls-play { display: grid; }
#hud:not(.playing) .controls-play { display: none; }
#hud:not(.playing) .controls-free { display: grid; }
.btn.ghost { background: rgba(255, 255, 255, 0.85); color: #6a4fb0; box-shadow: 0 4px 0 rgba(106, 79, 176, 0.35); font-size: 16px; padding: 10px 26px; margin-left: 10px; }
.btn.ghost:hover { box-shadow: 0 6px 0 rgba(106, 79, 176, 0.35); }
.val { opacity: 0.7; font-variant-numeric: tabular-nums; }
.hud-right input[type=range] { width: 110px; accent-color: #ff6f9e; }
#error { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; padding: 12px 16px; border-radius: 14px; background: #3b1d2f; color: #ffd6e0; font: 13px/1.4 ui-monospace, monospace; white-space: pre-wrap; max-height: 40vh; overflow: auto; }

@media (max-width: 720px) {
  .hud-left .controls { display: none; }
}

/* Stage 3: prop transformation HUD */
.play-only { display: none; }
#hud.playing .play-only { display: block; }
#reticle { position: fixed; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: rgba(255,255,255,0.9); box-shadow: 0 0 0 2px rgba(106,79,176,0.55), 0 0 10px rgba(255,255,255,0.7); pointer-events: none; z-index: 4; }
#prompt { position: fixed; left: 50%; top: calc(50% + 34px); transform: translateX(-50%) scale(0.9); opacity: 0; transition: opacity .15s, transform .15s; padding: 8px 18px; border-radius: 999px; background: rgba(255,255,255,0.92); color: #4b3a86; font-weight: 700; box-shadow: 0 4px 0 rgba(106,79,176,0.3); pointer-events: none; z-index: 4; white-space: nowrap; }
#prompt.on { opacity: 1; transform: translateX(-50%) scale(1); }
#formchip { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 10px 22px; border-radius: 22px; background: rgba(255,255,255,0.92); color: #4b3a86; text-align: center; box-shadow: 0 5px 0 rgba(106,79,176,0.3); pointer-events: none; z-index: 4; display: none !important; }
#hud.playing #formchip.on { display: block !important; }
#formchip b { display: block; font-size: 18px; }
#formchip span { font-size: 13px; opacity: 0.85; }
#toast { position: fixed; left: 50%; top: 18%; transform: translate(-50%, -8px); opacity: 0; transition: opacity .25s, transform .25s; padding: 10px 22px; border-radius: 999px; background: rgba(75, 58, 134, 0.92); color: #fff; font-weight: 700; pointer-events: none; z-index: 6; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Stage 4: lobby + network HUD */
.field { font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 999px; border: 2px solid rgba(106,79,176,0.35); background: rgba(255,255,255,0.95); color: #4b3a86; text-align: center; outline: none; width: 220px; margin: 4px 0 10px; }
.field:focus { border-color: #ff6f9e; }
.field.code { width: 80px; margin: 0 6px; text-transform: uppercase; letter-spacing: 3px; padding: 8px 10px; }
.rowbtns { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.rowbtns .btn.ghost { margin-left: 0; }
.neterr { min-height: 20px; margin: 2px 0; color: #c0396b; font-weight: 600; font-size: 14px; }
.net-only { display: none; }
#hud.online .net-only { display: block; margin: 6px 0 8px; font-size: 13px; }
#plist { list-style: none; margin: 4px 0 0; padding: 0; max-height: 150px; overflow: hidden; }
#plist li { padding: 1px 0; opacity: 0.9; }
#plist li.me { font-weight: 700; }

/* Stage 5: lobby, match HUD, results */
.lobby-card { width: min(440px, 92vw); padding: 22px 26px 24px; border-radius: 30px; background: var(--panel); backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(60,40,90,.28); text-align: center; animation: float-in .6s cubic-bezier(.2,.9,.3,1.2) both; }
.lobby-card h2 { margin: 10px 0 8px; font-size: 30px; }
.lobby-card .badge { background: #fff; }
#lb-code { letter-spacing: 4px; color: var(--violet); }
#lb-list { list-style: none; margin: 8px 0 12px; padding: 0 4px 0 0; display: grid; gap: 6px; text-align: left; max-height: 34vh; overflow-y: auto; }
#lb-list li { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 16px; background: rgba(255,255,255,.75); font-weight: 600; }
#lb-list li.me { background: #fff; box-shadow: inset 0 0 0 2px var(--pink); }
#lb-list li.away { opacity: .5; }
#lb-list li em { margin-left: auto; font-style: normal; font-weight: 500; font-size: 12px; opacity: .7; }
#lb-list li i { font-style: normal; }
.prefs { font-size: 14px; font-weight: 500; }
#lb-prefs { display: flex; gap: 6px; justify-content: center; margin: 6px 0 4px; }
#lb-prefs button { font: inherit; font-weight: 600; font-size: 14px; padding: 6px 14px; border-radius: 99px; border: 2px solid rgba(106,79,176,.3); background: #fff; color: #6a4fb0; cursor: pointer; }
#lb-prefs button.on { background: var(--violet); color: #fff; border-color: var(--violet); }
#lb-note { min-height: 22px; font-weight: 500; opacity: .85; margin: 6px 0 4px; }
#lb-start:disabled { filter: grayscale(.7); opacity: .6; cursor: not-allowed; }
.lobby-card .btn.small { margin-left: 0; }

#match { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); text-align: center; z-index: 5; pointer-events: none; }
.m-top { display: inline-flex; align-items: baseline; gap: 14px; padding: 8px 26px; border-radius: 99px; background: var(--panel); backdrop-filter: blur(10px); box-shadow: 0 6px 20px rgba(60,40,90,.2); font-weight: 600; font-size: 18px; }
#m-time { font-size: 28px; font-variant-numeric: tabular-nums; min-width: 2.6ch; }
#m-time.low { color: #d6366e; animation: pulse .8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.m-sub { margin-top: 6px; display: inline-flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.m-sub > span { padding: 3px 14px; border-radius: 99px; background: var(--panel); }
.role.hunter { background: #ffd0df !important; color: #a02456; }
.role.hider { background: #d9f6ea !important; color: #1f7a5c; }
.role.ghost, .role.spectator { background: #e8e1f7 !important; color: #5a3ea0; }
#ability, #mana { position: fixed; bottom: 26px; display: grid; justify-items: center; gap: 4px; z-index: 5; pointer-events: none; font-size: 13px; color: #fff; text-shadow: 0 2px 6px rgba(40,20,80,.7); }
#ability { right: 30px; }
.ab-ring { position: relative; width: 66px; height: 66px; border-radius: 50%; background: var(--panel); box-shadow: 0 5px 0 rgba(106,79,176,.35); overflow: hidden; display: grid; place-items: center; font-weight: 700; color: var(--ink); text-shadow: none; }
.ab-ring > div { position: absolute; inset: 0; background: rgba(106,79,176,.45); transform-origin: bottom; transform: scaleY(0); }
.ab-ring span { position: relative; font-size: 18px; }
#ability.ready .ab-ring { box-shadow: 0 0 0 3px var(--mint), 0 0 18px var(--mint); }
#countdown { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 150px; font-weight: 700; color: #fff; text-shadow: 0 6px 0 #8a64d6, 0 14px 30px rgba(40,20,80,.5); opacity: 0; pointer-events: none; z-index: 6; }
#countdown.on { animation: count .9s ease-out both; }
@keyframes count { 0% { opacity: 0; transform: translate(-50%,-50%) scale(1.8); } 25% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.85); } }
#blind { position: fixed; inset: 0; z-index: 4; display: none; place-items: center; text-align: center; color: #fff; background: radial-gradient(circle, rgba(40,25,70,.86), rgba(20,10,40,.97)); pointer-events: none; }
#blind.on { display: grid; }
#blind h2 { font-size: 40px; margin: 0 0 6px; } #blind p { opacity: .85; margin: 0; }
#reconnect { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); padding: 10px 24px; border-radius: 99px; background: #4b3a86; color: #fff; font-weight: 600; z-index: 12; }
.results-card table { width: 100%; border-collapse: collapse; margin: 8px 0 10px; text-align: left; }
.results-card th { font-size: 12px; opacity: .6; font-weight: 600; padding: 2px 8px; }
.results-card td { padding: 6px 8px; font-weight: 500; border-top: 1px solid rgba(59,47,79,.1); }
.results-card tr.me td { font-weight: 700; background: rgba(255,143,180,.18); }
.results-card td.pts { text-align: right; font-weight: 700; }
.results-card.results-card h2 { font-size: 34px; }
#results.won h2 { color: #d6366e; }
#rs-timer { opacity: .75; min-height: 20px; }
#hud:not(.playing) #match, #hud:not(.playing) #ability, #hud:not(.playing) #mana { }
#hud.lobbyview .hud-right, #hud.lobbyview .controls { display: none !important; }
#hud.lobbyview #match { display: none; }

/* Stage 6: settings */
#settings { z-index: 30; background: rgba(40,25,70,.35); }
.settings-card { width: min(480px, 94vw); max-height: 90vh; overflow: auto; text-align: left; }
.settings-card h2 { text-align: center; margin-top: 0; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.tabs button { font: inherit; font-weight: 600; padding: 6px 16px; border-radius: 99px; border: 2px solid rgba(106,79,176,.3); background: #fff; color: #6a4fb0; cursor: pointer; }
.tabs button.on { background: var(--violet); color: #fff; border-color: var(--violet); }
.settings-card section { display: grid; gap: 10px; margin-bottom: 12px; }
.settings-card section.hidden { display: none; }
.settings-card label { display: grid; gap: 4px; font-weight: 600; }
.settings-card label.check { display: flex; gap: 8px; align-items: center; }
.settings-card .val { float: right; opacity: .7; font-weight: 500; }
.settings-card select { font: inherit; padding: 6px 10px; border-radius: 12px; border: 2px solid rgba(106,79,176,.3); }
.settings-card > .btn { display: block; margin: 8px auto 0; }
#bind-list { display: grid; gap: 4px; }
.bind { display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.keycap { min-width: 92px; font: inherit; font-weight: 600; padding: 4px 12px; border-radius: 10px; border: 2px solid rgba(106,79,176,.3); background: #fff; box-shadow: 0 3px 0 rgba(106,79,176,.25); cursor: pointer; }
.keycap.listening { background: #ffe9a8; border-color: #e0a526; }
#lb-pal { display: flex; gap: 8px; justify-content: center; margin: 6px 0 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(60,40,90,.3); cursor: pointer; transition: transform .15s; }
.swatch:hover { transform: scale(1.12); }
.swatch.on { box-shadow: 0 0 0 3px var(--violet), 0 2px 6px rgba(60,40,90,.3); transform: scale(1.12); }

/* Stage 6: touch controls (only shown after the first touch) */
#touch { display: none; position: fixed; inset: 0; z-index: 6; pointer-events: none; touch-action: none; user-select: none; }
#touch.on { display: block; }
#t-look { position: absolute; top: 0; right: 0; width: 55%; height: 100%; pointer-events: auto; touch-action: none; }
#t-pad { position: absolute; left: 24px; bottom: 28px; width: 132px; height: 132px; border-radius: 50%; background: rgba(255,255,255,.28); border: 3px solid rgba(255,255,255,.55); pointer-events: auto; touch-action: none; display: grid; place-items: center; }
#t-knob { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.8); box-shadow: 0 3px 8px rgba(60,40,90,.35); }
.t-btns { position: absolute; right: 18px; bottom: 24px; width: 230px; display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: 10px; pointer-events: none; }
.t-btns button { pointer-events: auto; touch-action: none; width: 66px; height: 66px; border-radius: 50%; border: 3px solid rgba(255,255,255,.7); background: rgba(138,100,214,.7); color: #fff; font: 600 14px/1 'Fredoka', sans-serif; box-shadow: 0 4px 0 rgba(60,40,90,.3); }
.t-btns button.down, .t-btns button.on { background: rgba(255,143,180,.9); transform: translateY(2px); }
.t-btns button.hidden { display: none; }
body.touch-ui #reticle { opacity: .8; }
body.touch-ui #resume, body.touch-ui .hud-left .controls, body.touch-ui #cammode { display: none !important; }
body.touch-ui #ability { bottom: 190px; }
body.touch-ui #mana { bottom: 18px; }
.settings-card { background: rgba(255,250,255,.98); }

/* Room list (title screen) */
#rooms-box { margin: 8px auto 4px; text-align: left; width: min(520px, 92vw); padding: 10px 12px 12px; border-radius: 22px; background: var(--panel); backdrop-filter: blur(12px); box-shadow: 0 8px 26px rgba(60,40,90,.25); color: var(--ink); }
.rooms-head { display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; padding: 0 6px 4px; }
#rooms-status { font-weight: 500; opacity: .6; font-size: 12px; }
#rooms-list { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 4px; max-height: 214px; overflow-y: auto; }
#rooms-list li { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 14px; border-radius: 16px; background: rgba(255,255,255,.85); font-weight: 600; font-size: 14px; }
#rooms-list li .rn { flex: 1; }
#rooms-list li .rc { font-variant-numeric: tabular-nums; opacity: .75; font-weight: 500; }
#rooms-list li .rs { font-size: 12px; font-weight: 500; opacity: .6; min-width: 56px; text-align: right; }
#rooms-list li button { font: inherit; font-weight: 600; font-size: 13px; padding: 4px 14px; border-radius: 99px; border: 0; background: var(--violet); color: #fff; cursor: pointer; }
#rooms-list li button:disabled { background: #b9b1d4; cursor: not-allowed; }

/* Hunter mana bar (bottom centre): four segments = four fireballs */
#mana { left: 50%; transform: translateX(-50%); gap: 6px; }
#mana.hidden { display: none !important; }
#mana-bar { position: relative; width: min(300px, 60vw); height: 18px; border-radius: 99px; overflow: hidden; background: rgba(36,22,70,.62); box-shadow: 0 0 0 2px rgba(255,255,255,.55), 0 5px 0 rgba(106,79,176,.35); }
#mana-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(1); background: linear-gradient(90deg, #7a5cff, #5ec8ff); transition: filter .2s; }
#mana-bar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 2px), rgba(24,12,52,.85) calc(25% - 2px), rgba(24,12,52,.85) 25%); }
#mana.ready #mana-fill { filter: drop-shadow(0 0 6px #7ad7ff) brightness(1.1); }
#mana.empty #mana-fill { background: linear-gradient(90deg, #a35cff, #ff7aa8); }
#mana.empty #mana-bar { animation: manashake .5s ease-in-out infinite; }
@keyframes manashake { 50% { box-shadow: 0 0 0 2px rgba(255,140,170,.9), 0 5px 0 rgba(106,79,176,.35); } }
.mana-txt { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.mana-txt span { opacity: .85; font-variant-numeric: tabular-nums; }
