:root {
  --bg: #46178f;
  --bg-dark: #2b0c5c;
  --red: #e21b3c;
  --blue: #1368ce;
  --yellow: #d89e00;
  --green: #26890c;
  --ink: #222;
  --muted: #6b6b6b;
  --ok: #26890c;
  --bad: #e21b3c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: var(--bg);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.correct { background: var(--ok); }
body.wrong { background: var(--bad); }

.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  text-align: center;
}
.screen.active { display: flex; }

.card {
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.logo { font-size: 40px; font-weight: 900; letter-spacing: -1px; }

input {
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  padding: 12px;
  border: 2px solid #ccc;
  border-radius: 4px;
  text-align: center;
  width: 100%;
}
input:focus { outline: none; border-color: var(--bg); }

button {
  font: inherit;
  cursor: pointer;
  border: none;
}

.btn {
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  padding: 14px 24px;
  border-radius: 4px;
  box-shadow: 0 4px 0 #000;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #000; }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.light { background: #fff; color: var(--ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .3); }
.btn.ghost { background: rgba(255, 255, 255, .15); color: #fff; box-shadow: none; }
a.btn { text-decoration: none; display: inline-block; }
.btn.small { font-size: 16px; padding: 10px 18px; }

.roles {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}
.role-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3);
}
.role-note {
  background: #fff; color: var(--ink);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 17px; font-weight: 800; line-height: 1.4;
  width: 100%; max-width: 360px;
}
.role-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.role-btn.player { background: var(--blue); }
.role-btn.host { background: var(--red); }
.role-shape { font-size: 22px; opacity: .8; }
.role-name { font-size: 30px; font-weight: 900; }
.role-desc { font-size: 15px; font-weight: 600; opacity: .9; }
@media (min-width: 640px) {
  .roles { flex-direction: row; max-width: 600px; }
  .role-btn { flex: 1; padding: 36px 16px; }
}

.error { color: var(--bad); font-weight: 700; min-height: 1.3em; }

.big { font-size: 32px; font-weight: 900; }
.huge { font-size: 56px; font-weight: 900; line-height: 1.1; }
.sub { font-size: 18px; opacity: .85; font-weight: 600; }

.spinner {
  width: 48px; height: 48px;
  border: 6px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.c0 { background: var(--red); }
.c1 { background: var(--blue); }
.c2 { background: var(--yellow); }
.c3 { background: var(--green); }

.shape { font-size: 1.2em; line-height: 1; flex-shrink: 0; }

.timer {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--bg-dark);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 900;
  flex-shrink: 0;
}
.timer.low { background: var(--red); }

/* ---------- player ---------- */

.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: rgba(0, 0, 0, .25);
  font-weight: 800;
  z-index: 10;
}
.topbar[hidden] { display: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.leave-btn {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 14px; font-weight: 800;
  padding: 6px 10px;
  border-radius: 4px;
}
.has-topbar .screen { padding-top: 60px; }

#question.screen { justify-content: flex-start; height: 100dvh; gap: 10px; }
.q-head { flex: none; display: flex; align-items: center; gap: 12px; width: 100%; max-width: 640px; }
.q-text {
  flex: 1;
  background: #fff; color: var(--ink);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: clamp(14px, 2.4dvh, 18px); font-weight: 800;
  text-align: left;
}
.q-img { flex: 0 1 auto; min-height: 0; max-width: 100%; max-height: 28dvh; border-radius: 6px; object-fit: contain; }
.q-img[hidden], .h-img[hidden] { display: none; }
.answers button img { max-width: 100%; max-height: 12dvh; border-radius: 4px; object-fit: contain; }

.answers {
  flex: 1 0 auto;
  width: 100%; max-width: 640px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 180px;
}
.answers button {
  color: #fff;
  border-radius: 6px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3);
  font-size: clamp(14px, 2.4dvh, 18px); font-weight: 800;
  padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  word-break: keep-all;
  overflow-wrap: anywhere;
  min-width: 0;
}
.answers button .shape { font-size: clamp(24px, 4.5dvh, 36px); }
.answers button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, .3); }

