* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #87ceeb;
  color: #1a1a2e;
}
.hidden { display: none !important; }

/* ================= Scene ================= */
#scene { position: fixed; inset: 0; }
#sky {
  position: absolute; inset: 0;
  background: linear-gradient(#6db3e8 0%, #a8d8f0 55%, #cfeef7 100%);
}
#road {
  position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 60px, rgba(255,255,255,0.85) 60px 120px) center 38% / 100% 6px no-repeat,
    linear-gradient(#9aa2ab, #7e868f);
}

/* Billboard — the big screen the words appear on */
#billboard {
  position: absolute; left: 50%; top: 6%;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  min-height: 130px;
  background: #3d4247;
  border: 10px solid #23272b;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px 20px; text-align: center;
  z-index: 3;
}
#bb-line1 { color: #e8e8e8; font-size: clamp(1rem, 3vw, 1.5rem); font-weight: 600; }
#bb-line2 {
  color: #9be89b; font-weight: 800;
  font-size: clamp(1.4rem, 5.5vw, 2.6rem);
  letter-spacing: 2px; word-break: break-all;
  min-height: 1.2em;
  font-family: "Comic Sans MS", "Segoe UI", sans-serif;
}
#bb-line2.wrong { color: #ff7b7b; }
#bb-line2.right { color: #7bff8e; }

/* ================= Avatars (blocky Roblox-style, pure CSS) ================= */
#stage { position: absolute; inset: 0; z-index: 4; }
.avatar {
  position: absolute;
  width: 90px; height: 150px;
  transform: translate(-50%, 0) scale(var(--s, 1));
  transform-origin: 50% 100%;
  transition: left 1.1s ease-in-out, bottom 1.1s ease-in-out, transform 1.1s ease-in-out, opacity .4s;
}
.avatar .nametag {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  padding: 2px 8px; border-radius: 6px;
}
.avatar .head {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 44px; height: 40px; border-radius: 10px;
  background: var(--skin, #f2c744);
  box-shadow: inset -4px -5px 0 rgba(0,0,0,0.12);
}
.avatar .face {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 16px; display: flex; justify-content: center; gap: 12px;
}
.avatar .face i {
  width: 6px; height: 9px; background: #222; border-radius: 2px; display: block;
}
.avatar .torso {
  position: absolute; top: 42px; left: 50%; transform: translateX(-50%);
  width: 54px; height: 58px; border-radius: 6px;
  background: var(--shirt, #d9413c);
  box-shadow: inset -5px -6px 0 rgba(0,0,0,0.15);
}
.avatar .arm {
  position: absolute; top: 44px; width: 16px; height: 52px; border-radius: 6px;
  background: var(--skin, #f2c744);
  box-shadow: inset -3px -4px 0 rgba(0,0,0,0.12);
}
.avatar .arm.l { left: 2px; }
.avatar .arm.r { right: 2px; }
.avatar .leg {
  position: absolute; top: 100px; width: 20px; height: 48px; border-radius: 6px;
  background: var(--pants, #3f5aa8);
  box-shadow: inset -4px -5px 0 rgba(0,0,0,0.15);
}
.avatar .leg.l { left: 24px; }
.avatar .leg.r { right: 24px; }

.avatar .shoe {
  position: absolute; top: 144px; width: 20px; height: 8px; border-radius: 3px;
  background: var(--shoes, transparent);
}
.avatar .shoe.l { left: 24px; }
.avatar .shoe.r { right: 24px; }
.avatar .scarf {
  position: absolute; top: 38px; left: 50%; transform: translateX(-50%);
  width: 48px; height: 10px; border-radius: 4px; z-index: 2;
}

/* Explosion debris: body parts + fire sparks flung across the screen */
.bee-piece {
  position: fixed; z-index: 60; border-radius: 4px; pointer-events: none;
  box-shadow: inset -3px -4px 0 rgba(0,0,0,0.15);
}
.bee-fire {
  position: fixed; z-index: 61; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff6a8 0%, #ffb52e 40%, #ff5722 75%, transparent 100%);
  filter: blur(0.5px);
}

.avatar.speaking .arm.r { transform: rotate(-160deg); transform-origin: 50% 8px; }
.avatar.eliminated { opacity: 0.35; filter: grayscale(1); }
.avatar .bubble {
  position: absolute; top: -58px; left: 60%;
  background: #fff; border-radius: 10px; padding: 4px 10px;
  font-size: 14px; font-weight: 700; color: #333;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  opacity: 0; transition: opacity .3s;
}
.avatar .bubble::after {
  content: ""; position: absolute; bottom: -6px; left: 12px;
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.avatar.speaking .bubble { opacity: 1; }

/* ================= HUD ================= */
#hud {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; justify-content: space-between; gap: 8px;
  z-index: 10; pointer-events: none;
}
#hud-left, #hud-right { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: rgba(0,0,0,0.55); color: #fff;
  padding: 6px 12px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700;
}
.pill-btn { pointer-events: auto; border: none; cursor: pointer; }
.pill-btn:hover { background: rgba(0,0,0,0.75); }

#timerbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 116px; width: min(480px, 86vw); height: 10px;
  background: rgba(0,0,0,0.3); border-radius: 999px;
  overflow: hidden; z-index: 10;
}
#timerfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #4caf50, #ffc107 65%, #f44336);
  transition: width .2s linear;
}

#answer-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 40px; z-index: 10;
  display: flex; gap: 8px;
  width: min(520px, 92vw);
}
#answer {
  flex: 1; padding: 14px 16px;
  border-radius: 12px; border: 3px solid #23272b;
  font-size: 1.15rem; font-weight: 700; text-align: center;
  outline: none; background: #fff;
}
#btn-hear, #btn-submit {
  border: 3px solid #23272b; border-radius: 12px;
  font-size: 1.05rem; font-weight: 800; cursor: pointer;
  padding: 0 18px; background: #ffd54f;
}
#btn-submit { background: #7bd47b; }
#btn-hear:active, #btn-submit:active { transform: scale(0.95); }

