:root {
  --sky: #78b7ff;
  --panel: #1e1e28ee;
  --accent: #00a2ff;
  --good: #3ddc84;
  --bad: #ff5a5a;
  --font: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #000;
  color: #fff;
}

#c {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Gate */
.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 20%, #3a6aaa 0%, transparent 55%),
    linear-gradient(180deg, #6eb6ff 0%, #80c060 55%, #5a9a40 100%);
  padding: 16px;
}
.gate-card {
  width: min(400px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 60px #0006;
  border: 1px solid #ffffff18;
}
.logo {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  color: #fff;
  text-shadow: 0 3px 0 #0a5a9a;
}
.sub {
  text-align: center;
  color: #aab;
  font-size: 12px;
  margin: 6px 0 16px;
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab {
  flex: 1;
  border: none;
  background: #2a2a36;
  color: #ccc;
  font: inherit;
  font-weight: 700;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.tab.on {
  background: var(--accent);
  color: #fff;
}
.auth label {
  display: block;
  font-size: 12px;
  color: #9ab;
  margin-bottom: 10px;
}
.auth input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #3a3a4a;
  background: #12121a;
  color: #fff;
  font: inherit;
  font-size: 15px;
}
.go {
  width: 100%;
  margin-top: 6px;
  border: none;
  background: var(--good);
  color: #042;
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
}
.go:hover {
  filter: brightness(1.05);
}
.err {
  color: var(--bad);
  font-size: 13px;
  min-height: 1.2em;
  margin-top: 8px;
  text-align: center;
}
.help {
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.45;
  color: #9aa;
  background: #12121a;
  padding: 12px;
  border-radius: 10px;
}
.help code {
  background: #2a2a36;
  padding: 1px 5px;
  border-radius: 4px;
  color: #8cf;
}
.fine {
  margin-top: 10px;
  font-size: 11px;
  color: #667;
  text-align: center;
}

/* HUD */
.hud {
  position: fixed;
  inset: 0;
  z-index: 30; /* above canvas; chat must beat pointer-lock UX */
  pointer-events: none;
}
.hud.chat-open {
  pointer-events: none; /* only chat form is interactive */
}
.hud.chat-open .chat-form {
  pointer-events: auto;
  z-index: 40;
}
.hud.chat-open .chat-form input {
  outline: 2px solid #00a2ff;
  background: #000e;
  font-size: 16px; /* helps mobile/safari focus */
}
.hud.hidden,
.gate.hidden,
.blocker.hidden {
  display: none !important;
}
.topbar {
  pointer-events: none;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, #0009, transparent);
  font-size: 13px;
  font-weight: 700;
}
.brand {
  color: #8cf;
  letter-spacing: 0.06em;
}
#room-tag {
  background: #00a2ff55;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
}
#online {
  margin-left: auto;
  color: #9f9;
}
.btn-report {
  pointer-events: auto;
  border: 1px solid #f66;
  background: #4008;
  color: #faa;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-report:hover {
  background: #600a;
  color: #fff;
}
.report-panel {
  pointer-events: auto;
  position: absolute;
  top: 48px;
  right: 12px;
  width: min(280px, 80vw);
  background: #1a1020ee;
  border: 2px solid #f66;
  border-radius: 12px;
  padding: 12px;
  z-index: 35;
  box-shadow: 0 12px 40px #000a;
}
.report-panel.hidden {
  display: none !important;
}
.report-title {
  font-weight: 900;
  color: #faa;
  margin-bottom: 6px;
}
.report-help {
  font-size: 11px;
  color: #aab;
  line-height: 1.35;
  margin-bottom: 10px;
}
.report-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.report-list button {
  border: 1px solid #555;
  background: #222;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.report-list button:hover {
  border-color: #f66;
  background: #311;
}
.report-list .empty {
  font-size: 12px;
  color: #888;
}
.report-cancel {
  width: 100%;
  border: none;
  background: #333;
  color: #ccc;
  font: inherit;
  font-weight: 700;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.chat {
  pointer-events: none;
  position: absolute;
  left: 12px;
  bottom: 56px;
  width: min(360px, 70vw);
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  font-size: 13px;
  text-shadow: 0 1px 2px #000;
}
.chat .line {
  background: #0007;
  padding: 4px 8px;
  border-radius: 6px;
  width: fit-content;
  max-width: 100%;
  word-break: break-word;
}
.chat .line b {
  color: #8cf;
}
.chat .line.filtered {
  border-left: 3px solid #ffe566;
  padding-left: 6px;
}
.chat .filt {
  font-size: 11px;
  opacity: 0.9;
}

.chat-form {
  pointer-events: auto;
  position: absolute;
  left: 12px;
  bottom: 14px;
  width: min(360px, 70vw);
}
.chat-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ffffff22;
  background: #000a;
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
}
.chat-form input:focus {
  border-color: #00a2ff;
  box-shadow: 0 0 0 2px #00a2ff66;
  background: #000c;
}

.hint {
  position: absolute;
  right: 12px;
  bottom: 14px;
  font-size: 11px;
  color: #ccc;
  background: #0006;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
}

  to {
    transform: scale(1);
    opacity: 1;
  }
}
.cw-label {
  font-size: 12px;
  color: #ff9fce;
  letter-spacing: 0.12em;
  font-weight: 800;
  margin-bottom: 10px;
}
.cw-title {
  font-size: 26px;
  font-weight: 900;
  color: #ffe566;
  margin-bottom: 14px;
  line-height: 1.25;
}
.cw-scores {
  font-size: 14px;
  color: #eee;
  line-height: 1.5;
  margin-bottom: 12px;
}
.cw-scores .me {
  color: #8cf;
  font-weight: 800;
}
.cw-next {
  font-size: 12px;
  color: #aab;
}