.msg {
  background: #fff; color: var(--ink);
  border-radius: 8px;
  padding: 14px 16px;
  max-width: 560px;
  font-size: 18px; font-weight: 800;
  line-height: 1.5;
}
.msg[hidden], .h-msg[hidden] { display: none; }
.h-msg {
  flex: none;
  width: 100%; max-width: 1200px;
  background: var(--bg-dark); color: #fff;
  border: 3px solid #fff;
  border-radius: 8px;
  padding: clamp(10px, 2vh, 20px) 24px;
  font-size: clamp(20px, 3.4vh, 36px); font-weight: 900;
  line-height: 1.4;
}
.katex { font-size: 1.05em; }

.pill {
  display: inline-block;
  background: rgba(0, 0, 0, .3);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 20px; font-weight: 800;
}

/* ---------- host ---------- */

.host .screen { padding: 24px; }

.join-banner {
  display: flex; align-items: center; gap: 24px;
  background: #fff; color: var(--ink);
  border-radius: 8px;
  padding: 16px 24px;
  flex-wrap: wrap; justify-content: center;
}
.join-banner .label { font-size: 18px; font-weight: 700; color: var(--muted); }
.join-banner .url { font-size: 28px; font-weight: 900; word-break: break-all; }
.join-banner .pin { font-size: 64px; font-weight: 900; letter-spacing: 4px; line-height: 1; }
.join-banner img { width: 160px; height: 160px; }

.lobby-bar { display: flex; align-items: center; gap: 16px; width: 100%; max-width: 1100px; justify-content: space-between; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 1100px; }
.chip {
  background: rgba(0, 0, 0, .3);
  color: #fff;
  font-size: 20px; font-weight: 800;
  padding: 10px 18px;
  border-radius: 6px;
}
.chip:hover { background: var(--red); text-decoration: line-through; }
.chip.offline { opacity: .45; }

#h-question.screen, #h-reveal.screen {
  justify-content: flex-start;
  height: 100dvh;
  gap: 12px;
  padding: 16px 24px;
}
.h-q {
  flex: none;
  background: #fff; color: var(--ink);
  border-radius: 8px;
  padding: clamp(10px, 2.2vh, 24px) 24px;
  font-size: clamp(20px, 3.6vh, 40px); font-weight: 900;
  width: 100%; max-width: 1200px;
  word-break: keep-all;
}
.h-mid { display: flex; align-items: center; width: 100%; max-width: 1200px; flex: 1 1 0; min-height: 0; gap: 16px; }
.h-mid .timer { width: clamp(64px, 11vh, 120px); height: clamp(64px, 11vh, 120px); font-size: clamp(28px, 5vh, 52px); }
.h-img { flex: 1 1 0; min-width: 0; height: 100%; object-fit: contain; }
.h-count { flex: none; margin-left: auto; font-size: clamp(16px, 2.4vh, 24px); font-weight: 800; text-align: center; }
.h-count b { display: block; font-size: clamp(28px, 5vh, 52px); }

.h-choices {
  flex: none;
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: 100%; max-width: 1200px;
}
.h-choice {
  display: flex; align-items: center; gap: 16px;
  min-width: 0;
  padding: clamp(10px, 2vh, 20px) 24px;
  border-radius: 6px;
  font-size: clamp(18px, 2.8vh, 28px); font-weight: 800;
  text-align: left;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .3);
  word-break: keep-all;
  overflow-wrap: anywhere;
  transition: opacity .3s;
}
.h-choice .shape { font-size: clamp(22px, 3.4vh, 36px); }
.h-choice .check { margin-left: auto; font-size: clamp(22px, 3.4vh, 36px); }
.h-choice img { height: clamp(52px, 11vh, 110px); max-width: 50%; object-fit: contain; border-radius: 4px; }
.h-choice.faded { opacity: .3; }

