:root {
  --time: 18s;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --purple: #46178f;
  --dark: #1a1440;
  --ink: #2b1547;
}

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

html, body {
  height: 100%;
  font-family: 'Arial Rounded MT Bold', 'Trebuchet MS', Arial, sans-serif;
  color: #fff;
  overflow-y: auto;
}

body {
  background: var(--purple);
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.06), transparent 40%),
                    radial-gradient(circle at 80% 80%, rgba(255,255,255,.06), transparent 40%);
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: pop .3s ease;
}
.screen.active { display: flex; }

@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

h1, h2 {
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}

.logo {
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: .2rem;
}
.logo span { color: #ffca18; }

/* ---------- LOBBY ---------- */
#lobby {
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 24px;
  overflow-y: auto;
}
#lobby::before, #lobby::after { content: ''; margin: auto; }
  gap: 22px;
}
.sub { font-size: 1.05rem; opacity: .9; font-weight: 600; }

.field {
  width: min(420px, 90vw);
  background: #fff;
  border-radius: 14px;
  padding: 4px;
  display: flex;
  box-shadow: 0 8px 0 rgba(0,0,0,.25);
}
.field svg { flex: 0 0 44px; align-self: center; opacity: .5; }
.field input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  padding: 14px 10px;
  background: transparent;
  font-family: inherit;
  text-align: center;
}
.field input::placeholder { color: #b9a9d6; }

.bots {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.autobar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: .95rem;
}
.autolabel { white-space: nowrap; }
.autohint { font-size: .75rem; opacity: .7; font-weight: 600; }
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: 999px;
  padding: 4px 6px;
}
.step {
  border: none;
  background: var(--yellow);
  color: var(--ink);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}
.step:active { transform: scale(.92); }
.stepcount {
  width: 40px;
  text-align: center;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--ink);
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
}
.stepcount::-webkit-outer-spin-button, .stepcount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepcount::-moz-appearance: textfield;
.stepcount::placeholder { color: #b9a9d6; }
.botcard {
  background: rgba(255,255,255,.12);
  border: 3px solid transparent;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: .95rem;
  transition: all .15s;
}
.botcard:hover { background: rgba(255,255,255,.2); }
.botcard.on { border-color: var(--yellow); background: rgba(255,255,255,.22); transform: translateY(-2px); }
.botcard .bava { font-size: 1.4rem; }

#startBtn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(var(--yellow), #b47e00);
  border-radius: 999px;
  padding: 16px 54px;
  box-shadow: 0 8px 0 #7a5300, 0 10px 20px rgba(0,0,0,.3);
  transition: transform .1s, box-shadow .1s;
}
#startBtn:hover { transform: translateY(-2px); }
#startBtn:active { transform: translateY(4px); box-shadow: 0 3px 0 #7a5300; }
#startBtn:disabled { filter: grayscale(.6); cursor: wait; }

/* ---------- LOADING ---------- */
#loading { align-items: center; justify-content: center; text-align: center; gap: 18px; }
.spinner {
  width: 70px; height: 70px; border-radius: 50%;
  border: 6px solid rgba(255,255,255,.2);
  border-top-color: var(--yellow);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingMsg { font-size: 1.1rem; font-weight: 700; }

/* ---------- QUESTION BANNER ---------- */
#question .banner {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
}
#question .banner .count { font-weight: 900; font-size: 1.4rem; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.banner-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.answc {
  font-weight: 800;
  font-size: .95rem;
  background: rgba(255,255,255,.14);
  padding: 6px 14px;
  border-radius: 999px;
  text-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.answc b { color: var(--yellow); font-size: 1.15rem; margin-left: 4px; }

.timer {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900;
  position: relative;
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  z-index: 2;
}
.timer::before {
  content: '';
  position: absolute; inset: -8px; border-radius: 50%;
  border: 6px solid rgba(255,255,255,.2);
}
.timer::after {
  content: '';
  position: absolute; inset: -8px; border-radius: 50%;
  border: 6px solid var(--yellow);
  border-right-color: transparent;
  animation: countdown var(--time) linear forwards;
  transform: rotate(0);
}
@keyframes countdown { to { transform: rotate(360deg); } }

.prompt {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: 14px 20px;
  font-size: clamp(1.3rem, 4vw, 2.2rem);
  font-weight: 800;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}

