:root {
  --night: #1a1030;
  --night-dark: #100a20;
  --panel: #2b1d4a;
  --frame: #ff8c1a;
  --ink: #f6f0ff;
  --muted: #b8a8dc;
  --accent: #ff8c1a;
  --accent-ink: #2a1200;
  --purple: #a06cd5;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink); font-family: var(--font); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer;
  background: #43307a; border: 2px solid #6a52b0; border-bottom-width: 4px; border-radius: 12px;
  padding: 8px 14px; font-size: 1rem; line-height: 1.1;
  transition: transform 0.06s ease, background 0.15s;
}
.btn:hover { background: #523b92; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #c46200; }
.btn.primary:hover { background: #ffa64d; }
.btn.huge { font-size: 1.5rem; padding: 14px 28px; width: 100%; margin-top: 16px; }
.btn.round { width: 46px; height: 46px; padding: 0; font-size: 1.3rem; border-radius: 50%; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- panels & lobby ---------- */
.panel {
  background: var(--panel); border: 6px solid var(--frame); border-radius: 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 140, 26, 0.25); padding: 22px;
}
.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center;
  padding: 16px; z-index: 20; overflow-y: auto;
  background:
    radial-gradient(circle at 80% 12%, rgba(255, 240, 200, 0.9) 0 34px, rgba(255, 240, 200, 0.15) 36px, transparent 90px),
    radial-gradient(ellipse at top, #3d2a6e 0%, var(--night-dark) 75%);
}
h1 { margin: 0 0 8px; font-size: 2.4rem; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.4), 0 0 18px rgba(255, 140, 26, 0.6); }
.lobby-panel { width: min(520px, 100%); }
.lobby-panel label { display: block; font-weight: 700; margin: 14px 0 6px; }
.lobby-panel small { color: var(--muted); font-weight: 400; }
.tagline { color: var(--muted); margin: 0; }
input {
  font: inherit; font-size: 1.2rem; width: 100%; margin-top: 6px; padding: 10px 12px; color: var(--ink);
  background: var(--night-dark); border: 2px solid #6a52b0; border-radius: 12px; outline: none;
  -webkit-user-select: text; user-select: text;
}
input:focus { border-color: var(--accent); }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%; border: 4px solid transparent; background: var(--c); cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.swatch.on { border-color: #fff; transform: scale(1.1); }
.how { margin-top: 14px; font-size: 0.92rem; color: var(--muted); }
.how p { margin: 6px 0; }
#lobby-msg { min-height: 1.2em; margin: 10px 0 0; text-align: center; }

/* ---------- in game ---------- */
.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px; pointer-events: none;
}
.top > * { pointer-events: auto; }
.pill { background: rgba(16, 10, 32, 0.7); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.keys { background: rgba(16, 10, 32, 0.7); border-radius: 999px; padding: 5px 12px; font-size: 1.5rem; letter-spacing: 4px; }
.keys span { filter: grayscale(1) brightness(0.45); transition: filter 0.4s, transform 0.4s; display: inline-block; }
.keys span.got { filter: drop-shadow(0 0 6px #ffcc33); transform: scale(1.15); }
.players { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.chip { background: rgba(16, 10, 32, 0.7); border: 2px solid var(--c); border-radius: 999px; padding: 4px 10px; font-weight: 700; color: var(--c); font-size: 0.9rem; }
.chip.me { background: var(--c); color: #1a1030; }
.chip.away { opacity: 0.4; }

.banner {
  position: fixed; top: 70px; left: 50%; z-index: 6; transform: translate(-50%, -20px) scale(0.9); opacity: 0;
  max-width: min(92vw, 640px); text-align: center; font-size: clamp(1.1rem, 3.4vw, 1.6rem); font-weight: 800;
  background: rgba(43, 29, 74, 0.92); border: 4px solid var(--purple); border-radius: 18px; padding: 12px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); pointer-events: none; transition: opacity 0.25s, transform 0.25s;
}
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.banner.gold { border-color: #ffcc33; box-shadow: 0 0 30px rgba(255, 204, 51, 0.5); }
.banner.green { border-color: #7ed957; }
.banner.orange { border-color: #ff6a1a; }
.banner.purple { border-color: #d58cff; box-shadow: 0 0 30px rgba(213, 140, 255, 0.45); }

.hint {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 12px; max-width: min(56vw, 520px);
  background: #fff4e0; color: #3a1f00; border-radius: 22px; padding: 12px 16px; font-weight: 700; font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 4px var(--accent); pointer-events: none;
  animation: hint-in 0.35s ease-out;
}
.hint-face { font-size: 2.4rem; animation: wobble 0.6s ease-in-out infinite alternate; }
@keyframes hint-in { from { transform: translate(-50%, 40px); opacity: 0; } }
@keyframes wobble { from { transform: rotate(-10deg); } to { transform: rotate(10deg) scale(1.08); } }

/* the floating joystick */
.stick {
  position: fixed; left: 0; top: 0; z-index: 4; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity 0.15s;
}
.stick.on { opacity: 1; }
.stick::before {
  content: ''; position: absolute; left: -70px; top: -70px; width: 140px; height: 140px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); border: 3px solid rgba(255, 255, 255, 0.35);
}
.knob {
  position: absolute; left: -32px; top: -32px; width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255, 140, 26, 0.75); border: 3px solid #fff; box-shadow: 0 0 16px rgba(255, 140, 26, 0.7);
}

.buttons {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; gap: 16px; align-items: flex-end;
}
.act {
  border: 4px solid #fff; border-radius: 50%; cursor: pointer; font-size: 2.4rem; line-height: 1;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 255, 255, 0.2); touch-action: none;
}
.act.jump { width: 84px; height: 84px; background: #3ec1d3; }
.act.bonk { width: 110px; height: 110px; background: #a06cd5; font-size: 3rem; }
.act.down { transform: translateY(4px) scale(0.94); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }

/* surprises seen through the screen */
.map {
  position: fixed; left: 12px; top: 64px; z-index: 6; pointer-events: none;
  background: rgba(16, 10, 32, 0.88); border: 3px solid #6dff5a; border-radius: 18px; padding: 10px;
  box-shadow: 0 0 40px rgba(109, 255, 90, 0.45); animation: map-in 0.35s ease-out; text-align: center; transform-origin: top left;
}
@keyframes map-in { from { transform: scale(0.3); opacity: 0; } }
.map-title { color: #c9ffbf; font-weight: bold; font-size: 0.85rem; margin-bottom: 6px; }
.map canvas { display: block; width: min(42vw, 42vh, 300px); height: auto; aspect-ratio: 1; border-radius: 8px; }
body.dark #view { filter: brightness(0.9) contrast(1.1); }
body.slimed #view { filter: hue-rotate(40deg) saturate(1.4); }

.overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(16, 10, 32, 0.45); }
.overlay-panel { width: min(440px, 100%); text-align: center; animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
.overlay-panel h2 { font-size: 2rem; margin: 8px 0; }
.end-big { font-size: 3.4rem; animation: wobble 0.5s ease-in-out infinite alternate; }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }

@media (max-height: 520px) {
  .act.jump { width: 70px; height: 70px; font-size: 2rem; }
  .act.bonk { width: 90px; height: 90px; font-size: 2.5rem; }
  .banner { top: 60px; }
}