.bars { display: flex; align-items: flex-end; justify-content: center; gap: 24px; flex: 1 1 0; min-height: 0; width: 100%; }
.bar { width: 100px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; font-size: clamp(18px, 2.8vh, 28px); font-weight: 900; }
.bar .fill { width: 100%; border-radius: 4px 4px 0 0; min-height: 8px; transition: height .6s ease-out; }

.board { width: 100%; max-width: 800px; display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; color: var(--ink);
  border-radius: 6px;
  padding: 16px 24px;
  font-size: 28px; font-weight: 900;
}
.row:first-child { background: var(--yellow); color: #fff; }

/* ---------- final screen: hall of fame ---------- */

#h-end.screen {
  justify-content: flex-start;
  height: 100dvh;
  gap: 8px;
  padding: 16px 24px;
  overflow: hidden;
  position: relative;
}
.hof-title { flex: none; font-size: clamp(28px, 5.5vh, 52px); font-weight: 900; }
.hof-caption {
  flex: none;
  min-height: 1.4em;
  font-size: clamp(18px, 3.4vh, 32px); font-weight: 900;
  color: #ffd54f;
}
.hof-caption.pop { animation: hof-pop .45s ease-out; }

.hof-stage {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  width: 100%; max-width: 1100px;
  display: flex; flex-direction: column; justify-content: flex-end;
}

