:root {
  --bg: #1b1245;
  --bg2: #2a1b6b;
  --panel: #2f2278;
  --panel2: #3b2c8f;
  --ink: #ffffff;
  --muted: #b9b0ee;
  --yellow: #ffd23f;
  --pink: #ff5fa2;
  --cyan: #3fe0ff;
  --green: #4be38a;
  --red: #ff5a5f;
  --shadow: rgba(10, 5, 40, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 0%, var(--bg2), var(--bg) 60%) fixed;
  color: var(--ink);
  font-family: "Nunito", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
}

button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

#app { max-width: 880px; margin: 0 auto; padding: 12px 16px 48px; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 6px 0 14px; }
.logo { font-size: 22px; color: var(--yellow); letter-spacing: 0.5px; transform: rotate(-2deg); display: inline-block; text-shadow: 3px 3px 0 var(--pink); }
.roomtag { background: var(--panel); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.roomtag b { color: var(--ink); letter-spacing: 3px; }

.card { background: var(--panel); border-radius: 18px; padding: 18px; box-shadow: 0 6px 0 var(--shadow); }
.stack { display: grid; gap: 14px; }
.stack > *, .two > * { min-width: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }

/* buttons */
.btn {
  background: var(--yellow);
  color: #2b1c00;
  border: 0;
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c99a00;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #c99a00; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.big { font-size: 20px; padding: 14px 28px; }
.btn.alt { background: var(--cyan); box-shadow: 0 5px 0 #1a9ab5; color: #00222b; }
.btn.alt:active:not(:disabled) { box-shadow: 0 1px 0 #1a9ab5; }
.btn.ghost { background: var(--panel2); color: var(--ink); box-shadow: 0 4px 0 var(--shadow); }
.btn.danger { background: var(--red); box-shadow: 0 5px 0 #b02a2e; color: #fff; }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; box-shadow: 0 3px 0 var(--shadow); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.mid { justify-content: center; }

/* inputs */
.input {
  width: 100%;
  background: #1b1245;
  border: 3px solid var(--panel2);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 18px;
  outline: none;
}
.input:focus { border-color: var(--cyan); }
.input.code { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 24px; }
.err { color: var(--red); min-height: 22px; }

/* avatars */
.av {
  display: inline-grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 24px;
  background: hsl(var(--h, 260) 70% 55%);
  border: 3px solid rgba(255, 255, 255, 0.85);
  flex: none;
}
.av.sm { width: 30px; height: 30px; font-size: 16px; border-width: 2px; }
.av.lg { width: 64px; height: 64px; font-size: 36px; }
.avpick { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.avpick button { background: var(--panel2); border: 3px solid transparent; border-radius: 12px; font-size: 24px; padding: 4px 0; cursor: pointer; min-width: 0; }
@media (max-width: 420px) { .avpick button { font-size: 18px; border-width: 2px; } }
.avpick button.on { border-color: var(--yellow); background: #4a3aa8; }

/* home */
.hero { text-align: center; padding: 20px 0 6px; }
.hero .logo { font-size: 48px; }
.hero p { color: var(--muted); margin-top: 8px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 640px) { .two { grid-template-columns: minmax(0, 1fr); } }

/* lobby */
.codebox { text-align: center; }
.code-big { font-size: 56px; letter-spacing: 12px; color: var(--yellow); text-shadow: 4px 4px 0 var(--pink); padding-left: 12px; }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.pl { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 14px; padding: 10px; position: relative; }
.pl.off { opacity: 0.5; }
.pl .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .sub { font-size: 12px; color: var(--muted); }
.pl .kick { margin-left: auto; }
.crown { position: absolute; top: -10px; left: 6px; font-size: 20px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dashed var(--panel2); }
.setrow:last-child { border-bottom: 0; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper b { min-width: 52px; text-align: center; }
.banner { background: #4a3aa8; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.banner.warn { background: #6a2d5a; }

/* timer */
.timer { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar { flex: 1; height: 16px; background: var(--panel); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--green); border-radius: 999px; transition: width 0.2s linear, background 0.3s; }
.bar i.low { background: var(--red); }
.timer b { min-width: 42px; text-align: right; font-size: 20px; }

/* canvas */
.board-wrap { background: #fff; border-radius: 14px; border: 4px solid #fff; box-shadow: 0 6px 0 var(--shadow); overflow: hidden; width: 100%; max-width: 640px; margin: 0 auto; line-height: 0; }
.board { width: 100%; height: auto; touch-action: none; cursor: crosshair; display: block; background: #fff; }
.board.off { cursor: not-allowed; opacity: 0.6; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.tools .btn.on { outline: 3px solid #fff; }

/* pictures */
.pic { display: block; width: 100%; height: auto; background: #fff; border-radius: 12px; aspect-ratio: 4 / 3; object-fit: contain; }
.target-big { max-width: 560px; margin: 0 auto; border: 4px solid #fff; background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 6px 0 var(--shadow); line-height: 0; }
.target-big .pic { border-radius: 0; }

/* big messages */
.bigmsg { text-align: center; padding: 28px 12px; }
.bigmsg h2 { font-size: 30px; }
.countnum { font-size: 120px; line-height: 1; color: var(--yellow); text-shadow: 6px 6px 0 var(--pink); animation: pop 1s ease-in-out infinite; }
@keyframes pop { 0% { transform: scale(0.8); } 30% { transform: scale(1.1); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .countnum { animation: none; } }

.role { display: inline-block; background: var(--panel2); border-radius: 999px; padding: 5px 14px; font-size: 13px; }
.role.d { background: var(--pink); }

/* status strip */
.strip { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.chip { display: flex; align-items: center; gap: 6px; background: var(--panel); border-radius: 999px; padding: 4px 12px 4px 4px; font-size: 14px; }
.chip.off { opacity: 0.45; }
.chip .ok { color: var(--green); }

/* voting */
.cands { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 14px; }
.cand { background: var(--panel); border: 4px solid transparent; border-radius: 16px; padding: 8px; cursor: pointer; text-align: center; font-size: 14px; color: var(--muted); }
.cand:hover:not(:disabled) { border-color: var(--cyan); }
.cand.on { border-color: var(--yellow); background: var(--panel2); color: var(--ink); }
.cand:disabled { cursor: default; opacity: 0.7; }
.cand .pic { margin-bottom: 6px; }

/* results */
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 12px; margin: 10px 0 18px; }
.pod { text-align: center; width: 120px; }
.pod .blk { border-radius: 12px 12px 0 0; display: grid; place-items: center; font-size: 30px; color: #2b1c00; }
.pod.p1 .blk { height: 120px; background: var(--yellow); }
.pod.p2 .blk { height: 90px; background: #d7dbe8; }
.pod.p3 .blk { height: 64px; background: #e2a46a; }
.pod .nm { margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { display: grid; gap: 8px; }
.rk { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 14px; padding: 8px 12px; }
.rk .pts { margin-left: auto; font-size: 22px; color: var(--yellow); }
.rk .sub { font-size: 12px; color: var(--muted); }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 14px; }
.award { background: var(--panel2); border-radius: 14px; padding: 10px 14px; }
.award h4 { margin: 0 0 4px; color: var(--cyan); font-size: 14px; }
.recapset { margin-bottom: 22px; }
.recapset h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.shot { background: var(--panel); border-radius: 12px; padding: 6px; font-size: 13px; color: var(--muted); cursor: zoom-in; }
.shot .pic { margin-bottom: 4px; }
.shot.tgt { border: 3px solid var(--yellow); }
.zoom { position: fixed; inset: 0; background: rgba(10, 5, 40, 0.88); display: grid; place-items: center; padding: 16px; z-index: 50; cursor: zoom-out; }
.zoom img { max-width: min(100%, 900px); max-height: 100%; border-radius: 14px; background: #fff; }

/* overlay + toasts */
#overlay { position: fixed; left: 0; right: 0; bottom: 0; display: grid; gap: 8px; padding: 10px; z-index: 40; pointer-events: none; }
#overlay > * { pointer-events: auto; margin: 0 auto; max-width: 560px; width: 100%; }
.kickbox { background: var(--red); color: #fff; border-radius: 16px; padding: 12px 16px; box-shadow: 0 6px 0 var(--shadow); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.conn { background: #6a2d5a; border-radius: 12px; padding: 8px 14px; text-align: center; }
#toasts { position: fixed; top: 12px; left: 0; right: 0; display: grid; gap: 8px; z-index: 60; pointer-events: none; }
.toast { margin: 0 auto; background: #fff; color: #2b1c00; border-radius: 12px; padding: 10px 16px; box-shadow: 0 5px 0 var(--shadow); max-width: 90%; }


.candwrap { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.rep { background: transparent; border: 0; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 4px 8px; text-decoration: underline; }
.rep:hover { color: var(--red); }
.shot .rep { display: block; margin: 2px auto 0; }

.langpick { display: inline-flex; gap: 4px; background: var(--panel2); border-radius: 999px; padding: 4px; }
.langpick button { background: transparent; border: 0; border-radius: 999px; font-size: 20px; line-height: 1; padding: 6px 10px; cursor: pointer; opacity: 0.55; }
.langpick button.on { background: var(--panel); opacity: 1; box-shadow: 0 0 0 2px var(--yellow); }
.langpick button:hover { opacity: 1; }

.switch { flex: none; width: 54px; height: 30px; border-radius: 999px; border: 0; background: #5b4fa8; position: relative; cursor: pointer; transition: background 0.15s; padding: 0; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 var(--shadow); transition: transform 0.15s; }
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(24px); }
.switch:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.fine { font-size: 12px; opacity: 0.8; margin-top: 4px; }

.estimate { border-bottom: 0; color: var(--muted); font-size: 14px; padding-bottom: 0; }

.cats { align-items: flex-start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 60%; }
.catchip { border: 0; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; background: var(--panel2); color: var(--muted); }
.catchip.on { background: var(--cyan); color: #10264a; font-weight: 700; }
.catchip:disabled { cursor: default; }
.board-wrap.zoomed { outline: 3px solid var(--cyan); }
.waitbanner { background: var(--panel2); border: 3px dashed var(--yellow); border-radius: 14px; padding: 12px 14px; text-align: center; font-size: 18px; font-weight: 700; }
.waitbanner small { display: block; margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--muted); }
.cands.view .cand:disabled { opacity: 1; cursor: default; }
.hero .mascot { width: 120px; height: 120px; margin-bottom: 4px; filter: drop-shadow(0 6px 0 var(--shadow)); }

/* ad banners: empty (and hidden) unless ads are enabled and a provider fills them */
.adslot { display: flex; justify-content: center; margin: 4px auto 0; max-width: 100%; }
.adslot:empty { display: none; }
.adslot .adbox { width: 100%; max-width: 336px; min-height: 100px; border-radius: 12px; background: var(--panel2); display: grid; place-items: center; text-align: center; padding: 8px; font-size: 13px; opacity: .85; }
.adslot .adbox small { display: block; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; opacity: .7; margin-bottom: 4px; }
