:root {
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --ink: #1f1135;
  --bg1: #46178f;
  --bg2: #7b2ff7;
  --paper: #ffffff;
  --muted: #6b6b80;
  --ok: #26890c;
  --bad: #e21b3c;
  --shadow: 0 6px 0 rgba(0,0,0,.18);
}

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

html, body { height: 100%; }

body {
  font-family: "Segoe UI", Montserrat, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg2), var(--bg1));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}

a { color: inherit; }

.brand {
  color: #fff;
  font-weight: 800;
  font-size: clamp(28px, 7vw, 56px);
  letter-spacing: 1px;
  text-shadow: 0 4px 0 rgba(0,0,0,.25);
  margin: 10px 0 4px;
}
.brand span { color: #ffd000; }
.tagline { color: #e9defc; margin-bottom: 18px; font-size: 14px; }

.card {
  background: var(--paper);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.card.wide { max-width: 960px; }

.screen { display: none; width: 100%; align-items: center; flex-direction: column; }
.screen.active { display: flex; }

h1, h2 { line-height: 1.15; }
.center { text-align: center; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }

input, select, textarea, button { font: inherit; }

input.field, select.field, textarea.field {
  width: 100%;
  padding: 14px 16px;
  border: 3px solid #e3e3ef;
  border-radius: 10px;
  font-size: 18px;
  outline: none;
}
input.field:focus, textarea.field:focus, select.field:focus { border-color: var(--bg2); }
input.pin {
  text-align: center;
  font-size: 30px;
  letter-spacing: 8px;
  font-weight: 800;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .05s ease, filter .15s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: translateY(3px); box-shadow: none; }
button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
button.block { width: 100%; }
button.ghost { background: #efeef6; color: var(--ink); box-shadow: 0 6px 0 #d7d6e4; }
button.green { background: var(--green); box-shadow: 0 6px 0 #1c6608; }
button.red { background: var(--red); box-shadow: 0 6px 0 #a5132c; }
button.small { padding: 8px 12px; font-size: 14px; border-radius: 8px; box-shadow: 0 4px 0 rgba(0,0,0,.18); }

/* ---- big PIN / lobby ---- */
.pinbox { background: var(--paper); color: var(--ink); border-radius: 14px; padding: 14px 22px; text-align: center; }
.pinbox .label { font-size: 14px; color: var(--muted); font-weight: 700; }
.pinbox .pin { font-size: clamp(40px, 12vw, 84px); font-weight: 900; letter-spacing: 6px; }
.joinurl { color:#fff; font-size: 15px; margin: 10px 0; }
.joinurl b { background: rgba(0,0,0,.25); padding: 3px 8px; border-radius: 6px; }

.players { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.chip {
  background: #fff; color: var(--ink); font-weight: 800;
  padding: 8px 14px; border-radius: 999px; box-shadow: 0 4px 0 rgba(0,0,0,.15);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.counter { color:#fff; font-weight:800; font-size: 20px; }

/* ---- question + answers ---- */
.qtext {
  background: #fff; color: var(--ink); border-radius: 14px;
  padding: 18px; font-size: clamp(20px, 3.2vw, 34px); font-weight: 800;
  text-align: center; width: 100%; margin-bottom: 14px;
}
.qmeta { color:#fff; display:flex; justify-content: space-between; width:100%; margin-bottom:10px; font-weight:700;}

.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.answers.single { grid-template-columns: 1fr; }
.ans {
  display: flex; align-items: center; gap: 12px;
  color: #fff; font-size: clamp(16px, 2.4vw, 24px); font-weight: 800;
  padding: 18px; border-radius: 12px; min-height: 76px; text-align: left;
  box-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.ans .shape { font-size: 26px; line-height: 1; }
.ans.c0 { background: var(--red); }
.ans.c1 { background: var(--blue); }
.ans.c2 { background: var(--yellow); }
.ans.c3 { background: var(--green); }
.ans.dim { opacity: .35; }
.ans.win { outline: 5px solid #fff; box-shadow: 0 0 0 6px rgba(255,255,255,.4), 0 6px 0 rgba(0,0,0,.25); }
.ans .tick { margin-left: auto; font-size: 26px; }

button.ans { cursor: pointer; }
.player-answers { grid-template-columns: 1fr 1fr; }
.player-answers .ans { min-height: 18vh; font-size: clamp(16px,4.5vw,22px); }
.player-answers .ans .shape { font-size: 34px; }

/* ---- timer ---- */
.timer {
  width: 64px; height: 64px; border-radius: 50%;
  background: #fff; color: var(--ink); font-weight: 900; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
}
.bar { width: 100%; height: 12px; background: rgba(255,255,255,.3); border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.bar > i { display: block; height: 100%; background: #ffd000; width: 100%; transition: width .25s linear; }

/* ---- reveal distribution ---- */
.dist { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; align-items: end; }
.dist .col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dist .barv { width: 70%; border-radius: 8px 8px 0 0; min-height: 6px; transition: height .4s ease; }
.dist .barv.c0 { background: var(--red); }
.dist .barv.c1 { background: var(--blue); }
.dist .barv.c2 { background: var(--yellow); }
.dist .barv.c3 { background: var(--green); }
.dist .n { color: var(--ink); font-weight: 800; }
.dist .lab { color: var(--ink); font-weight:700; display:flex; gap:6px; align-items:center; justify-content:center; text-align:center; }
.dist .barv.win { outline: 4px solid var(--ink); }

.lb { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.lb .lrow {
  display: flex; align-items: center; gap: 10px; background: #fff;
  border-radius: 10px; padding: 10px 14px; font-weight: 800; box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.lb .lrow .pos { width: 26px; color: var(--muted); }
.lb .lrow .sc { margin-left: auto; }

/* ---- player result ---- */
.verdict { width: 100%; border-radius: 16px; padding: 28px; text-align: center; color:#fff; }
.verdict.good { background: var(--green); }
.verdict.bad { background: var(--red); }
.verdict .big { font-size: 36px; font-weight: 900; }
.verdict .pts { font-size: 26px; font-weight: 800; margin-top: 8px; }
.waitdot { color:#fff; font-size: 20px; font-weight: 700; text-align:center; }

/* ---- podium ---- */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; width: 100%; margin: 20px 0; }
.podium .stand { background: #fff; border-radius: 12px 12px 0 0; width: 28%; text-align: center; padding: 12px; box-shadow: 0 6px 0 rgba(0,0,0,.2); }
.podium .stand .nm { font-weight: 900; }
.podium .stand .sc { color: var(--muted); font-weight: 800; }
.podium .p1 { height: 200px; background: #ffd700; }
.podium .p2 { height: 160px; background: #e6e6e6; }
.podium .p3 { height: 130px; background: #e6a667; }
.podium .medal { font-size: 30px; }

/* ---- editor ---- */
.qcard { border: 3px solid #ece9f6; border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.qcard .opt { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.qcard .opt .dot { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.qcard .opt .dot.c0 { background: var(--red);} .qcard .opt .dot.c1 { background: var(--blue);}
.qcard .opt .dot.c2 { background: var(--yellow);} .qcard .opt .dot.c3 { background: var(--green);}
.qcard .opt input[type=radio] { width: 22px; height: 22px; }
.qhead { display:flex; gap:10px; align-items:center; }
.qhead .num { font-weight: 900; color: var(--bg1); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--red); color: #fff; font-weight: 800; padding: 12px 18px;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.3); display: none; z-index: 50;
}
.toast.show { display: block; animation: pop .2s ease; }

.footlink { color:#e9defc; margin-top:16px; font-size: 13px; }
.hide { display: none !important; }

/* ---- user bar + badges (host/admin) ---- */
.userbar {
  width: 100%; max-width: 960px; display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.12); color: #fff; border-radius: 10px;
  padding: 8px 14px; margin-bottom: 14px; font-size: 14px;
}
.userbar b { font-weight: 800; }
.badge {
  display: inline-block; background: #efeef6; color: var(--ink);
  font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px;
  text-transform: capitalize;
}
.badge.admin { background: #ffd000; color: #4a3b00; }
.badge.on { background: #d4f4cf; color: #1c6608; }
.badge.off { background: #f6d4d4; color: #a5132c; }
#userList .lrow { gap: 8px; flex-wrap: wrap; }

/* ---- landing / front page ---- */
.home-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  width: 100%; max-width: 820px;
}
.home-card {
  background: var(--paper); border-radius: 16px; padding: 24px;
  display: flex; flex-direction: column; gap: 10px; min-height: 270px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.home-card h2 { font-size: 26px; }
.home-ico { font-size: 50px; line-height: 1; }

/* ---- wheel of fortune ---- */
.wheel-layout {
  display: flex; gap: 24px; width: 100%; max-width: 900px;
  align-items: flex-start; justify-content: center;
}
.wheel-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.wheel-stage canvas {
  width: min(82vw, 440px); height: auto; border-radius: 50%;
  transform-origin: 50% 50%; box-shadow: 0 12px 34px rgba(0,0,0,.4);
  background: #fff;
}
.wheel-pointer {
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; border-left: 16px solid transparent; border-right: 16px solid transparent;
  border-top: 30px solid #fff; z-index: 5; filter: drop-shadow(0 3px 2px rgba(0,0,0,.45));
}
#spinBtn { font-size: 22px; padding: 14px 44px; border-radius: 999px; letter-spacing: 1px; }
.wheel-panel { flex: 1; max-width: 360px; }
.namelist { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; margin-top: 4px; }
.nm-item { display: flex; align-items: center; gap: 8px; background: #f4f2fb; border-radius: 8px; padding: 8px 12px; font-weight: 700; }
.nm-item .x { margin-left: auto; cursor: pointer; color: var(--muted); font-weight: 800; border: none; background: none; font-size: 20px; box-shadow: none; padding: 0 4px; }
.nm-item .x:active { transform: none; }

/* ---- overlay (winner) ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,8,50,.72);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.overlay-card {
  background: var(--paper); border-radius: 18px; padding: 30px 34px; text-align: center;
  max-width: 92vw; box-shadow: 0 24px 70px rgba(0,0,0,.5); animation: pop .25s ease;
}
.overlay-card .muted { font-weight: 800; text-transform: uppercase; letter-spacing: 2px; }
.winner-name { font-size: clamp(30px, 8vw, 56px); font-weight: 900; color: var(--bg1); margin: 6px 0 20px; word-break: break-word; }

@media (max-width: 640px) {
  .home-grid { grid-template-columns: 1fr; }
  .wheel-layout { flex-direction: column; align-items: center; }
  .wheel-panel { max-width: min(82vw, 440px); width: 100%; }
}

@media (max-width: 520px) {
  .player-answers .ans { min-height: 18vh; }
}