.hof-podium {
  flex: none;
  display: flex; justify-content: center; align-items: flex-end;
  gap: clamp(12px, 3vw, 40px);
  padding: 0 16px;
  border-bottom: 10px solid #d4af37;
}
.hof-col {
  position: relative;
  width: clamp(130px, 22vw, 240px);
  display: flex; flex-direction: column; align-items: center;
}
.hof-name {
  position: relative; z-index: 2;
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #fff; color: var(--ink);
  border-radius: 8px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(18px);
  transition: opacity .4s, transform .4s;
}
.hof-col.in .hof-name { opacity: 1; transform: none; }
.hof-name .who { font-size: clamp(18px, 3.2vh, 30px); font-weight: 900; word-break: break-all; line-height: 1.15; }
.hof-name .pts { font-size: clamp(13px, 2vh, 18px); font-weight: 700; color: var(--muted); }
.hof-ped {
  width: 100%;
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 6px;
  border-radius: 8px 8px 0 0;
  font-size: clamp(26px, 6vh, 56px); font-weight: 900;
}
.r1 .hof-ped { height: clamp(80px, 21vh, 220px); background: linear-gradient(#ffe082, #d89e00); color: #5a3d00; }
.r2 .hof-ped { height: clamp(62px, 15vh, 160px); background: linear-gradient(#eceff1, #90a4ae); color: #37474f; }
.r3 .hof-ped { height: clamp(48px, 11vh, 120px); background: linear-gradient(#ffcc80, #a0522d); color: #3e1f00; }

/* 2nd and 3rd: a pile of hammers. The spot is a zero-size point on the name,
   rotated so each hammer comes in from a different angle. */
.hof-hammer-spot {
  position: absolute; z-index: 3;
  width: 0; height: 0;
  pointer-events: none;
}
.hof-hammer {
  position: absolute;
  width: 160px; height: 64px;
  transform-origin: 0 50%;
  transform: rotate(-70deg);
  opacity: 0;
}
.hof-hammer.swing { animation: hof-swing .9s forwards; }

/* 4th and below: blow up */
.hof-pit {
  flex: none;
  position: relative;
  display: flex; flex-direction: column;
  margin-top: clamp(10px, 2.5vh, 24px);
  padding-bottom: clamp(16px, 4vh, 40px);
}
.hof-loser.doomed { background: #ffcdd2; transition: background 1.4s; }

/* ---------- execution effects (positioned by host.js) ---------- */
.hof-fx { position: absolute; pointer-events: none; }
.hof-flash { inset: 0; z-index: 20; opacity: 0; }
.hof-particle { z-index: 7; border-radius: 2px; }
.hof-smoke {
  z-index: 6;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 120, 120, .8) 0 35%, rgba(80, 80, 80, .45) 55%, rgba(60, 60, 60, 0) 72%);
}
.hof-ring {
  z-index: 7;
  border: 10px solid;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.hof-fireball {
  z-index: 7;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 12%, #fff59d 22%, #ffb300 40%, #f4511e 58%, rgba(183, 28, 28, .6) 68%, rgba(0, 0, 0, 0) 74%);
  mix-blend-mode: screen;
}
.hof-scorch {
  z-index: 1;
  width: 150px; height: 26px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, rgba(0, 0, 0, .75) 0 40%, rgba(40, 20, 0, .4) 60%, rgba(0, 0, 0, 0) 72%);
}
.hof-shard {
  z-index: 6;
  margin: 0 !important;
  transition: none !important;
}

.hof-bomb {
  z-index: 7;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #888 0 8%, #3a3a3a 22%, #111 60%);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
.hof-bomb .fuse {
  position: absolute; left: 50%; top: -14px;
  width: 6px; height: 18px;
  background: #8d6e63;
  border-radius: 3px;
  transform: rotate(20deg);
  transform-origin: 50% 100%;
}
.hof-bomb .spark {
  position: absolute; left: calc(50% + 3px); top: -20px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 25%, #ffeb3b 45%, rgba(255, 152, 0, 0) 70%);
  animation: hof-spark .12s linear infinite alternate;
}

.hof-guillo { z-index: 4; }
.hof-guillo .post {
  position: absolute; top: 0; bottom: 0;
  width: 16px;
  background: linear-gradient(90deg, #5d4037, #8d6e63 45%, #4e342e);
  border-radius: 3px;
}
.hof-guillo .post.l { left: 0; }
.hof-guillo .post.r { right: 0; }
.hof-guillo .beam {
  position: absolute; top: 0; left: -10px; right: -10px;
  height: 18px;
  background: linear-gradient(#8d6e63, #4e342e);
  border-radius: 4px;
}
.hof-guillo .rope {
  position: absolute; top: 18px; left: 50%;
  width: 3px; height: 30px;
  margin-left: -1px;
  background: #d7ccc8;
  transform-origin: 50% 0;
  z-index: 1;
}
.hof-guillo .blade {
  position: absolute; top: 18px; left: 16px; right: 16px;
  height: 74px;
  background: linear-gradient(170deg, #eceff1 0%, #b0bec5 45%, #78909c 70%, #eceff1 100%);
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 100%);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .4));
  z-index: 2;
}

.hof-cracks {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.hof-cracks polyline {
  fill: none;
  stroke: #263238;
  stroke-width: 2;
  stroke-linejoin: bevel;
  vector-effect: non-scaling-stroke;
}
.hof-losers {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end;
  gap: 8px 12px;
  padding: 0 16px;
}
.hof-loser {
  background: rgba(255, 255, 255, .92); color: var(--ink);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: clamp(14px, 2.4vh, 22px); font-weight: 800;
  white-space: nowrap;
  opacity: 0; transform: translateY(14px);
  transition: opacity .35s, transform .35s;
}
.hof-loser.in { opacity: 1; transform: none; }
.hof-loser .rk { color: var(--muted); margin-right: 6px; }
.hof-floor { flex: none; display: flex; height: 14px; }
.hof-floor .flap {
  flex: 1;
  background: repeating-linear-gradient(90deg, #6d4c41 0 46px, #4e342e 46px 49px);
}

/* 1st: hall of fame */
.hof-spot {
  position: absolute; inset: -40px; z-index: 4;
  background: radial-gradient(ellipse var(--sw, 260px) var(--sh, 340px) at var(--sx, 50%) var(--sy, 50%), rgba(255, 236, 160, .15) 0 45%, rgba(0, 0, 0, .7) 75%);
  opacity: 0;
  transition: opacity 1.2s;
  pointer-events: none;
}
.hof-stage.focus .hof-spot { opacity: .65; transition: opacity .6s; }
.hof-stage.win .hof-spot { opacity: 1; }
.hof-victim { position: relative; z-index: 5; }
.hof-stage.win .r1 { z-index: 5; }
.hof-name.glory {
  border: 4px solid #ffd54f;
  animation: hof-glow 1.6s ease-in-out infinite;
}
.hof-crown {
  position: absolute; z-index: 3;
  left: 50%;
  font-size: clamp(40px, 8vh, 80px);
  line-height: 1;
  transform: translate(-50%, -100vh);
  pointer-events: none;
}
.hof-crown.drop { animation: hof-crown 1s cubic-bezier(.3, 1.4, .5, 1) forwards; }
.hof-confetti { position: absolute; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.hof-confetti i {
  position: absolute; top: -20px;
  width: 10px; height: 16px;
  border-radius: 2px;
  animation: hof-confetti linear infinite;
}

@keyframes hof-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
/* Wind up, slam down at ~62% (0.56s of 0.9s), bounce, then vanish. */
@keyframes hof-swing {
  0% { opacity: 0; transform: rotate(-60deg); }
  15% { opacity: 1; transform: rotate(-75deg); }
  45% { opacity: 1; transform: rotate(-95deg); }
  62% { opacity: 1; transform: rotate(4deg); }
  72% { opacity: 1; transform: rotate(-6deg); }
  85% { opacity: 1; transform: rotate(-2deg); }
  100% { opacity: 0; transform: rotate(-50deg); }
}
@keyframes hof-spark {
  from { transform: scale(.7); opacity: .7; }
  to { transform: scale(1.3); opacity: 1; }
}
@keyframes hof-glow {
  0%, 100% { box-shadow: 0 0 18px 4px rgba(255, 213, 79, .6); }
  50% { box-shadow: 0 0 36px 12px rgba(255, 213, 79, .95); }
}
@keyframes hof-crown {
  from { transform: translate(-50%, -100vh) rotate(-20deg); }
  to { transform: translate(-50%, -100%) rotate(-8deg); }
}
@keyframes hof-confetti {
  from { transform: translateY(0) rotate(0); }
  to { transform: translateY(110vh) rotate(720deg); }
}

.host-actions { display: flex; gap: 12px; width: 100%; max-width: 1200px; justify-content: flex-end; flex: none; }
.host-actions .restart { margin-right: auto; font-size: 16px; }
/* Test ending is local only, so hide the real-game Restart button while it plays. */
.testing-end #h-end .restart { visibility: hidden; }

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal .card { max-width: 420px; text-align: center; }
.modal-title { font-size: 22px; font-weight: 900; }
.modal-text { font-size: 16px; font-weight: 600; color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { font-size: 18px; padding: 12px 20px; }

.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  background: var(--red); color: #fff;
  padding: 14px 24px; border-radius: 6px;
  font-size: 18px; font-weight: 800;
  max-width: calc(100% - 32px);
  z-index: 100;
}
.toast[hidden] { display: none; }
.toast.ok { background: var(--ok); }

.lobby-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.lobby-info { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.lobby-bar { flex-wrap: wrap; }
.timer-set {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, .3);
  border-radius: 4px;
  padding: 6px 6px 6px 12px;
  font-size: 16px; font-weight: 800;
}
.timer-set select {
  font: inherit;
  font-size: 16px; font-weight: 800;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: #fff; color: var(--ink);
  cursor: pointer;
}

/* ---------- admin ---------- */

#a-editor.screen { justify-content: flex-start; padding-bottom: 48px; }

.ed-bar {
  position: sticky; top: 0; z-index: 5;
  width: 100%; max-width: 900px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0;
  background: var(--bg);
  text-align: left;
}
.ed-actions { display: flex; gap: 10px; }
.ed-actions .btn { font-size: 18px; padding: 10px 18px; white-space: nowrap; }

.ed-list { width: 100%; max-width: 900px; display: flex; flex-direction: column; gap: 16px; }
.ed-add { width: 100%; max-width: 900px; }

.ed-list, .ed-bar, .ed-add { max-width: 1100px; }
.ed-card {
  background: #fff; color: var(--ink);
  border-radius: 8px;
  padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px;
  text-align: left;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .25);
}
.ed-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.ed-side {
  display: flex; flex-direction: column; gap: 12px;
  background: #f4f1f8;
  border-radius: 6px;
  padding: 12px;
  min-width: 0;
}
.ed-side-title { font-size: 15px; font-weight: 900; }
.ed-field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 800; color: var(--muted); }
.ed-side select, .ed-side .ed-custom, .ed-side .ed-msg {
  font: inherit; font-size: 15px; font-weight: 700;
  color: var(--ink);
  text-align: left;
  padding: 7px 9px;
  border: 2px solid #ccc; border-radius: 4px;
  background: #fff;
  width: 100%;
}
.ed-side .ed-msg { resize: vertical; }
.ed-side .ed-custom:focus, .ed-side .ed-msg:focus { outline: none; border-color: var(--bg); }
.ed-custom[hidden], .ed-preview[hidden], .ed-note[hidden] { display: none; }
.ed-preview { font-size: 15px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; line-height: 1.5; }
.ed-hint { font-size: 12px; font-weight: 600; }
.ed-note { font-size: 13px; font-weight: 800; color: var(--bad); }

.ed-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ed-num { font-size: 20px; font-weight: 900; margin-right: 4px; }
.ed-tools { display: flex; gap: 6px; margin-left: auto; }

.ed-card select {
  font: inherit; font-weight: 700;
  padding: 6px 10px;
  border: 2px solid #ccc; border-radius: 4px;
  background: #fff;
}

.ed-q {
  font: inherit; font-size: 18px; font-weight: 700;
  padding: 10px 12px;
  border: 2px solid #ccc; border-radius: 4px;
  resize: vertical;
  width: 100%;
}
.ed-q:focus, .ed-card select:focus { outline: none; border-color: var(--bg); }

.mini {
  background: #ececec; color: var(--ink);
  font-size: 14px; font-weight: 800;
  padding: 7px 12px;
  border-radius: 4px;
  white-space: nowrap;
}
.mini:hover:not(:disabled) { background: #dcdcdc; }
.mini:disabled { opacity: .35; cursor: default; }

.ed-img {
  display: flex; align-items: center; gap: 12px;
  background: #f4f1f8;
  border: 2px dashed #d4cce0;
  border-radius: 6px;
  padding: 10px;
  min-height: 72px;
}
.ed-img img { max-height: 140px; max-width: 60%; border-radius: 4px; object-fit: contain; }
.ed-img-empty { color: var(--muted); font-weight: 700; }
.ed-img-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.ed-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ed-choice {
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
  border-radius: 6px;
  color: #fff;
  min-width: 0;
}
.ed-choice .shape { font-size: 22px; width: 24px; text-align: center; }
.ed-choice input {
  flex: 1; min-width: 0;
  font-size: 16px; font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
}
.ed-choice input:disabled { background: transparent; color: #fff; font-size: 18px; }
.ed-thumb { height: 44px; max-width: 64px; object-fit: cover; border-radius: 4px; background: #fff; }
.ed-ok {
  background: rgba(0, 0, 0, .25); color: #fff;
  font-size: 14px; font-weight: 800;
  padding: 8px 10px;
  border-radius: 4px;
  white-space: nowrap;
}
.ed-ok.on { background: #fff; color: var(--ok); }

@media (max-width: 700px) {
  .h-q { font-size: 22px; padding: 16px; }
  .h-choice { font-size: 18px; padding: 14px; }
  .h-choices { grid-template-columns: 1fr; }
  .join-banner .pin { font-size: 44px; }
  .join-banner .url { font-size: 20px; }
  .bar { width: 60px; font-size: 20px; }
  .row { font-size: 20px; }
  .ed-choices { grid-template-columns: 1fr; }
  .ed-tools { margin-left: 0; }
}

@media (max-width: 860px) {
  .ed-card { grid-template-columns: 1fr; }
}