#toast {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75); color: #fff;
  padding: 14px 26px; border-radius: 14px;
  font-size: 1.3rem; font-weight: 800; text-align: center;
  z-index: 20; max-width: 90vw;
}

/* ================= Menu ================= */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 20px;
  background: linear-gradient(160deg, #87ceeb 0%, #cfeef7 100%);
  overflow: hidden;
}
#menu-main {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; max-width: 520px;
}
.overlay h1 { font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 800; }
.overlay h2 { font-size: clamp(1.5rem, 4vw, 2.4rem); font-weight: 800; }
.tagline { color: #40606f; margin-top: -6px; }
#name-input {
  width: min(300px, 80vw); padding: 12px 16px;
  border-radius: 10px; border: 3px solid #23272b;
  font-size: 1.05rem; text-align: center; outline: none;
}
.mode-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 170px; padding: 16px 20px;
  border-radius: 14px; border: 3px solid #23272b;
  background: #fff; cursor: pointer;
  transition: transform .15s ease;
}
.mode-btn:hover { transform: translateY(-3px); }
.mode-icon { font-size: 2rem; }
.mode-name { font-size: 1.15rem; font-weight: 800; }
.mode-desc { font-size: 0.72rem; color: #667; }

#server-row {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700;
}
#server-select {
  padding: 8px 12px; border-radius: 10px; border: 3px solid #23272b;
  font-size: 0.95rem; font-weight: 700; background: #fff; cursor: pointer;
}
#btn-shuffle-server {
  border: 3px solid #23272b; border-radius: 10px; background: #ffd54f;
  font-size: 1rem; padding: 6px 10px; cursor: pointer;
}
.controls-hint { color: #40606f; font-size: 0.85rem; }
#tts-warning { color: #b3541e; font-weight: 700; }
.back-link { color: #0277bd; text-decoration: none; font-weight: 700; font-size: 0.9rem; }

/* ================= Difficulty tower ================= */
#tower-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-height: 92vh;
}
#tower-title { font-weight: 800; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; }
#tower {
  display: flex; flex-direction: column-reverse; /* Easy at the bottom, like the chart */
  overflow-y: auto; max-height: 84vh;
  border: 3px solid #23272b; border-radius: 10px;
  scrollbar-width: thin;
}
.tier {
  display: flex; align-items: center; justify-content: flex-end;
  min-height: 30px; width: 168px;
  padding: 0 10px;
  border: none; border-top: 2px solid rgba(0,0,0,0.55);
  color: #fff; font-weight: 800; font-size: 0.8rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
  cursor: pointer; flex-shrink: 0;
}
.tier.light { color: #222; text-shadow: none; }
.tier:hover { filter: brightness(1.15); }
.tier.selected { outline: 3px solid #fff; outline-offset: -5px; }
.tier.selected::before { content: "▶ "; }

#gameover { flex-direction: column; }
#go-detail { font-size: 1.05rem; max-width: 460px; text-align: center; line-height: 1.5; }

@media (max-width: 700px) {
  .overlay { flex-direction: column; overflow-y: auto; justify-content: flex-start; padding-top: 30px; }
  #tower { max-height: 40vh; }
  .avatar { --mob: 0.8; }
  #billboard { min-height: 100px; }
}