.answers {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
  padding: 0 8px 8px;
  height: 44%;
}
@media (max-width: 640px) {
  .answers { height: 40%; font-size: .9rem; }
}
.answer {
  border: none;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: inherit;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  box-shadow: inset 0 -8px 0 rgba(0,0,0,.25);
  border-radius: 8px;
  transition: transform .1s, filter .2s;
  position: relative;
  overflow: hidden;
}
.answer:hover:not(:disabled) { transform: scale(1.02); }
.answer:active:not(:disabled) { transform: scale(.98); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.answer:disabled { cursor: default; }
.answer .shaw {
  flex: 0 0 30px; height: 30px; border-radius: 8px;
  background: rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
.a0 { background: var(--red); }
.a1 { background: var(--blue); }
.a2 { background: var(--yellow); }
.a3 { background: var(--green); }
.answer .txt { text-align: left; }
.answer.correct { background: var(--green) !important; animation: flash .5s; }
.answer.wrong { background: #5a1a1a !important; }
.answer.dim { filter: brightness(.45); }
.answer.lock { filter: brightness(.6); }
.answer.mine { outline: 4px solid #fff; }

/* ---------- score bubbles on the board ---------- */
.bubble {
  position: absolute;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  z-index: 4;
  transition: all .2s;
  cursor: default;
  background: var(--dark);
}
.bubble.wrong { background: #8a1a1a; transform: rotate(360deg) scale(.6); opacity: .6; }
.bubble.correct { background: var(--dark); }
.bubble .pts { font-size: .65rem; color: var(--yellow); }

/* ---------- HUD ---------- */
#hud {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.playerchip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: .9rem;
}
.playerchip.me { background: var(--yellow); color: var(--ink); }
.playerchip .ava { font-size: 1.2rem; }
.playerchip .score { color: var(--yellow); }
.playerchip.me .score { color: var(--ink); opacity: .7; }

/* ---------- END ---------- */
#end { align-items: center; justify-content: flex-start; text-align: center; padding: 24px; gap: 20px; overflow-y: auto; }
#end::before, #end::after { content: ''; margin: auto; }
.podium {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  justify-content: center;
}
.pod {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 120px;
}
.pod .rank { font-size: .85rem; font-weight: 900; opacity: .8; }
.pod .ava { font-size: 2.6rem; }
.pod .stand {
  width: 100%; border-radius: 8px 8px 0 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.2rem;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.25);
  padding: 8px;
  color: var(--ink);
}
.pod .stand.p1 { height: 130px; background: #ffca18; }
.pod .stand.p2 { height: 95px; background: #cfd6dd; }
.pod .stand.p3 { height: 70px; background: #d08a5b; }
.pod .name { font-weight: 800; font-size: 1rem; max-width: 130px; }
.winner-banner { font-size: clamp(1.6rem, 5vw, 2.6rem); font-weight: 900; }
#againBtn {
  border: none; cursor: pointer; font-family: inherit;
  font-size: 1.3rem; font-weight: 900; color: #fff;
  background: linear-gradient(var(--green), #1c7006);
  border-radius: 999px; padding: 14px 44px;
  box-shadow: 0 8px 0 #124b04, 0 10px 20px rgba(0,0,0,.3);
}
#againBtn:active { transform: translateY(4px); box-shadow: 0 3px 0 #124b04; }

/* ---------- toast / bot messaging ---------- */
.feed {
  flex: 0 0 auto;
  min-height: 64px;
  padding: 6px 14px;
  display: flex; gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.feed .msg {
  background: rgba(255,255,255,.15);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .8rem;
  font-weight: 700;
  animation: slideup .3s ease;
}
@keyframes slideup { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

/* ---------- WATCH TOGGLE ---------- */
.watchtoggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: .95rem;
  user-select: none;
}
.watchtoggle input { display: none; }
.wtrack {
  width: 54px; height: 30px;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  position: relative;
  transition: background .2s;
  flex: 0 0 auto;
}
.wknob {
  position: absolute;
  top: 2px; left: 2px;
  width: 26px; height: 26px;
  background: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
  transition: transform .2s;
  box-shadow: 0 2px 5px rgba(0,0,0,.3);
}
.watchtoggle input:checked + .wtrack { background: var(--yellow); }
.watchtoggle input:checked + .wtrack .wknob { transform: translateX(24px); }
.wtlabel { color: #fff; }

/* ---------- CUSTOM BOT MODAL ---------- */
.botcard.add {
  border: 3px dashed rgba(255,255,255,.4);
  background: transparent;
  color: #fff;
  font-size: 1.2rem;
  padding: 8px 18px;
}
.botcard.add:hover { background: rgba(255,255,255,.12); }
.botcard .bx {
  background: rgba(0,0,0,.3);
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
}
.botcard .bx:hover { background: rgba(0,0,0,.5); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 8, 40, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.modal {
  background: #fff;
  color: var(--ink);
  border-radius: 18px;
  padding: 20px;
  width: min(380px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.mhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 900;
  font-size: 1.2rem;
}
.mclose {
  border: none;
  background: #eee;
  color: var(--ink);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 900;
}
.mclose:hover { background: #ddd; }
.modal input[type="text"] {
  border: 3px solid #e3daf0;
  border-radius: 10px;
  padding: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  text-align: center;
}
.modal input[type="text"]:focus { border-color: var(--yellow); }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.em {
  border: 3px solid transparent;
  background: #f2edfa;
  font-size: 1.7rem;
  border-radius: 12px;
  cursor: pointer;
  padding: 4px 8px;
  transition: all .15s;
}
.em:hover { transform: scale(1.1); }
.em.on { border-color: var(--yellow); background: #fff4c8; }
.mrow {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 800;
  font-size: .85rem;
  color: #7a6a9e;
}
.mrow input[type="range"] { width: 100%; accent-color: var(--yellow); }
.primary {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(var(--green), #1c7006);
  border-radius: 999px;
  padding: 13px;
  box-shadow: 0 5px 0 #124b04;
}
.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #124b04; }
