:root {
  --bg: #120c24;
  --bg2: #1d1340;
  --pink: #ff3ea5;
  --cyan: #2de2e6;
  --yellow: #ffd23f;
  --green: #3dfc7a;
  --red: #ff4b4b;
  --text: #f4f1ff;
  --muted: #a99fd1;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 4px),
    radial-gradient(circle at 50% 0%, #2c1a66 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0.3em 0; font-weight: 900; letter-spacing: 0.02em; }
h1 { text-shadow: 0 0 12px var(--pink), 3px 3px 0 #000; }
h2 { text-shadow: 0 0 10px var(--cyan); }
p { margin: 0.5em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

button, a.button {
  font: inherit;
  font-weight: 800;
  color: var(--text);
  background: var(--bg2);
  border: 3px solid var(--cyan);
  border-radius: 12px;
  padding: 0.6em 1.1em;
  cursor: pointer;
  box-shadow: 0 4px 0 #000;
  transition: transform 0.05s;
}
a.button { display: inline-block; text-decoration: none; }
button:active, a.button:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
button.primary {
  background: var(--pink);
  border-color: var(--yellow);
  font-size: 1.2rem;
  text-transform: uppercase;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 3px solid var(--pink);
  font-weight: 800;
}
.logo { color: var(--yellow); text-shadow: 0 0 8px var(--yellow); text-transform: uppercase; }

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 70vh;
  padding: 1rem;
}

.big-emoji { font-size: 5rem; animation: bob 1s ease-in-out infinite; }
.mega { font-size: clamp(2.5rem, 7vw, 6rem); }
.boom { color: var(--yellow); animation: shake 0.15s infinite; }

@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes shake {
  25% { transform: translate(-4px, 2px) rotate(-3deg); }
  75% { transform: translate(4px, -2px) rotate(3deg); }
}
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }

/* ---- Home ---- */

.home-actions { display: flex; flex-direction: column; align-items: stretch; gap: 0.6rem; width: min(100%, 420px); }
.code-form { display: flex; gap: 0.5rem; }
.code-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 0.5em;
  border-radius: 10px;
  border: 3px solid var(--pink);
  background: #0b0718;
  color: var(--text);
  user-select: text;
}
.error { color: var(--red); font-weight: 700; min-height: 1.2em; margin: 0; }

.stats { display: flex; gap: 1rem; justify-content: center; margin: 1.5rem 0 0.5rem; flex-wrap: wrap; }
.stat {
  min-width: 170px;
  padding: 0.7rem 1.2rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid var(--pink);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat b { font-size: 2.4rem; color: var(--yellow); text-shadow: 0 0 10px var(--yellow); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; }

.credit { text-align: center; padding: 1rem; color: var(--muted); font-size: 0.85rem; }
.credit a { color: var(--cyan); font-weight: 700; text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* ---- Lobby rules ---- */

.rules-title { margin-top: 2rem; }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.8rem; width: min(100%, 900px); margin: 1rem auto; }
.rule-card { background: rgba(0, 0, 0, 0.35); border: 2px solid var(--cyan); border-radius: 14px; padding: 0.8rem 1rem; text-align: left; }
.rule-card h3 { margin: 0 0 0.3rem; color: var(--yellow); }
.rule-card p { margin: 0; font-size: 0.95rem; }

/* ---- Player: join ---- */

.card {
  background: rgba(0, 0, 0, 0.35);
  border: 3px solid var(--cyan);
  border-radius: 18px;
  padding: 1.5rem;
  margin: 2rem auto;
  max-width: 420px;
  box-shadow: 0 0 25px rgba(45, 226, 230, 0.25);
}
.join { display: flex; flex-direction: column; gap: 1rem; text-align: center; }
.edit-me { padding: 0.1em 0.4em; margin-left: 0.4rem; font-size: 0.9rem; border-width: 2px; box-shadow: none; }
.join input {
  font: inherit;
  font-size: 1.3rem;
  padding: 0.6em;
  border-radius: 10px;
  border: 3px solid var(--pink);
  background: #0b0718;
  color: var(--text);
  text-align: center;
  user-select: text;
}
.emojis { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.3rem; }
.emojis button { font-size: 1.4rem; padding: 0.15em 0; min-width: 0; border-width: 2px; border-color: transparent; box-shadow: none; }
.emojis button.picked { border-color: var(--yellow); background: #3a2580; }

.chips, .targets { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1rem; }
.chip { background: var(--bg2); border: 2px solid var(--cyan); border-radius: 999px; padding: 0.3em 0.8em; }
.chip.off, .off { opacity: 0.4; }
.targets button { border-color: var(--red); }
.targets button.thrown { animation: shake 0.15s 2; }

/* ---- Player: games ---- */

.qd {
  position: fixed;
  inset: 3.2rem 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 14vw, 8rem);
  font-weight: 900;
  cursor: pointer;
  text-shadow: 4px 4px 0 #000;
}
.qd small { font-size: 1rem; font-weight: 600; opacity: 0.8; text-shadow: none; }
.qd.ready { background: #5a0f2a; }
.qd.go { background: var(--green); color: #052; animation: pop 0.15s; }

.arena { position: fixed; inset: 3.2rem 0 0 0; }
.arena.hot { background: radial-gradient(circle, #5a1a00 0%, var(--bg) 70%); animation: shake 0.3s infinite; }
.bomb {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  line-height: 1.1;
  background: var(--red);
  border-color: var(--yellow);
  animation: pulse 0.4s infinite;
}
.bomb:active { transform: translate(-50%, -50%) scale(0.95); }

.mash {
  width: min(70vw, 300px);
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 2.5rem;
  background: var(--pink);
  border: 6px solid var(--yellow);
  box-shadow: 0 10px 0 #000, 0 0 40px var(--pink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.mash span { font-size: 3rem; color: var(--yellow); }
.mash:active { transform: translateY(8px); box-shadow: 0 2px 0 #000, 0 0 40px var(--pink); }
.timer { font-size: 2rem; font-weight: 900; color: var(--yellow); }

.summary { list-style: none; padding: 0; margin: 1rem auto; width: min(100%, 420px); text-align: left; }
.summary li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3em 0.6em; border-radius: 8px; }
.summary li:nth-child(odd) { background: rgba(255, 255, 255, 0.05); }
.summary li.loser { background: rgba(255, 62, 165, 0.35); }
.summary-line { color: var(--muted); }

.splat {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  text-align: center;
  animation: splat 2.6s forwards;
}
.splat-blob {
  font-size: 7rem;
  filter: drop-shadow(0 0 20px var(--red));
  background: radial-gradient(circle, rgba(255, 40, 40, 0.85) 0%, rgba(255, 40, 40, 0.5) 45%, transparent 70%);
  border-radius: 50%;
  padding: 2rem;
}
.splat-text { font-weight: 800; background: rgba(0, 0, 0, 0.6); border-radius: 8px; padding: 0.2em 0.6em; }
@keyframes splat {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  10% { transform: scale(1.2) rotate(5deg); opacity: 1; }
  20% { transform: scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(40px); }
}

/* ---- Host ---- */

.host .splat-blob { font-size: 3.5rem; padding: 1rem; }

body.host { display: flex; flex-direction: column; min-height: 100vh; }
.host-layout { flex: 1; display: grid; grid-template-columns: 1fr 260px; min-height: 0; }
#stage { padding: 1rem 2rem; text-align: center; overflow: auto; }
#side { background: rgba(0, 0, 0, 0.3); border-left: 3px solid var(--cyan); padding: 0.5rem 1rem; overflow: auto; }
#side ul { list-style: none; padding: 0; margin: 0 0 1rem; }
#side li { display: flex; justify-content: space-between; align-items: center; padding: 0.15em 0; }
.kick { padding: 0 0.4em; font-size: 0.8rem; border-width: 1px; border-color: var(--red); box-shadow: none; }
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  padding: 0.8rem;
  background: rgba(0, 0, 0, 0.4);
  border-top: 3px solid var(--pink);
}

.join-code { font-size: clamp(2.5rem, 7vw, 5.5rem); color: var(--yellow); letter-spacing: 0.08em; margin: 0; }
.join-url { font-size: clamp(1rem, 1.8vw, 1.5rem); font-weight: 700; color: var(--cyan); overflow-wrap: anywhere; user-select: text; }
.rule { font-size: 1.6rem; max-width: 900px; }
.intro .mega { animation: pop 0.4s, pulse 1s 0.4s infinite; }
.countdown { width: min(600px, 80%); height: 12px; margin-top: 2rem; border-radius: 6px; background: var(--cyan); animation: countdown 4s linear forwards; }
@keyframes countdown { to { width: 0; } }

.grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.8rem; margin: 1rem 0; }
.avatar {
  width: 110px;
  padding: 0.5rem;
  border-radius: 14px;
  background: var(--bg2);
  border: 3px solid var(--cyan);
  animation: pop 0.3s;
  position: relative;
}
.avatar .face { font-size: 2.6rem; }
.avatar .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar .badge { font-weight: 800; color: var(--yellow); }
.avatar.hot { border-color: var(--red); background: #5a1a00; animation: shake 0.2s infinite; }
.avatar.out { border-color: var(--pink); background: #4a0f35; }

.qd-banner { font-size: clamp(3rem, 10vw, 8rem); font-weight: 900; border-radius: 20px; padding: 1rem; text-shadow: 4px 4px 0 #000; }
.qd-banner.ready { background: #5a0f2a; }
.qd-banner.go { background: var(--green); color: #052; animation: pop 0.15s; }

.bars { max-width: 900px; margin: 0 auto; }
.bar-row { display: grid; grid-template-columns: 200px 1fr 60px; align-items: center; gap: 0.8rem; margin: 0.3rem 0; text-align: left; }
.bar-row .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 22px; background: rgba(255, 255, 255, 0.08); border-radius: 11px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); transition: width 0.15s; }

.talk-timer { font-size: 3rem; font-weight: 900; color: var(--cyan); font-variant-numeric: tabular-nums; }
.talk-timer.over { color: var(--red); animation: pulse 0.6s infinite; }
.crown { font-size: 8rem; }

@media (max-width: 800px) {
  .host-layout { grid-template-columns: 1fr; }
  #side { border-left: none; border-top: 3px solid var(--cyan); }
}
