:root {
  --ink: #24324a;
  --panel: rgba(255, 255, 255, 0.86);
  --accent: #ff7a59;
  --accent-dark: #e35d3c;
  --mint: #3fb8a6;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe6f2; }
body { font-family: "Fredoka", system-ui, sans-serif; color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; }
.pill { background: var(--panel); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 0 rgba(36, 50, 74, 0.12); }
.pill svg { width: 20px; height: 24px; }
.pill.pop { animation: pop 0.3s ease-out; }
.pill.low { color: #e0453a; }
@keyframes pop { 40% { transform: scale(1.18); } }
#hud .right { display: flex; gap: 8px; pointer-events: auto; }
#mute { border: 0; cursor: pointer; font: inherit; color: inherit; }
#mute svg { width: 22px; height: 22px; }
.you { color: #e35d3c; }
.them { color: #3f6fe0; }

/* ---------- screens ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(191, 230, 242, 0.35); backdrop-filter: blur(3px); }
.overlay.hidden { display: none; }
.card { background: var(--panel); border-radius: 28px; padding: 32px 28px; max-width: 420px; width: 100%; text-align: center; box-shadow: 0 10px 0 rgba(36, 50, 74, 0.12); }
.card h1 { margin: 0 0 4px; font-size: 44px; line-height: 1.05; color: var(--accent); }
.card h2 { margin: 0 0 8px; font-size: 32px; color: var(--accent); }
.card p { margin: 8px 0; font-size: 17px; line-height: 1.4; }
.card .keys { opacity: 0.75; font-size: 15px; }
.big { font-size: 40px; font-weight: 700; margin: 8px 0; }

button.play { margin-top: 16px; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 24px; color: #fff; background: var(--accent); padding: 12px 40px; border-radius: 999px; box-shadow: 0 6px 0 var(--accent-dark); transition: transform 0.08s; }
button.play:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark); }
button.play.alt { background: var(--mint); box-shadow: 0 6px 0 #2c8a7d; font-size: 18px; padding: 10px 24px; }
button.play.alt:active { box-shadow: 0 2px 0 #2c8a7d; }
button.link { margin-top: 12px; border: 0; background: none; font: inherit; font-size: 16px; color: var(--ink); opacity: 0.7; text-decoration: underline; cursor: pointer; }

.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 12px; }
.modes .play { font-size: 20px; padding: 12px 24px; }

/* ---------- friend match lobby ---------- */
.versus { margin-top: 24px; padding-top: 12px; border-top: 2px dashed rgba(36, 50, 74, 0.15); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.versus .play { margin-top: 0; }
.join { display: flex; gap: 8px; }
.join input { font: inherit; font-size: 20px; font-weight: 700; width: 110px; text-align: center; letter-spacing: 4px; border-radius: 999px; border: 2px solid rgba(36, 50, 74, 0.2); padding: 8px 12px; color: var(--ink); background: #fff; user-select: text; -webkit-user-select: text; }
.code { font-size: 56px; font-weight: 700; letter-spacing: 8px; color: var(--accent); line-height: 1.1; }
#qr:not(:empty) { width: 200px; height: 200px; margin: 8px auto; padding: 8px; background: #fff; border-radius: 16px; }
#qr svg { width: 100%; height: 100%; display: block; }
.card p.url { font-size: 13px; word-break: break-all; margin: 0; }

.join input, input.name { user-select: text; -webkit-user-select: text; }
input.name { font: inherit; font-size: 18px; font-weight: 700; width: 200px; text-align: center; border-radius: 999px; border: 2px solid rgba(36, 50, 74, 0.2); padding: 8px 12px; color: var(--ink); background: #fff; }

/* ---------- scores ---------- */
.card.scores { max-height: calc(100vh - 32px); overflow-y: auto; text-align: left; }
.card.scores h2 { text-align: center; }
.card.scores h3 { margin: 16px 0 6px; font-size: 18px; }
.card.scores ol, .card.scores ul { margin: 0; padding-left: 24px; }
.card.scores li { display: flex; gap: 6px; padding: 3px 0; font-size: 16px; }
.card.scores li span { margin-left: auto; opacity: 0.6; }
.card.scores li.none { opacity: 0.6; list-style: none; margin-left: -24px; }
.card.scores ul { list-style: none; padding-left: 0; }
.card.scores .play, .card.scores .keys, .card.scores div { text-align: center; }
.card.scores .play { display: block; margin: 16px auto 0; }

/* ---------- traps ---------- */
#trapDock { position: fixed; left: 16px; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#trapBar { display: flex; gap: 8px; }
#trapBar.hidden, #trapBar.hidden + #trapsLive { display: none; }
#trapsLive { font-size: 13px; font-weight: 700; opacity: 0.7; }
button.trap { pointer-events: auto; border: 0; border-radius: 18px; background: var(--panel); box-shadow: 0 4px 0 rgba(36, 50, 74, 0.15), inset 0 -4px 0 var(--c); font: inherit; color: var(--ink); padding: 8px 12px 10px; min-width: 96px; display: flex; flex-direction: column; align-items: center; cursor: pointer; touch-action: none; }
button.trap .ico { font-size: 24px; line-height: 1.1; }
button.trap .name { font-size: 13px; font-weight: 700; }
button.trap .cost { font-size: 12px; opacity: 0.7; }
button.trap:disabled { opacity: 0.4; cursor: default; }

/* paint splash from a splash trap */
#splash { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#splash .blob { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.2); border-radius: 42% 58% 55% 45% / 50% 40% 60% 50%; opacity: 0; animation-name: splat; animation-timing-function: ease-in; animation-fill-mode: forwards; }
#splash .blob.ink { border-radius: 0; background: center / contain no-repeat; }
@keyframes splat {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(0.2); }
  6% { opacity: 0.97; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1); }
  60% { opacity: 0.92; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.08); }
}

/* ---------- taunts ---------- */
.taunts { margin-top: 12px; }
.taunts.hidden { display: none; }
#tauntButtons { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#tauntButtons button { border: 0; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 rgba(36, 50, 74, 0.15); font: inherit; font-size: 30px; line-height: 1; padding: 8px 10px; cursor: pointer; transition: transform 0.08s; }
#tauntButtons button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(36, 50, 74, 0.15); }
#tauntButtons button:disabled { opacity: 0.4; cursor: default; }

/* the reaction raining over the loser's screen (sits above every other screen) */
#tauntLayer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
#tauntLayer .rise { position: absolute; bottom: -12vh; font-size: var(--s); animation: rise var(--d) cubic-bezier(0.2, 0.7, 0.4, 1) var(--delay) forwards; opacity: 0; }
@keyframes rise {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg) scale(0.6); }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), -115vh) rotate(var(--r)) scale(1.1); }
}
#tauntLayer .shout { position: absolute; left: 50%; top: 42%; text-align: center; transform: translate(-50%, -50%); animation: shout 2.6s ease-out forwards; }
#tauntLayer .shout .big { font-size: 110px; line-height: 1; margin: 0; }
#tauntLayer .shout .words { font-size: 52px; font-weight: 700; color: #fff; -webkit-text-stroke: 2px var(--accent-dark); text-shadow: 0 5px 0 rgba(36, 50, 74, 0.35); width: max-content; max-width: 90vw; line-height: 1.1; }
@keyframes shout {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); }
  14% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(4deg); }
  24% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}
/* the sender's confirmation: one emoji floating up */
#tauntLayer .sent { position: absolute; left: 50%; bottom: 30%; font-size: 64px; animation: sent 1.2s ease-out forwards; }
@keyframes sent { 0% { opacity: 0; transform: translate(-50%, 0) scale(0.5); } 20% { opacity: 1; transform: translate(-50%, -20px) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -160px) scale(1); } }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); font-size: 32px; font-weight: 700; color: #fff; text-shadow: 0 3px 0 rgba(36, 50, 74, 0.35); pointer-events: none; opacity: 0; }
#toast.show { animation: toast 1.1s ease-out; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -30%); } 15% { opacity: 1; transform: translate(-50%, -50%); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%); } }
