/* AudioQuiz — game-show design system (mobile-first) */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --cream: #fff8ee;
  --paper: #fffdf9;
  --ink: #241d3d;
  --ink-soft: #5c5478;
  --muted: #837b9b;
  --line: #ece5f6;
  --line-strong: #ddd3ee;
  --coral: #ff6b6b;
  --sun: #ffc93c;
  --teal: #2ec4b6;
  --grape: #7b61ff;
  --sky: #48b8f0;
  --good: #0fa968;
  --bad: #e8446b;
  --good-soft: #d5f8e6;
  --bad-soft: #ffdce6;
  --radius: 26px;
  --hard: 6px 6px 0 var(--ink);
  --hard-sm: 4px 4px 0 var(--ink);
  --hard-xs: 3px 3px 0 var(--ink);
  --font-body: "Noto Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, sans-serif;
  --font-display: "Mali", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  background-color: var(--cream);
  background-image:
    radial-gradient(rgba(36, 29, 61, .055) 1.2px, transparent 1.3px),
    radial-gradient(900px 620px at 8% -10%, #ffe8c9 0%, rgba(255, 232, 201, 0) 55%),
    radial-gradient(820px 560px at 104% 4%, #d9f6f0 0%, rgba(217, 246, 240, 0) 55%),
    radial-gradient(720px 540px at 50% 112%, #ffe2ef 0%, rgba(255, 226, 239, 0) 60%);
  background-size: 22px 22px, auto, auto, auto;
}

::selection { background: #ffd166; color: var(--ink); }
a { color: #5b46d6; }
:focus-visible { outline: 3px dashed var(--grape); outline-offset: 3px; border-radius: 8px; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.01em; }

/* ---------- motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.8); } 70% { transform: scale(1.05); } 100% { opacity: 1; transform: scale(1); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(var(--rot, -6deg)); } 50% { transform: translateY(-12px) rotate(calc(var(--rot, -6deg) * -1)); } }
@keyframes bounceDot { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-7px); opacity: 1; } }
@keyframes waveBar { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes confettiFall { to { transform: translate3d(var(--dx, 0), 108vh, 0) rotate(var(--rot, 600deg)); opacity: 0; } }
@keyframes popScore { 0% { transform: scale(1); } 40% { transform: scale(1.22) rotate(-3deg); } 100% { transform: scale(1); } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem;
  padding: .6rem clamp(.75rem, 3vw, 1.4rem);
  background: rgba(255, 248, 238, .92);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--ink);
  position: sticky; top: 0; z-index: 30;
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.06rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em;
}
.brand a { color: inherit; text-decoration: none; }
.brand .logo {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 12px;
  background: linear-gradient(135deg, var(--sun), var(--coral));
  font-size: 17px;
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-4deg);
}
.spacer { flex: 1; }
.topbar-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* ---------- layout ---------- */
.wrap { width: min(1120px, 100% - 2rem); margin: 1.4rem auto 2.6rem; }
.narrow { width: min(520px, 100% - 1.4rem); }
.wide { width: min(1240px, 100% - 1.4rem); }
.row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .9rem; flex-wrap: wrap; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

/* ---------- cards / ticket ---------- */
.card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: clamp(1.05rem, 2.5vw, 1.7rem);
  box-shadow: var(--hard);
  animation: fadeUp .45s cubic-bezier(.2, .7, .3, 1) both;
}
.card + .card { margin-top: 1.1rem; }
.card h2 { margin: 0 0 .75rem; font-size: 1.18rem; }

.ticket {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 24px;
  padding: clamp(1.1rem, 2.6vw, 1.7rem);
  box-shadow: var(--hard);
}
.ticket::before,
.ticket::after {
  content: "";
  position: absolute; top: calc(50% - 12px);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--ink);
}
.ticket::before { left: -14px; }
.ticket::after { right: -14px; }
.ticket-top {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding-bottom: .7rem; margin-bottom: .8rem;
  border-bottom: 2px dashed var(--line-strong);
}

.page-title { font-size: clamp(1.5rem, 3.2vw, 2.1rem); line-height: 1.2; margin: .1rem 0 .6rem; }
.q-title { font-size: clamp(1.35rem, 3.4vw, 2.2rem); line-height: 1.3; margin: .7rem 0 .9rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; word-break: break-all; }
.label { color: var(--ink-soft); font-size: .78rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.hint { color: var(--muted); font-size: .92rem; margin: .85rem 0 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .7rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 700;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--hard-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-primary { background: var(--grape); color: #fff; }
.btn-sun { background: var(--sun); color: var(--ink); }
.btn-soft { background: #efeaff; }
.btn-danger { background: #ffe1e9; color: #a5143c; }
.btn-ghost { background: var(--paper); }
.btn-lg { padding: .95rem 1.5rem; font-size: 1.08rem; border-radius: 18px; }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 11px; box-shadow: var(--hard-xs); }
.btn-sm:hover:not(:disabled) { box-shadow: 4px 4px 0 var(--ink); }
.btn-sm:active:not(:disabled) { box-shadow: 1px 1px 0 var(--ink); }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
.field { display: grid; gap: .35rem; margin-bottom: .95rem; }
.field > label { font-size: .86rem; font-weight: 700; color: var(--ink-soft); }
.input {
  width: 100%;
  padding: .8rem 1rem;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  transition: box-shadow .15s ease;
}
.input:focus { outline: none; box-shadow: 0 0 0 4px rgba(123, 97, 255, .25); }
textarea.input { min-height: 92px; resize: vertical; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 19px) 55%, calc(100% - 14px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input[type="file"].input { padding: .5rem .6rem; font-size: 15px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--grape); width: 18px; height: 18px; }

/* ---------- badges / pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .28rem .7rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff;
  font-size: .82rem; font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}
.badge-score {
  background: var(--sun);
  font-variant-numeric: tabular-nums;
  padding: .34rem .8rem; font-size: .92rem;
  font-family: var(--font-display); font-weight: 700;
}
.badge-score.bump { animation: popScore .5s ease; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .28rem .65rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff;
  font-size: .8rem; font-weight: 700; color: var(--ink-soft);
  white-space: nowrap;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink); }
.timer.expired { color: var(--bad); }

/* ---------- avatar ---------- */
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 13px;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.avatar-sm { width: 30px; height: 30px; border-radius: 10px; font-size: .8rem; }
.avatar-xs { width: 26px; height: 26px; border-radius: 9px; font-size: .74rem; }

/* ---------- PIN ---------- */
.pin {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.7rem, 8vw, 4.6rem);
  line-height: 1.05; letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 4px 4px 0 #ffd166;
  margin: .15rem 0 .4rem;
  word-break: break-all;
}
.pin-input {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.6rem; letter-spacing: .34em; text-align: center;
  font-variant-numeric: tabular-nums;
  padding: .8rem .9rem .8rem 1.2rem;
}

/* ---------- choices ---------- */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 1rem 0; }
.choice {
  position: relative;
  display: flex; align-items: center; gap: .75rem;
  width: 100%; min-height: 78px;
  padding: .9rem 1rem;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem; font-weight: 600; text-align: left;
  box-shadow: var(--hard-sm);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.choice:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.choice:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.choice:disabled { cursor: default; }
.choice .key {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 50%;
  background: #fff;
  font-family: var(--font-display); font-weight: 700;
}
.choice .label-text { flex: 1; min-width: 0; }
.choice-body { flex: 1; min-width: 0; }
.choice-body .label-text { display: block; }
.choice img { width: 58px; height: 58px; object-fit: cover; border-radius: 12px; border: 2px solid var(--ink); flex: 0 0 auto; }

.choices > .choice:nth-child(4n+1) { background: #ffe3e0; }
.choices > .choice:nth-child(4n+2) { background: #e0f2ff; }
.choices > .choice:nth-child(4n+3) { background: #ddf7f0; }
.choices > .choice:nth-child(4n+4) { background: #fff0c9; }

.choice.picked { box-shadow: 0 0 0 4px var(--grape), var(--hard-sm); }
.choice.picked::after {
  content: "✓";
  position: absolute; top: -.65rem; right: -.45rem;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--grape); color: #fff;
  font-size: .8rem; font-weight: 800;
}
.choices > .choice.correct { background: var(--good-soft); box-shadow: 0 0 0 4px rgba(15, 169, 104, .28), var(--hard-sm); }
.choices > .choice.correct::before {
  content: "✓";
  position: absolute; top: -.65rem; right: -.45rem;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--good); color: #fff;
  font-size: .8rem; font-weight: 800;
}
.choices > .choice.wrong { background: var(--bad-soft); box-shadow: 0 0 0 4px rgba(232, 68, 107, .22), var(--hard-sm); }
.choices > .choice.dim { opacity: .45; box-shadow: 2px 2px 0 var(--ink); }
.choice .count-num { font-family: var(--font-body); font-size: .78rem; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.choice .mini-bar { display: block; height: 8px; width: 100%; margin-top: .4rem; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.choice .mini-bar i { display: block; height: 100%; background: var(--teal); transition: width .5s ease; }

/* ---------- timer / progress ---------- */
.timebar { height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; margin: .4rem 0 .9rem; }
.timebar > span { display: block; height: 100%; width: 100%; background: var(--teal); transition: width .2s linear; }
.timebar.low > span { background: var(--coral); }
.q-progress { height: 10px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.q-progress > span { display: block; height: 100%; background: var(--grape); transition: width .4s ease; }

.ladder { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.ladder i {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff;
  transition: transform .2s ease, background .2s ease;
}
.ladder i.done { background: var(--grape); }
.ladder i.now { background: var(--sun); transform: scale(1.35); }

.ring {
  --p: 100;
  position: relative;
  width: 76px; height: 76px; flex: 0 0 auto;
  margin-left: auto;
  border: 3px solid var(--ink); border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--grape) calc(var(--p) * 1%), #fff0c9 0);
  box-shadow: var(--hard-xs);
  transition: background .2s linear;
}
.ring::before {
  content: ""; position: absolute; inset: 6px;
  border-radius: 50%; background: #fff;
}
.ring .timer { position: relative; font-family: var(--font-display); font-size: 1.02rem; }
.ring.low { background: conic-gradient(var(--coral) calc(var(--p) * 1%), #ffe1e6 0); }

/* ---------- audio wave ---------- */
.audio-row { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; margin-bottom: .3rem; }
.wave { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.wave i {
  display: block; width: 4px; height: 100%;
  border: 1.5px solid var(--ink); border-radius: 3px;
  background: var(--sun); opacity: .4;
  transform-origin: bottom;
  animation: waveBar 1s ease-in-out infinite;
}
.wave i:nth-child(2) { animation-delay: .12s; }
.wave i:nth-child(3) { animation-delay: .24s; }
.wave i:nth-child(4) { animation-delay: .36s; }
.wave i:nth-child(5) { animation-delay: .48s; }
.wave.playing i { opacity: 1; background: var(--teal); }
.wave:not(.playing) i { animation-play-state: paused; transform: scaleY(.3); }

/* ---------- result ---------- */
.result-banner {
  display: flex; align-items: center; gap: .7rem;
  padding: .9rem 1.1rem; margin: 1rem 0;
  border: 2px solid var(--ink); border-radius: 18px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  box-shadow: var(--hard-sm);
  animation: popIn .4s both;
}
.result-banner .banner-emoji { font-size: 1.6rem; line-height: 1; }
.result-banner.good { background: var(--good-soft); }
.result-banner.bad { background: var(--bad-soft); }
.result-banner.neutral { background: #fff0c9; }
.q-image { max-width: 100%; max-height: 280px; border: 2px solid var(--ink); border-radius: 16px; margin-bottom: .5rem; }

/* ---------- board ---------- */
.board { list-style: none; padding: 0; margin: 1.1rem 0; display: grid; gap: .5rem; }
.board li {
  display: grid; grid-template-columns: 2.2rem 1fr 140px 4.2rem;
  gap: .7rem; align-items: center;
  padding: .6rem .85rem;
  border: 2px solid var(--ink); border-radius: 16px;
  background: #fff;
  box-shadow: var(--hard-xs);
  animation: fadeUp .4s both;
}
.board li:nth-child(1) { background: #fff3cd; }
.board li:nth-child(2) { background: #f1f3f9; }
.board li:nth-child(3) { background: #ffe9db; }
.board li.me { background: #efeaff; box-shadow: 0 0 0 4px rgba(123, 97, 255, .22), var(--hard-xs); }
.board .rank { font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; text-align: center; }
.board .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .bar { height: 12px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.board .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), var(--grape)); transition: width .6s ease; }
.board .pts { text-align: right; font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- host ---------- */
.host-q .q-top { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.lobby { position: relative; overflow: hidden; text-align: center; }
.lobby > * { position: relative; z-index: 1; }
.lobby-top { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; text-align: left; }
.lobby-top .pin { text-align: left; }
.lobby-count {
  display: grid; justify-items: center; gap: .05rem;
  padding: .55rem 1rem;
  border: 2px solid var(--ink); border-radius: 18px;
  background: #fff0c9; box-shadow: var(--hard-xs);
}
.count-big { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.copy-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.avatar-grid { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: center; margin: 1.1rem 0; min-height: 44px; }
.player-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .7rem .25rem .25rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff; box-shadow: 2px 2px 0 var(--ink);
  font-weight: 700; font-size: .88rem;
  animation: popIn .35s both;
}

/* ---------- player ---------- */
.play-wrap { width: min(580px, 100% - 1.2rem); margin: .9rem auto calc(2rem + env(safe-area-inset-bottom)); }
.play-wrap .choices { grid-template-columns: 1fr; }
.play-wrap .choice { min-height: 76px; }
.lobby-emoji { font-size: 3.2rem; line-height: 1; margin-bottom: .3rem; }
.dots { display: inline-flex; gap: .35rem; margin-top: 1rem; }
.dots i { width: 10px; height: 10px; border: 2px solid var(--ink); border-radius: 50%; background: var(--grape); opacity: .4; animation: bounceDot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

/* ---------- toast / confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: .7rem 1.05rem;
  border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: 4px 4px 0 rgba(36, 29, 61, .35);
  z-index: 70; max-width: min(90vw, 420px); font-size: .9rem;
  animation: fadeUp .25s both;
}
.toast[hidden] { display: none; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -16px; width: 10px; height: 15px; border: 2px solid var(--ink); border-radius: 3px; opacity: .95; animation: confettiFall var(--dur, 1.9s) cubic-bezier(.3, .6, .4, 1) forwards; }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 2rem; align-items: center; padding: .4rem 0 .8rem; }
.hero-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .8rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff; box-shadow: var(--hard-xs);
  font-size: .82rem; font-weight: 700;
  transform: rotate(-2deg);
}
.hero h1 { font-size: clamp(2.35rem, 6vw, 3.8rem); line-height: 1.08; margin: .85rem 0 .7rem; }
.hero h1 .hl { background: linear-gradient(180deg, transparent 58%, #ffd166 58%, #ffd166 92%, transparent 92%); padding: 0 .08em; }
.hero p { color: var(--ink-soft); font-size: 1.02rem; max-width: 34ch; margin: 0 0 1.2rem; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 350px; }
.hero-join { width: min(360px, 100%); }
.hero-join h2 { margin: .1rem 0 .9rem; font-size: 1.35rem; }
.float-card {
  position: absolute; z-index: 0;
  width: 70px; height: 70px;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 20px;
  background: #fff; box-shadow: var(--hard-sm);
  font-size: 31px;
  animation: floaty 6.5s ease-in-out infinite;
}
.fc-1 { top: 0; left: 1%; --rot: -8deg; }
.fc-2 { top: 22%; right: 0; --rot: 7deg; animation-delay: -1.6s; }
.fc-3 { bottom: 6%; left: -2%; width: 60px; height: 60px; font-size: 26px; --rot: 5deg; animation-delay: -3.2s; }
.fc-4 { bottom: 0; right: 12%; width: 54px; height: 54px; font-size: 24px; --rot: -6deg; animation-delay: -4.8s; }

.marquee {
  overflow: hidden;
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
  background: var(--sun);
  margin-top: 1.6rem;
}
.marquee-track { display: flex; width: max-content; animation: marquee 26s linear infinite; }
.marquee-group { display: flex; align-items: center; gap: 2.2rem; padding: .55rem 1.1rem; white-space: nowrap; font-family: var(--font-display); font-weight: 700; font-size: .95rem; }
.marquee-group span { display: inline-flex; align-items: center; gap: .4rem; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; margin-top: 1.8rem; }
.step {
  padding: 1.1rem;
  border: 2px solid var(--ink); border-radius: 20px;
  background: var(--paper); box-shadow: var(--hard-xs);
}
.step:nth-child(1) { transform: rotate(-.7deg); }
.step:nth-child(2) { transform: rotate(.5deg); }
.step:nth-child(3) { transform: rotate(-.4deg); }
.step-num {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; margin-bottom: .5rem;
  border: 2px solid var(--ink); border-radius: 10px;
  background: var(--sun);
  font-family: var(--font-display); font-weight: 700;
  box-shadow: 2px 2px 0 var(--ink);
}
.step h3 { margin: 0 0 .2rem; font-size: 1rem; }
.step p { margin: 0; color: var(--ink-soft); font-size: .88rem; }

/* ---------- auth ---------- */
.auth-wrap { width: min(440px, 100% - 1.2rem); margin: clamp(1.6rem, 7vh, 4rem) auto 3rem; }
.auth-brand {
  display: flex; justify-content: center; align-items: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  margin-bottom: 1rem;
}
.auth-brand .logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 13px;
  background: linear-gradient(135deg, var(--sun), var(--coral));
  box-shadow: var(--hard-xs); transform: rotate(-4deg);
}
.auth-icon { font-size: 2.3rem; line-height: 1; margin-bottom: .3rem; }

/* ---------- admin ---------- */
.admin-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 1rem; align-items: start; }
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; margin-top: 1rem; }
.quiz-card {
  display: grid; gap: .75rem;
  padding: 1rem;
  border: 2px solid var(--ink); border-radius: 20px;
  background: var(--paper); box-shadow: var(--hard-xs);
  transition: transform .14s ease, box-shadow .14s ease;
}
.quiz-card:hover { transform: translate(-1px, -1px); box-shadow: var(--hard-sm); }
.quiz-card-top { display: flex; gap: .65rem; align-items: center; }
.quiz-emoji {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 13px;
  background: #fff0c9; font-size: 20px;
}
.quiz-card:nth-child(3n+2) .quiz-emoji { background: #e0f2ff; }
.quiz-card:nth-child(3n+3) .quiz-emoji { background: #ddf7f0; }
.quiz-title { display: block; font-family: var(--font-display); font-weight: 700; color: var(--ink); text-decoration: none; line-height: 1.3; }
.quiz-title:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .65rem .45rem; border-bottom: 2px solid var(--line); vertical-align: middle; }
.table th { color: var(--ink-soft); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: 0; }

.q-item {
  display: flex; gap: .7rem; justify-content: space-between; align-items: flex-start;
  padding: .85rem;
  border: 2px solid var(--line-strong); border-radius: 18px;
  background: var(--paper); margin-bottom: .55rem;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.q-item:hover { border-color: var(--ink); box-shadow: var(--hard-xs); transform: translateY(-1px); }
.q-item .q-main { min-width: 0; }
.q-item .q-actions { display: flex; gap: .35rem; flex: 0 0 auto; flex-wrap: wrap; }
.q-meta { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.thumb { width: 42px; height: 42px; object-fit: cover; border: 2px solid var(--ink); border-radius: 10px; }
.choice-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center;
  padding: .6rem;
  border: 2px solid var(--line-strong); border-radius: 14px;
  margin-bottom: .45rem; background: #fff;
}
.choice-row .file-cell { width: 11rem; }
.audio-preview { width: 100%; margin-top: .4rem; }
.divider { height: 2px; background: var(--line); margin: .9rem 0; border-radius: 2px; }
.notice { padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: 14px; margin-bottom: .9rem; font-size: .92rem; box-shadow: var(--hard-xs); }
.notice.ok { background: var(--good-soft); }
.notice.err { background: var(--bad-soft); }

/* ---------- misc ---------- */
.spinner {
  width: 32px; height: 32px; margin: 0 auto .9rem;
  border: 3px solid var(--line-strong);
  border-top-color: var(--grape);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-grid > div:last-child { order: -1; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 1.3rem; }
  .hero-art { min-height: 0; padding: 1rem 0; }
  .float-card { display: none; }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .topbar { padding: .5rem .7rem; gap: .45rem; }
  .brand { font-size: .98rem; }
  .brand .logo { width: 32px; height: 32px; font-size: 15px; }
  .wrap { width: calc(100% - 1.2rem); margin: .9rem auto 2rem; }
  .card, .ticket { padding: 1.05rem; border-radius: 22px; }
  .card { box-shadow: 4px 4px 0 var(--ink); }
  .hero h1 { font-size: 2.3rem; }
  .hero p { font-size: .98rem; }
  .choices { grid-template-columns: 1fr; gap: .6rem; }
  .choice { min-height: 72px; padding: .8rem .9rem; font-size: .98rem; }
  .choice .key { width: 34px; height: 34px; }
  .lobby-top { grid-template-columns: 1fr; text-align: center; }
  .lobby-top .pin { text-align: center; }
  .lobby-count { justify-self: center; }
  .btn { padding: .65rem 1rem; }
  .btn-lg { padding: .85rem 1.15rem; font-size: 1.02rem; }
  .board li { grid-template-columns: 1.8rem 1fr 3.6rem; }
  .board .bar { display: none; }
  .q-title { font-size: 1.28rem; }
  .ring { width: 62px; height: 62px; }
  .ring .timer { font-size: .9rem; }
  .play-wrap { width: calc(100% - 1rem); margin-top: .7rem; }
  .quiz-grid { grid-template-columns: 1fr; }
  .q-item { flex-direction: column; }
  .q-item .q-actions { width: 100%; }
  .choice-row { grid-template-columns: auto 1fr; }
  .choice-row .file-cell { grid-column: 2; width: auto; }
  .marquee-group { font-size: .86rem; gap: 1.5rem; }
  .table th, .table td { padding: .55rem .35rem; }
  .ticket::before, .ticket::after { width: 18px; height: 18px; top: calc(50% - 9px); }
  .ticket::before { left: -9px; }
  .ticket::after { right: -9px; }
}

@media (max-width: 400px) {
  .topbar-meta .btn { padding: .3rem .55rem; font-size: .8rem; }
  .hero h1 { font-size: 2rem; }
  .pin { letter-spacing: .06em; }
  .pin-input { letter-spacing: .22em; font-size: 1.4rem; }
  .badge { font-size: .76rem; }
  .choice { min-height: 66px; }
  .results .choice { min-height: 62px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- mascot: น้องเสียง (admin) ---------- */
.mascot {
  position: relative; flex: 0 0 auto;
  width: 44px; height: 44px; padding: 0;
  display: grid; place-items: center;
  border: 0; background: none; border-radius: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mascot:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
.mascot svg { width: 44px; height: 44px; display: block; overflow: visible; }
.m-body { transform-box: fill-box; transform-origin: center bottom; animation: mBob 3.4s ease-in-out infinite; }
.m-antenna { transform-box: fill-box; transform-origin: center bottom; animation: mNote 2.8s ease-in-out infinite; }
.m-eyes { transform-box: fill-box; transform-origin: center; animation: mBlink 5.4s infinite; }
.mascot:hover .m-body { animation-duration: 1.5s; }
.mascot:hover .m-antenna { animation-duration: 1.2s; }
.mascot.is-happy .m-body { animation: mHop .65s cubic-bezier(.3, .7, .4, 1); }

@keyframes mBob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-2px) rotate(2deg); }
}
@keyframes mNote {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
}
@keyframes mBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(.12); }
}
@keyframes mHop {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-9px) scale(1.06, .94) rotate(-6deg); }
  60% { transform: translateY(0) scale(.96, 1.04) rotate(4deg); }
  100% { transform: none; }
}

.mascot-bubble {
  position: absolute; left: -6px; top: calc(100% + 10px); z-index: 60;
  width: max-content; max-width: min(250px, 72vw);
  padding: .4rem .65rem;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 14px;
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-display); font-size: .82rem; line-height: 1.35; color: var(--ink);
  opacity: 0; transform: translateY(-4px) scale(.94); transform-origin: top left;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.mascot-bubble::before {
  content: ""; position: absolute; top: -6px; left: 14px;
  width: 10px; height: 10px; background: var(--paper);
  border-left: 2px solid var(--ink); border-top: 2px solid var(--ink);
  transform: rotate(45deg);
}
.mascot-bubble.is-on { opacity: 1; transform: none; }

@media (max-width: 700px) {
  .mascot, .mascot svg { width: 38px; height: 38px; }
  .mascot-bubble { font-size: .78rem; }
}
