/* ============================================================
   Baht Buddies — shared styles (landing + player + admin)
   Bright, chunky, kid-friendly "sticker" design.
   ============================================================ */
:root {
  --ink: #26243a;
  --paper: #fff8ec;
  --card: #ffffff;
  --coral: #ff6b6b;
  --teal: #29c7b0;
  --yellow: #ffd93d;
  --purple: #9b7bff;
  --green: #58c471;
  --blue: #4dabf7;
  --red: #ff5252;
  --shadow: 0 6px 0 rgba(38, 36, 58, .9);
  --radius: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(41, 199, 176, .14) 0 9vmin, transparent 9.5vmin),
    radial-gradient(circle at 88% 12%, rgba(255, 217, 61, .20) 0 7vmin, transparent 7.5vmin),
    radial-gradient(circle at 82% 84%, rgba(255, 107, 107, .13) 0 10vmin, transparent 10.5vmin),
    radial-gradient(circle at 8% 88%, rgba(155, 123, 255, .14) 0 8vmin, transparent 8.5vmin),
    var(--paper);
  min-height: 100vh;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 16px 16px 40px; }
.hidden { display: none !important; }

/* ---------- generic bits ---------- */
.card {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: clamp(26px, 5vw, 40px); letter-spacing: .5px; }
h2 { font-size: clamp(20px, 3.4vw, 27px); }