.blocker {
  position: fixed;
  inset: 0;
  z-index: 50; /* above mobile pad (#kid-arcade-controls:15) so Tap to play works */
  display: grid;
  place-items: center;
  background: #0006;
  cursor: pointer;
  font-size: 22px;
  font-weight: 800;
}

/* Serious warning */
.swear-warn {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(40, 0, 0, 0.88);
  padding: 20px;
}
.swear-warn.hidden {
  display: none !important;
}
.swear-warn-inner {
  max-width: 520px;
  background: #1a0000;
  border: 4px solid #ff2020;
  box-shadow: 0 0 40px #ff000088, inset 0 0 30px #000;
  padding: 28px 24px;
  text-align: center;
  animation: warn-pulse 0.8s ease infinite alternate;
}
@keyframes warn-pulse {
  from {
    border-color: #ff2020;
  }
  to {
    border-color: #ffcc00;
  }
}
.swear-warn-title {
  font-size: 28px;
  font-weight: 900;
  color: #ff3030;
  letter-spacing: 0.12em;
  margin-bottom: 16px;
  text-shadow: 0 0 12px #f00;
}
.swear-warn-body {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
  color: #ffeaea;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.swear-warn-sub {
  font-size: 13px;
  color: #ffcc00;
  font-weight: 700;
  margin-bottom: 18px;
}
.swear-warn-ok {
  border: none;
  background: #ff2020;
  color: #fff;
  font: inherit;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.08em;
  padding: 12px 28px;
  cursor: pointer;
  border-radius: 4px;
}
.swear-warn-ok:hover {
  background: #ff4040;
}

/* Jumpscare */
.jumpscare {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.jumpscare.hidden {
  display: none !important;
}
.jumpscare img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: contrast(1.35) saturate(1.4) brightness(1.05);
  animation: js-shake 0.08s linear infinite, js-zoom 0.4s ease-out forwards;
}
@keyframes js-shake {
  0% {
    transform: translate(0, 0) scale(1.15);
  }
  25% {
    transform: translate(-12px, 6px) scale(1.18);
  }
  50% {
    transform: translate(10px, -8px) scale(1.2);
  }
  75% {
    transform: translate(-8px, -4px) scale(1.17);
  }
  100% {
    transform: translate(6px, 8px) scale(1.19);
  }
}
@keyframes js-zoom {
  from {
    filter: contrast(2) brightness(2);
  }
  to {
    filter: contrast(1.35) saturate(1.4);
  }
}
.jumpscare-glitch {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 0, 0.06) 2px,
    rgba(0, 255, 0, 0.06) 4px
  );
  mix-blend-mode: overlay;
}
.jumpscare-ban {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(18px, 4vw, 32px);
  font-weight: 900;
  color: #ff2020;
  text-shadow: 0 0 20px #000, 0 0 8px #f00;
  letter-spacing: 0.08em;
  background: #000c;
  padding: 16px 24px;
  border: 3px solid #ff2020;
  z-index: 2;
}
.jumpscare-ban span {
  display: block;
  margin-top: 8px;
  font-size: 0.55em;
  color: #ffcc00;
}


/* Emote wheel */
.emote-menu {
  pointer-events: auto;
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  z-index: 45;
  width: min(420px, calc(100vw - 24px));
  background: linear-gradient(180deg, #1a1a28f2, #12121cf2);
  border: 2px solid #00a2ff88;
  border-radius: 18px;
  padding: 14px 14px 12px;
  box-shadow: 0 16px 50px #000a, 0 0 0 1px #ffffff10 inset;
  backdrop-filter: blur(8px);
}
.emote-menu.hidden {
  display: none !important;
}
.emote-title {
  font-weight: 900;
  letter-spacing: 0.12em;
  font-size: 13px;
  color: #8cf;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.emote-title span {
  font-weight: 600;
  letter-spacing: 0;
  font-size: 11px;
  color: #889;
}
.emote-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 480px) {
  .emote-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .emote-menu {
    bottom: 100px;
  }
}
.emote-btn {
  appearance: none;
  border: 2px solid #ffffff18;
  background: #2a2a3acc;
  color: #fff;
  border-radius: 14px;
  padding: 10px 6px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font: inherit;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
  position: relative;
}
.emote-btn:hover,
.emote-btn:focus-visible {
  background: #00a2ff44;
  border-color: #00a2ff;
  transform: translateY(-2px) scale(1.04);
  outline: none;
}
.emote-btn:active {
  transform: scale(0.96);
}
.emote-btn .e-ico {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 0 #0006);
}
.emote-btn .e-name {
  font-size: 11px;
  font-weight: 800;
  color: #dde;
}
.emote-btn kbd {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #8ab;
  background: #0006;
  border-radius: 4px;
  padding: 1px 4px;
  border: 1px solid #fff2;
}
.hud.emote-open {
  pointer-events: none;
}
.hud.emote-open .emote-menu {
  pointer-events: auto;
}

.blocker-sub {
  margin-top: 8px;
  font-size: 13px;
  color: #bcd;
  font-weight: 600;
}