.muted { opacity: .68; font-weight: 600; }
.small { font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 800; font-size: 17px;
  color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 16px;
  padding: 12px 20px; cursor: pointer; user-select: none;
  box-shadow: 0 5px 0 rgba(38, 36, 58, .9);
  transition: transform .06s ease, box-shadow .06s ease, background .15s ease;
}
.btn:hover { background: #fffdf5; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(38, 36, 58, .9); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }

.btn-coral   { background: var(--coral); color: #fff; }
.btn-teal    { background: var(--teal);  color: #fff; }
.btn-yellow  { background: var(--yellow); }
.btn-purple  { background: var(--purple); color: #fff; }
.btn-green   { background: var(--green); color: #fff; }
.btn-big     { font-size: 21px; padding: 16px 30px; border-radius: 20px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 4px 13px; font-weight: 800; font-size: 14px;
}

.badge {
  display: inline-block; padding: 3px 12px; border-radius: 999px;
  border: 2.5px solid var(--ink); font-weight: 800; font-size: 13px;
}
.badge-buzz     { background: var(--yellow); }
.badge-answer   { background: #ffd6a5; }
.badge-reveal   { background: #c3fae8; }
.badge-over     { background: #d0bfff; }
.badge-countdown{ background: #ffe0ef; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.logo { font-size: 22px; font-weight: 900; letter-spacing: .3px; }
.logo .flag { margin-right: 6px; }

.iconbtn {
  width: 46px; height: 46px; border-radius: 14px;
  border: 3px solid var(--ink); background: #fff; cursor: pointer;
  font-size: 20px; box-shadow: 0 4px 0 rgba(38,36,58,.9);
}
.iconbtn:active { transform: translateY(3px); box-shadow: none; }

/* ---------- join screen ---------- */
.join-card { max-width: 480px; margin: 5vh auto 0; text-align: center; }
.mascot-row { font-size: clamp(40px, 9vw, 62px); letter-spacing: 8px; margin-bottom: 4px; }

.field { text-align: left; margin-top: 16px; }
.field label { display: block; font-weight: 800; margin-bottom: 6px; font-size: 15px; }
.input {
  width: 100%; font-family: inherit; font-weight: 800; font-size: 24px;
  padding: 13px 16px; border: 3px solid var(--ink); border-radius: 16px;
  background: #fffdf5; color: var(--ink); outline: none; letter-spacing: 2px;
}
.input:focus { box-shadow: 0 0 0 4px rgba(255, 217, 61, .55); }
.code-input { text-transform: uppercase; text-align: center; font-size: 32px; letter-spacing: 10px; }

.role-toggle { display: flex; gap: 10px; margin-top: 18px; }
.role-toggle button {
  flex: 1; font-family: inherit; font-weight: 800; font-size: 16px; cursor: pointer;
  border: 3px solid var(--ink); border-radius: 16px; padding: 12px 8px; background: #fff;
  box-shadow: 0 4px 0 rgba(38,36,58,.9); transition: transform .06s ease;
}
.role-toggle button:active { transform: translateY(3px); box-shadow: none; }
.role-toggle button.active { background: var(--yellow); }

.join-error {
  margin-top: 14px; padding: 10px 14px; border-radius: 14px;
  background: #ffe3e3; border: 2.5px solid var(--red); color: #a12626;
  font-weight: 800; display: none;
}

/* ---------- lobby ---------- */
.lobby-card { max-width: 640px; margin: 4vh auto 0; text-align: center; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.pchip .dot { width: 10px; height: 10px; border-radius: 50%; background: #ccc; border: 2px solid var(--ink); }
.pchip .dot-on  { background: var(--green); }
.pchip .dot-off { background: #e3b7b7; }

/* ---------- countdown overlay ---------- */
.countdown-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(38, 36, 58, .82); color: #fff; text-align: center;
}
.countdown-overlay .num {
  font-size: clamp(120px, 34vw, 260px); font-weight: 900; line-height: 1;
  animation: pop .9s ease infinite;
}
.countdown-overlay .lbl { font-size: clamp(20px, 5vw, 34px); font-weight: 800; margin-top: 6px; }
@keyframes pop {
  0%   { transform: scale(.4); opacity: 0; }
  35%  { transform: scale(1.12); opacity: 1; }
  70%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(.96); opacity: .85; }
}

/* ---------- round stage ---------- */
.round-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.stage-card { position: relative; max-width: 640px; margin: 0 auto; text-align: center; overflow: hidden; min-height: 300px; }
.q-emoji { font-size: clamp(72px, 18vw, 120px); line-height: 1.15; display: block; }
.q-name  { font-size: clamp(24px, 6vw, 38px); font-weight: 900; margin-top: 6px; }
.q-thai  { font-size: clamp(17px, 4vw, 24px); font-weight: 700; opacity: .75; }
.q-note  { margin-top: 8px; }

.target-banner {
  display: inline-block; margin-top: 12px; padding: 8px 22px; border-radius: 999px;
  background: var(--yellow); border: 3px solid var(--ink); font-weight: 900; font-size: clamp(18px, 4.5vw, 26px);
}

/* timer ring */
.ring-wrap { position: absolute; top: 10px; right: 10px; width: 76px; height: 76px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #e8e4f2; stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--green); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .2s linear, stroke .3s ease; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 900; }

/* zones */
.zone { max-width: 640px; margin: 18px auto 0; text-align: center; }

.buzz-btn {
  width: min(320px, 80vw); height: min(320px, 80vw); border-radius: 50%;
  font-family: inherit; font-size: clamp(34px, 9vw, 56px); font-weight: 900; color: #fff;
  background: radial-gradient(circle at 32% 28%, #ff9d9d, var(--coral) 62%);
  border: 6px solid var(--ink); cursor: pointer; user-select: none; touch-action: manipulation;
  box-shadow: 0 12px 0 rgba(38,36,58,.9), inset 0 -14px 0 rgba(0,0,0,.14);
  transition: transform .07s ease, box-shadow .07s ease;
}
.buzz-btn:active { transform: translateY(9px) scale(.98); box-shadow: 0 3px 0 rgba(38,36,58,.9), inset 0 -14px 0 rgba(0,0,0,.14); }

.sitout-box {
  max-width: 520px; margin: 18px auto 0; padding: 18px; border-radius: var(--radius);
  background: #efeaff; border: 3px dashed var(--purple); font-weight: 800; font-size: 18px; text-align: center;
}

.choice-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 6px; }
.choice-btn {
  min-width: 130px; padding: 18px 22px; font-family: inherit; font-size: 26px; font-weight: 900;
  border: 3.5px solid var(--ink); border-radius: 18px; background: #fff; cursor: pointer;
  box-shadow: 0 5px 0 rgba(38,36,58,.9); transition: transform .06s ease, box-shadow .06s ease;
}
.choice-btn:hover { background: #fffdf2; }
.choice-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(38,36,58,.9); }

.wait-box { font-size: 20px; font-weight: 800; padding: 22px; background: #fff; border-radius: var(--radius); border: 3px solid var(--ink); box-shadow: var(--shadow); }
.thinking-dots::after { content: '…'; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* answer countdown bar (buzzer only) */
.answer-bar-wrap { max-width: 640px; margin: 14px auto 0; height: 22px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.answer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); transition: width .2s linear; }

/* ---------- count & pay board ---------- */
.pay-board { max-width: 640px; margin: 14px auto 0; text-align: center; }
.shelf { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 14px; background: #fffdf5; border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }

.money-btn { position: relative; cursor: pointer; transition: transform .08s ease; touch-action: manipulation; }
.money-btn:hover { transform: translateY(-4px) rotate(-2deg); }
.money-btn:active { transform: translateY(1px) scale(.97); }

.coin {
  width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; color: #4a3208; position: relative;
  border: 3px solid rgba(0,0,0,.28);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), inset 0 4px 0 rgba(255,255,255,.35), 0 4px 0 rgba(38,36,58,.55);
}
.coin::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; border: 2px dashed rgba(0,0,0,.18); }
.coin .val { font-size: 24px; z-index: 1; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
.coin-1   { background: radial-gradient(circle at 32% 28%, #e0a878, #b06f3d 70%); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.coin-5   { background: radial-gradient(circle at 32% 28%, #ffe9a3, #d9b23c 70%); }
.coin-10  { background: radial-gradient(circle at 32% 28%, #fff3c4 0 52%, #cfd6dd 53% 100%); }

.note {
  width: 96px; height: 52px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 900; color: #fff; position: relative; text-shadow: 0 1px 2px rgba(0,0,0,.45);
  border: 3px solid rgba(0,0,0,.3);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), inset 0 4px 0 rgba(255,255,255,.25), 0 4px 0 rgba(38,36,58,.55);
}
.note::before { content: ''; position: absolute; inset: 5px; border-radius: 6px; border: 2px dashed rgba(255,255,255,.4); }
.note .val { font-size: 20px; z-index: 1; }
.note-20  { background: linear-gradient(135deg, #6d8fc7, #3f5f96); }
.note-50  { background: linear-gradient(135deg, #cf6a6a, #9e3d3d); }
.note-100 { background: linear-gradient(135deg, #5fae7c, #2f7a4b); }

.money-label { display: block; margin-top: 4px; font-size: 12px; font-weight: 800; opacity: .7; }

.tray {
  min-height: 64px; margin-top: 12px; padding: 10px; border-radius: var(--radius);
  background: #fff; border: 3px dashed var(--ink); display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
}
.tray .empty { opacity: .5; font-weight: 700; }
.tray-chip {
  position: relative; border: 2.5px solid var(--ink); border-radius: 12px; background: #fffdf5;
  padding: 6px 10px; font-weight: 900; font-size: 15px; cursor: pointer; box-shadow: 0 3px 0 rgba(38,36,58,.7);
}
.tray-chip small { display: block; font-size: 11px; opacity: .65; }
.pay-row { display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.total-chip { font-size: 24px; padding: 8px 20px; background: var(--teal); color: #fff; border-color: var(--ink); }

/* ---------- reveal ---------- */
.reveal-card { max-width: 640px; margin: 16px auto 0; text-align: center; padding: 22px; }
.verdict { font-size: clamp(20px, 5vw, 30px); font-weight: 900; margin-bottom: 8px; }
.verdict-good { color: #1c7c46; }
.verdict-bad  { color: #b3372f; }
.r-price { font-size: clamp(30px, 8vw, 52px); font-weight: 900; background: var(--yellow); display: inline-block; padding: 6px 26px; border-radius: 18px; border: 3.5px solid var(--ink); box-shadow: var(--shadow); }
.pts { margin-top: 10px; font-weight: 900; font-size: 18px; }
.pts-plus  { color: #1c7c46; }
.pts-minus { color: #b3372f; }

.shake { animation: shake .5s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(9px) rotate(1deg); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(5px); }
}

/* ---------- game over ---------- */
.over-card { max-width: 620px; margin: 4vh auto 0; text-align: center; }
.rank-list, .lb-list { list-style: none; margin: 10px 0 0; padding: 0; }
.rank-list li, .lb-list li {
  display: flex; justify-content: space-between; gap: 10px; font-weight: 800; font-size: 17px;
  padding: 9px 14px; border-bottom: 2px solid #eee6f5;
}
.rank-list li.me, .lb-list li.me { background: #fff7d6; border-radius: 10px; }

/* ---------- spectator banner ---------- */
.spec-banner {
  max-width: 640px; margin: 0 auto 12px; padding: 8px 16px; text-align: center;
  background: #e3f2ff; border: 3px solid var(--blue); color: #1d4f7c; border-radius: 999px; font-weight: 800;
}

/* ---------- toast & confetti ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 99;
  background: var(--ink); color: #fff; font-weight: 800; padding: 12px 22px; border-radius: 999px;
  display: none; max-width: 90vw; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.confetti-piece { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 98; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ============================================================
   Landing page
   ============================================================ */
.hero { position: relative; overflow: hidden; text-align: center; padding: 46px 18px 34px; }
.hero h1 { font-size: clamp(38px, 9vw, 72px); margin-bottom: 6px; }
.hero .tagline { font-size: clamp(17px, 3.6vw, 24px); font-weight: 700; opacity: .85; max-width: 640px; margin: 0 auto 22px; }
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.float-coin { position: absolute; opacity: .5; animation: floaty 5s ease-in-out infinite; pointer-events: none; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-22px) rotate(8deg); } }

.section { margin-top: 34px; }
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.step-card .step-num {
  width: 42px; height: 42px; border-radius: 50%; background: var(--yellow); border: 3px solid var(--ink);
  display: grid; place-items: center; font-weight: 900; font-size: 20px; margin-bottom: 10px; box-shadow: 0 4px 0 rgba(38,36,58,.8);
}

.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.money-photo { border-radius: var(--radius); overflow: hidden; border: 3px solid var(--ink); box-shadow: var(--shadow); background: #fff; }
.money-photo img { width: 100%; height: 210px; object-fit: cover; display: block; }
.money-photo figcaption { padding: 10px 14px; font-weight: 800; text-align: center; background: #fffdf5; }

.denom-legend { display: flex; gap: 14px; justify-content: center; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; padding: 16px; background: #fff; border-radius: var(--radius); border: 3px solid var(--ink); box-shadow: var(--shadow); }

.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.rule-card { text-align: center; font-weight: 800; }
.rule-card .big { font-size: 34px; font-weight: 900; display: block; margin-bottom: 4px; }

/* ============================================================
   Admin console (teacher) — separate interface from gameplay
   ============================================================ */
.admin-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

.setup-row { margin-bottom: 14px; }
.setup-row label { display: block; font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.setup-row select, .setup-row input[type=number] {
  width: 100%; font-family: inherit; font-weight: 800; font-size: 17px; padding: 10px 12px;
  border: 3px solid var(--ink); border-radius: 14px; background: #fffdf5; color: var(--ink);
}
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row input[type=range] { flex: 1; accent-color: var(--teal); height: 28px; }
.range-val { min-width: 56px; text-align: center; font-weight: 900; font-size: 17px; background: #fff; border: 2.5px solid var(--ink); border-radius: 10px; padding: 4px 8px; }

.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-pick button {
  font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; text-align: left;
  border: 3px solid var(--ink); border-radius: 14px; padding: 12px; background: #fff; box-shadow: 0 4px 0 rgba(38,36,58,.8);
}
.mode-pick button.active { background: var(--teal); color: #fff; }
.mode-pick small { display: block; font-weight: 700; opacity: .75; margin-top: 2px; }

.big-code {
  text-align: center; font-size: clamp(34px, 6vw, 52px); letter-spacing: 12px; font-weight: 900;
  background: var(--yellow); border: 3.5px solid var(--ink); border-radius: 18px; padding: 12px 8px; margin: 14px 0;
  box-shadow: var(--shadow); user-select: all;
}

.live-table { width: 100%; border-collapse: collapse; font-weight: 800; }
.live-table th, .live-table td { padding: 8px 10px; text-align: left; border-bottom: 2px solid #eee6f5; }
.live-table tr.me-row { background: #fff7d6; }

.admin-round-card { margin-top: 14px; }
.teacher-hint { display: inline-block; margin-left: 8px; padding: 3px 12px; border-radius: 999px; background: #ffe0ef; border: 2.5px solid var(--ink); font-weight: 900; font-size: 14px; }

.feed { list-style: none; margin: 10px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.feed li { padding: 7px 10px; border-bottom: 2px solid #f0eaf8; font-weight: 700; font-size: 14.5px; }

.ws-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; background: #ccc; border: 2px solid var(--ink); }
.ws-dot.on { background: var(--green); }
