/* =========================================================
   หมากฮอสไทย — ธีมพรีเมียม (โทนมืด ไม้ + ทอง)
   ========================================================= */
:root {
  --bg: #120d09;
  --bg-2: #1c140e;
  --surface: rgba(255, 244, 228, 0.05);
  --surface-2: rgba(255, 244, 228, 0.09);
  --border: rgba(255, 230, 190, 0.12);
  --border-strong: rgba(232, 182, 90, 0.45);
  --text: #f6ecdd;
  --muted: #b2a08b;
  --gold: #e8b65a;
  --gold-2: #c98d2e;
  --gold-soft: rgba(232, 182, 90, 0.16);
  --danger: #ff6b5b;
  --ok: #5fe0a0;

  /* กระดาน (เปลี่ยนตามธีม) */
  --light-sq: #ecd3a8;
  --dark-sq: #9b6438;
  --frame-1: #6b4220;
  --frame-2: #3a2210;
  --coord-on-light: #9b6438;
  --coord-on-dark: #ecd3a8;

  --last: rgba(255, 220, 120, 0.32);
  --select: rgba(255, 214, 10, 0.5);
  --target: rgba(95, 224, 160, 0.9);
  --capture: rgba(255, 90, 70, 0.95);
  --radius: 18px;
  color-scheme: dark;
}

[data-theme='jade'] {
  --light-sq: #e6eedc;
  --dark-sq: #3f7a5e;
  --frame-1: #2f5a45;
  --frame-2: #142a20;
  --coord-on-light: #3f7a5e;
  --coord-on-dark: #e6eedc;
}
[data-theme='midnight'] {
  --light-sq: #c8d2e4;
  --dark-sq: #33466b;
  --frame-1: #2a3958;
  --frame-2: #0f1626;
  --coord-on-light: #33466b;
  --coord-on-dark: #c8d2e4;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  font-family: 'Kanit', 'Leelawadee UI', 'Tahoma', sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(232, 182, 90, 0.16), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(155, 100, 56, 0.14), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ---------- ปุ่ม ---------- */
.btn {
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #f3c873, var(--gold-2));
  border-color: transparent;
  color: #2a1a08;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(232, 182, 90, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 18px; font-size: 1.1rem; }

.icon-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1.15rem;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn svg { width: 20px; height: 20px; }

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px;
}
.link-btn:hover { color: var(--gold); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); margin: 10px 0 0; text-align: center; }
.label { display: block; font-size: 0.9rem; color: var(--muted); margin: 16px 0 8px; }

/* =========================================================
   เมนูหลัก
   ========================================================= */
.hero { text-align: center; padding: 8px 0 0; }

.hero-board-wrap {
  perspective: 900px;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: -18px;
}
.hero-board {
  width: 230px;
  height: 230px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 8px solid var(--frame-1);
  border-radius: 8px;
  transform: rotateX(52deg) rotateZ(-28deg);
  box-shadow: 0 0 0 2px rgba(232, 182, 90, 0.5), 0 40px 60px rgba(0, 0, 0, 0.7);
  animation: heroFloat 6s ease-in-out infinite;
  transform-style: preserve-3d;
}
.hero-board .hc { display: flex; align-items: center; justify-content: center; }
.hero-board .hc.l { background: var(--light-sq); }
.hero-board .hc.d { background: var(--dark-sq); }
.hero-board .hp {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  transform: translateZ(4px);
}
.hero-board .hp.bounce { animation: heroHop 3s ease-in-out infinite; }
@keyframes heroFloat {
  0%, 100% { transform: rotateX(52deg) rotateZ(-28deg) translateY(0); }
  50% { transform: rotateX(52deg) rotateZ(-24deg) translateY(-8px); }
}
@keyframes heroHop {
  0%, 70%, 100% { transform: translateZ(4px); }
  80% { transform: translateZ(22px); }
  90% { transform: translateZ(4px); }
}

.title {
  margin: 0;
  font-size: 2.8rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.5px;
}
.title span {
  background: linear-gradient(180deg, #fff6e4, #e8c88e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.title em {
  font-style: normal;
  margin-left: 8px;
  background: linear-gradient(180deg, #ffd889, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: 6px 0 0; color: var(--muted); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 20px 0 4px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
}
.stat b { display: block; font-size: 1.35rem; font-weight: 600; color: var(--gold); line-height: 1.2; }
.stat span { font-size: 0.8rem; color: var(--muted); }

.modes { display: grid; gap: 12px; margin-top: 16px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--gold-soft);
}
.mode-card:active { transform: scale(0.99); }
.mode-card.featured {
  background: linear-gradient(135deg, rgba(232, 182, 90, 0.22), rgba(232, 182, 90, 0.05));
  border-color: var(--border-strong);
}
.mode-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-soft);
  color: var(--gold);
}
.mode-icon svg { width: 28px; height: 28px; }
.mode-text { flex: 1; min-width: 0; }
.mode-text strong { display: block; font-size: 1.1rem; font-weight: 500; }
.mode-text small { color: var(--muted); font-size: 0.88rem; }
.mode-arrow { color: var(--gold); font-size: 1.6rem; line-height: 1; }

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.theme-pick { display: flex; align-items: center; gap: 8px; }
.theme-pick .label { margin: 0 4px 0 0; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background: conic-gradient(var(--a) 0 25%, var(--b) 0 50%, var(--a) 0 75%, var(--b) 0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.footer-right { display: flex; align-items: center; gap: 6px; }

/* ---------- Sheet / Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 3, 2, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
  animation: fade 0.2s;
}
.modal-box {
  position: relative;
  background: linear-gradient(180deg, #2a1e15, #1d150f);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: rise 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.modal-box h2 { margin: 0 0 4px; font-weight: 600; font-size: 1.4rem; }
.close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
}
.close-x:hover { background: var(--surface-2); color: var(--text); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px) scale(0.97); opacity: 0; } }

.level-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level-cards button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.level-cards button:hover { border-color: var(--border-strong); }
.level-cards button.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(232, 182, 90, 0.22), rgba(232, 182, 90, 0.06));
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.level-cards .stars { color: var(--gold); letter-spacing: 2px; font-size: 0.95rem; }
.level-cards strong { font-size: 1.1rem; font-weight: 500; }
.level-cards small { color: var(--muted); font-size: 0.75rem; text-align: center; line-height: 1.3; }
.level-cards .rec { font-size: 0.72rem; color: var(--muted); margin-top: 4px; min-height: 1em; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 9px 6px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.segmented button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.sheet-actions { margin-top: 20px; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.85rem; margin: 18px 0 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.2rem;
  letter-spacing: 5px;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
}
.join-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.join-row input::placeholder { letter-spacing: 0; text-transform: none; color: var(--muted); }

.rules-list { margin: 12px 0 0; padding-left: 20px; line-height: 1.75; }
.rules-list b { color: var(--gold); font-weight: 500; }

/* =========================================================
   หน้าเกม
   ========================================================= */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.mode-label {
  flex: 1;
  min-width: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right { display: flex; gap: 6px; }

.online-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.room-code { font-size: 1.3rem; letter-spacing: 4px; margin-left: 6px; color: var(--gold); }
.online-actions { display: flex; gap: 6px; }
.online-actions .btn { padding: 6px 12px; font-size: 0.9rem; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.player-bar.active {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(232, 182, 90, 0.16), var(--surface));
  box-shadow: 0 0 0 3px var(--gold-soft), 0 0 24px rgba(232, 182, 90, 0.15);
}
.avatar {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
}
.avatar.white { background: radial-gradient(circle at 50% 35%, #fffdf8, #efe6d6 45%, #c3b69f); box-shadow: 0 3px 0 #8f8471, 0 4px 8px rgba(0,0,0,.4); }
.avatar.black { background: radial-gradient(circle at 50% 35%, #5c5c5c, #262626 50%, #0d0d0d); box-shadow: 0 3px 0 #000, 0 4px 8px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.08); }
.avatar .badge {
  position: absolute;
  right: -4px;
  bottom: -4px;
  font-size: 0.85rem;
  line-height: 1;
  background: #2a1e15;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pname { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: none; margin-left: 4px; }
.player-bar.thinking .dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); animation: dot 1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.tray { display: flex; gap: 2px; min-height: 12px; margin-top: 3px; flex-wrap: wrap; }
.tray i { width: 12px; height: 12px; border-radius: 50%; }
.tray i.white { background: radial-gradient(circle at 50% 35%, #fff, #cfc4b0); }
.tray i.black { background: radial-gradient(circle at 50% 35%, #666, #111); box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.draw-btn {
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 500;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
  animation: drawPulse 1.6s ease-in-out infinite;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.draw-btn:hover { background: rgba(232, 182, 90, 0.28); }
.draw-btn:active { transform: scale(0.95); }
.draw-btn.on {
  background: linear-gradient(180deg, #f3c873, var(--gold-2));
  color: #2a1a08;
  border-color: transparent;
  animation: none;
}
.draw-btn:disabled { cursor: default; animation: none; opacity: 0.55; }
.draw-btn.on:disabled { opacity: 1; }
@keyframes drawPulse { 50% { box-shadow: 0 0 0 5px rgba(232, 182, 90, 0.18); } }

.pcount { text-align: right; color: var(--muted); font-size: 0.85rem; line-height: 1.25; }
.pcount b { display: block; color: var(--text); font-size: 1.15rem; font-weight: 600; }

/* ---------- กระดาน ---------- */
.board-wrap { position: relative; margin: 10px 0; container-type: inline-size; }

.board {
  display: grid;
  /* minmax(0, 1fr) ล็อกขนาดช่องให้เท่ากันเสมอ ไม่ขยายตามเนื้อหา */
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  container-type: inline-size;
  aspect-ratio: 1;
  width: 100%;
  border: 12px solid var(--frame-1);
  border-image: linear-gradient(145deg, var(--frame-1), var(--frame-2)) 1;
  box-shadow:
    0 0 0 2px rgba(232, 182, 90, 0.55),
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(232, 182, 90, 0.08);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.cell.light { background: var(--light-sq); }
.cell.dark {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.1)), var(--dark-sq);
  cursor: pointer;
}
.cell.last::before { content: ''; position: absolute; inset: 0; background: var(--last); }
.cell.selected::before { content: ''; position: absolute; inset: 0; background: var(--select); }
.cell.hint { box-shadow: inset 0 0 0 3px var(--ok); animation: hint 1s ease-in-out infinite; }
@keyframes hint { 50% { box-shadow: inset 0 0 0 5px var(--ok), inset 0 0 22px rgba(95, 224, 160, 0.6); } }

.cell.target::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--target);
  box-shadow: 0 0 12px var(--target);
  pointer-events: none;
  animation: targetPulse 1.2s ease-in-out infinite;
}
.cell.target.cap::after { background: var(--capture); box-shadow: 0 0 14px var(--capture); }
@keyframes targetPulse { 50% { transform: scale(1.2); } }

.coord {
  position: absolute;
  font-size: max(8px, 1.9cqw);
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
  opacity: 0.85;
}
.coord.rank { top: 3px; left: 3px; }
.coord.file { bottom: 3px; right: 4px; }
.cell.light .coord { color: var(--coord-on-light); }
.cell.dark .coord { color: var(--coord-on-dark); }

/* ---------- หมาก ---------- */
.piece {
  position: relative;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: transform 0.15s;
}
.piece::before {
  content: '';
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.5);
}
.piece.white {
  background: radial-gradient(circle at 50% 32%, #fffdf8 0%, #f1e8d8 42%, #cbbfa9 100%);
  box-shadow:
    inset 0 -3px 5px rgba(0, 0, 0, 0.16),
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    0 0.55cqw 0 #94887a,
    0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.45);
}
.piece.black {
  background: radial-gradient(circle at 50% 32%, #5e5e5e 0%, #2a2a2a 45%, #0c0c0c 100%);
  box-shadow:
    inset 0 -3px 5px rgba(0, 0, 0, 0.4),
    inset 0 2px 2px rgba(255, 255, 255, 0.18),
    0 0.55cqw 0 #000,
    0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.55);
}
.piece.black::before { box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.1); }
.piece .crown {
  position: relative;
  width: 58%;
  height: 58%;
  color: #e3a83b;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35)) drop-shadow(0 0 4px rgba(255, 200, 80, 0.5));
}
.piece.black .crown { color: #f3c45c; }

.piece.movable { cursor: pointer; }
.piece.must { animation: must 1.1s ease-in-out infinite; }
.cell.selected .piece { transform: translateY(-4%) scale(1.08); }
.piece.ghost { opacity: 0.28; }
.piece.hidden { visibility: hidden; }
.piece.moving { position: absolute; z-index: 6; will-change: transform; }
.piece.moving, .piece.ghostcap { width: auto; height: auto; }

@keyframes must {
  0%, 100% { outline: 0 solid rgba(255, 90, 70, 0); outline-offset: 0; }
  50% { outline: 3px solid rgba(255, 90, 70, 0.9); outline-offset: 2px; }
}

.board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 3, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 7;
}
.board-overlay p { margin: 14px 0 0; font-size: 1.1rem; white-space: pre-line; line-height: 1.6; }
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-row { display: flex; justify-content: center; margin: 12px 0; min-height: 34px; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1rem;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.status:empty { visibility: hidden; }
.status.mine { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.status.warn { border-color: var(--danger); color: var(--danger); background: rgba(255, 107, 91, 0.12); animation: warnPulse 1.2s ease-in-out infinite; }
@keyframes warnPulse { 50% { box-shadow: 0 0 0 4px rgba(255, 107, 91, 0.15); } }

.controls { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.ctrl svg { width: 20px; height: 20px; }
.ctrl:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ctrl:disabled { opacity: 0.35; cursor: default; }
.ctrl.danger { color: var(--danger); }
.ctrl.hint-btn { color: var(--ok); }
.ctrl .count {
  font-size: 0.7rem;
  background: rgba(95, 224, 160, 0.18);
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 2px;
}

/* ---------- ผลการแข่งขัน ---------- */
.result-box { text-align: center; }
.result-icon { font-size: 3.4rem; line-height: 1.2; animation: trophy 0.8s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes trophy { from { transform: scale(0.2) rotate(-20deg); opacity: 0; } }
.result-title { font-size: 1.8rem !important; }
.result-title.win {
  background: linear-gradient(180deg, #ffe7a8, var(--gold-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-stats { display: flex; justify-content: center; gap: 18px; margin: 14px 0 0; color: var(--muted); font-size: 0.9rem; }
.result-stats b { color: var(--text); font-size: 1.1rem; display: block; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #2e2218;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: toastIn 0.25s ease-out;
}
@keyframes toastIn { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------- โปรไฟล์ ---------- */
.menu-top { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.profile-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.profile-chip svg { width: 15px; height: 15px; color: var(--muted); flex-shrink: 0; }
.pc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.pc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }

.text-input {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
}
.text-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }

.avatar-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatar-grid button {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.15s;
}
.avatar-grid button:hover { transform: scale(1.08); }
.avatar-grid button.active { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 2px var(--gold-soft); }
@media (max-width: 400px) { .avatar-grid { grid-template-columns: repeat(6, 1fr); } }

.avatar .face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
}

.music-btn.off, .mute-btn.off { opacity: 0.45; }

/* ---------- นาฬิกาต่อตา ---------- */
.clock {
  flex-shrink: 0;
  min-width: 58px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.05rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  color: var(--muted);
}
.clock.running { color: var(--text); border-color: var(--border-strong); }
.clock.low { color: #ffb74d; border-color: #ffb74d; }
.clock.crit { color: var(--danger); border-color: var(--danger); animation: clockPulse 0.5s ease-in-out infinite alternate; }
@keyframes clockPulse { to { background: rgba(255, 107, 91, 0.22); transform: scale(1.06); } }

/* ---------- ดูย้อนเกม ---------- */
.replay-bar {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 10px 12px 12px;
}
.rp-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rp-title { font-weight: 500; color: var(--gold); }
.rp-label { color: var(--muted); font-variant-numeric: tabular-nums; }
#rpSlider { width: 100%; accent-color: var(--gold); margin: 4px 0 10px; }
.rp-buttons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rp-buttons .ctrl { padding: 8px 2px; }
.rp-buttons .ctrl svg { width: 18px; height: 18px; }
.rp-play { color: var(--gold); border-color: var(--border-strong) !important; }

/* =========================================================
   เอฟเฟกต์
   ========================================================= */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.particle {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: particle ease-out forwards;
  box-shadow: 0 0 6px rgba(255, 200, 80, 0.6);
}
@keyframes particle {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2); opacity: 0; }
}
.ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid rgba(255, 210, 90, 0.9);
  transform: translate(-50%, -50%) scale(0.3);
  animation: ring 0.5s ease-out forwards;
}
@keyframes ring { to { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }

.ghostcap { position: absolute; z-index: 5; transform: translate(-50%, -50%); }

.fx-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-weight: 600;
  font-size: 9cqw;
  color: #fff;
  text-shadow: 0 3px 0 #b5651d, 0 6px 16px rgba(0, 0, 0, 0.6);
  animation: banner 1.2s cubic-bezier(0.2, 1.4, 0.4, 1) forwards;
  z-index: 8;
}
.fx-banner.combo { color: #ffd54f; text-shadow: 0 3px 0 #c62828, 0 0 24px rgba(255, 120, 0, 0.8); }
.fx-banner.big { font-size: 11cqw; }
.fx-banner.promo { color: #fff3b0; text-shadow: 0 3px 0 #8f4c12, 0 0 28px rgba(255, 215, 64, 0.95); }
.fx-banner.turn { font-size: 7cqw; color: var(--gold); text-shadow: 0 3px 0 #4a2c14, 0 0 20px rgba(0, 0, 0, 0.6); animation-duration: 1.1s; }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.15) rotate(2deg); opacity: 1; }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { transform: translate(-50%, -60%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(0.9); opacity: 0; }
}

.confetti {
  position: fixed;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  z-index: 40;
  pointer-events: none;
  animation: confetti ease-in forwards;
}
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--drift), 105vh) rotate(var(--rot)); opacity: 0.9; }
}

.cell.crowned .piece { animation: crowned 1.1s ease-out; }
@keyframes crowned {
  0% { transform: scale(1); filter: brightness(1); }
  30% { transform: scale(1.22); filter: brightness(1.4) drop-shadow(0 0 12px rgba(255, 215, 64, 0.95)); }
  100% { transform: scale(1); filter: brightness(1); }
}

.board-wrap.shake { animation: shake 0.35s ease-in-out; }
.board-wrap.shake-strong { animation: shake-strong 0.45s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -1px); }
}
@keyframes shake-strong {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-6px, 3px) rotate(-0.6deg); }
  40% { transform: translate(6px, -3px) rotate(0.6deg); }
  60% { transform: translate(-4px, 2px) rotate(-0.3deg); }
  80% { transform: translate(3px, -1px); }
}

/* =========================================================
   โหมดเต็มจอ
   ========================================================= */
body.fs { overflow: hidden; }
body.fs #game {
  max-width: none;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
body.fs #game > :not(.board-wrap) { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }
body.fs .topbar { margin-bottom: 4px; }
body.fs .online-panel { margin-bottom: 4px; padding: 4px 12px; }
body.fs .player-bar { padding: 4px 12px; }
body.fs .board-wrap {
  flex: 1;
  min-height: 0;
  margin: 6px 0;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.fs .board { width: min(100cqw, 100cqh); }
body.fs .status-row { margin: 4px 0; }
body.fs .fx-banner { font-size: min(9cqw, 9cqh); }
body.fs .fx-banner.big { font-size: min(11cqw, 11cqh); }
body.fs .fx-banner.turn { font-size: min(7cqw, 7cqh); }

@media (max-width: 400px) {
  .title { font-size: 2.3rem; }
  .board { border-width: 8px; }
  .hero-board-wrap { height: 160px; }
  .hero-board { width: 190px; height: 190px; }
  .ctrl { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .board-wrap.shake, .board-wrap.shake-strong, .hero-board, .hero-board .hp.bounce { animation: none; }
}

/* =========================================================
   ห้องออนไลน์หลายคน: คิว / อีโมจิ / แชท
   ========================================================= */
.people-btn { font-variant-numeric: tabular-nums; }
.board-overlay #waitCopy { margin-top: 12px; }

.watch-tag {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(10, 7, 4, 0.72);
  border: 1px solid var(--border-strong);
  color: var(--gold);
  font-size: 0.85rem;
  pointer-events: none;
}

/* อีโมจิลอยขึ้นบนกระดาน */
.react-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 7; border-radius: 12px; }
.react-float {
  position: absolute;
  bottom: 4%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: reactUp 2.7s cubic-bezier(0.25, 0.8, 0.4, 1) forwards;
}
.rf-emoji { font-size: clamp(2rem, 9cqw, 3.4rem); line-height: 1; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }
.rf-name {
  margin-top: 2px;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(10, 7, 4, 0.7);
  color: var(--text);
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.react-float.mine .rf-name { color: var(--gold); }
@keyframes reactUp {
  0% { transform: translate(0, 20px) scale(0.3); opacity: 0; }
  12% { transform: translate(0, 0) scale(1.25); opacity: 1; }
  22% { transform: translate(0, -8%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translate(var(--drift), -260%) scale(0.9); opacity: 0; }
}

/* ข้อความแชทลอยบนกระดาน (ตอนมองไม่เห็นกล่องแชท) */
.chat-pop {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 8;
  max-width: 88%;
  padding: 7px 14px;
  border-radius: 16px;
  background: rgba(30, 21, 14, 0.92);
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 0.92rem;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: toastIn 0.25s ease-out;
}
.chat-pop b { font-weight: 500; color: var(--gold); }

.social { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.queue-card, .react-card, .chat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
}

.qc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.qc-title { font-weight: 500; }
.qc-me { font-size: 0.85rem; color: var(--gold); }
.qc-list, .people-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.qc-list { max-height: 132px; overflow-y: auto; }
.person {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}
.person.me { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--border-strong); }
.person.off { opacity: 0.5; }
.q-no { width: 20px; text-align: center; color: var(--gold); font-variant-numeric: tabular-nums; }
.p-av { font-size: 1.25rem; width: 28px; text-align: center; }
.p-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-extra { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.q-empty { color: var(--muted); font-size: 0.85rem; padding: 4px 2px; }
.qc-actions { display: flex; gap: 6px; margin-top: 8px; }
.qc-actions .btn { flex: 1; padding: 7px 10px; font-size: 0.88rem; }
#peopleList .label { display: block; margin-top: 12px; }

.react-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.react-tabs button {
  flex: 1;
  padding: 6px 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
}
.react-tabs button.active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.react-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.react-btn {
  aspect-ratio: 1;
  border: 0;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 1.35rem;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, background 0.15s;
}
.react-btn:hover { background: var(--surface-2); transform: scale(1.12); }
.react-btn.pop { animation: reactPop 0.3s ease-out; }
@keyframes reactPop { 50% { transform: scale(1.4); } }
.phrase-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.phrase-chip {
  max-width: 100%;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.phrase-chip:hover { background: rgba(232, 182, 90, 0.28); }

.chat-card { display: flex; flex-direction: column; position: relative; min-height: 0; }
.chat-head { font-weight: 500; margin-bottom: 6px; }
.chat-log {
  height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  overscroll-behavior: contain;
}
.chat-msg { display: flex; gap: 8px; align-items: flex-start; max-width: 92%; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.sys {
  align-self: center;
  max-width: 100%;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}
.cm-av { font-size: 1.25rem; line-height: 1.6; }
.cm-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 5px 10px;
  border-radius: 14px;
  background: var(--surface-2);
}
.chat-msg.mine .cm-body { background: rgba(232, 182, 90, 0.2); align-items: flex-end; }
.cm-name { font-size: 0.72rem; color: var(--muted); }
.cm-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.cm-text.big { font-size: 1.8rem; line-height: 1.2; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }
.chat-form .text-input { flex: 1; min-width: 0; padding: 8px 12px; font-size: 1rem; }
.chat-form .btn { padding: 8px 14px; }
.emoji-pop {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 56px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  padding: 8px;
  border-radius: 14px;
  background: #2a1e15;
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.emoji-pop button { border: 0; background: transparent; font-size: 1.3rem; aspect-ratio: 1; cursor: pointer; border-radius: 8px; padding: 0; }
.emoji-pop button:hover { background: var(--surface-2); }

/* หน้าโปรไฟล์: ตัวอย่างหน้าตา + กลุ่มรูป */
.avatar-preview { display: flex; flex-direction: column; align-items: center; margin: 12px 0 4px; }
.avatar-preview span {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  background: var(--gold-soft);
  box-shadow: 0 0 0 2px var(--border-strong);
}
.avatar-preview small { margin-top: 6px; color: var(--muted); }
.req { color: var(--danger); font-style: normal; }
.avatar-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; margin-bottom: 8px; }
.avatar-tabs button {
  padding: 7px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.9rem;
}
.avatar-tabs button.active { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 0.92rem; color: var(--muted); cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--gold); }

/* จอกว้าง: แชท/คิวอยู่ด้านขวาของกระดาน */
@media (min-width: 1000px) {
  #game.has-social { max-width: 976px; padding-right: 416px; position: relative; }
  #game.has-social > .social {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 384px;
    margin-top: 0;
  }
  #game.has-social .qc-list { max-height: 92px; }
  #game.has-social .chat-card { flex: 1; min-height: 0; }
  #game.has-social .chat-log { height: auto; flex: 1; min-height: 80px; }
}

@media (max-width: 400px) {
  .react-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .react-btn { font-size: 1.5rem; }
}

/* เต็มจอ: ซ่อนคิว/แชท เหลือแถบอีโมจิ */
body.fs .social { margin-top: 4px; }
body.fs .queue-card, body.fs .chat-card, body.fs .phrase-row { display: none; }
body.fs .react-card { padding: 6px 10px; }
body.fs #game.has-social { padding-right: 12px; }
body.fs #game.has-social > .social { position: static; width: 100%; }

/* เยาะเย้ย: เด้งขึ้นกลางจอตัวใหญ่ */
.taunt-pop {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  max-width: calc(100vw - 32px);
}
.taunt-pop.show { animation: tauntIn var(--pop-ms, 2.6s) cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.tp-emoji {
  font-size: clamp(6rem, 30vmin, 12rem);
  line-height: 1;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6));
  animation: tauntWiggle 0.5s ease-in-out 0.35s 3;
}
.tp-text {
  margin-top: 6px;
  padding: 8px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff7a5c, #d8432c);
  color: #fff;
  font-size: clamp(1.4rem, 6vmin, 2.4rem);
  font-weight: 600;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.15);
  overflow-wrap: anywhere;
}
.tp-name {
  margin-top: 6px;
  padding: 2px 12px;
  border-radius: 999px;
  background: rgba(10, 7, 4, 0.75);
  color: var(--gold);
  font-size: 0.95rem;
}
@keyframes tauntIn {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-12deg); opacity: 0; }
  14% { transform: translate(-50%, -50%) scale(1.15) rotate(4deg); opacity: 1; }
  24% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  82% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -64%) scale(0.85); opacity: 0; }
}
@keyframes tauntWiggle {
  25% { transform: rotate(-14deg) scale(1.05); }
  75% { transform: rotate(14deg) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .taunt-pop.show { animation-timing-function: linear; }
  .tp-emoji, .tp-burst, .tp-sparks span { animation: none !important; }
  .tp-sparks { display: none; }
}

/* แชทลอยตอนเต็มจอ (ห้องออนไลน์) */
.fs-chat { display: none; }
body.fs.online-room .fs-chat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  position: fixed;
  left: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 15;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.fs-feed { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.fs-msg.chat-msg { align-self: flex-start; flex-direction: row; max-width: 100%; animation: fsMsgIn 0.25s ease-out; transition: opacity 0.6s, transform 0.6s; }
.fs-msg .cm-body, .fs-msg.mine .cm-body { background: rgba(20, 14, 9, 0.86); border: 1px solid var(--border); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); align-items: flex-start; }
.fs-msg.mine .cm-body { border-color: var(--border-strong); }
.fs-msg.sys { background: rgba(20, 14, 9, 0.86); align-self: flex-start; }
.fs-msg.out { opacity: 0; transform: translateY(-6px); }
@keyframes fsMsgIn { from { opacity: 0; transform: translateX(-16px); } }
.fs-bar { display: flex; gap: 6px; width: 100%; pointer-events: auto; }
.fs-toggle {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(30, 21, 14, 0.92);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.fs-toggle.on { background: var(--gold-soft); }
.fs-form { flex: 1; display: flex; gap: 6px; min-width: 0; }
.fs-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(20, 14, 9, 0.92);
  color: var(--text);
  outline: none;
}
.fs-form input:focus { box-shadow: 0 0 0 3px var(--gold-soft); }
.fs-form button {
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, #f3c873, var(--gold-2));
  color: #2a1a08;
  font-weight: 600;
  cursor: pointer;
}

/* คำขอย้อนตาจากคู่แข่ง */
.undo-ask {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  width: min(330px, 88%);
  padding: 16px 16px 14px;
  border-radius: 18px;
  text-align: center;
  background: linear-gradient(180deg, #2f2217, #1f160f);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 4px var(--gold-soft);
  animation: uaIn 0.28s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes uaIn { from { opacity: 0; transform: translate(-50%, -40%) scale(0.95); } }
.ua-icon { font-size: 2.2rem; line-height: 1; }
.undo-ask p { margin: 8px 0 12px; font-size: 1rem; }
.ua-actions { display: flex; gap: 8px; }
.ua-actions .btn { flex: 1; padding: 10px 8px; }

/* =========================================================
   สมาชิก + ดาวแชมป์
   ========================================================= */
.acct-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.92rem;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acct-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.acct-btn.member { border-color: var(--border-strong); color: var(--gold); }

/* สีดาวตามยศ */
.silver { --star: #e6ecf2; --star-glow: rgba(220, 232, 245, 0.7); }
.gold { --star: #ffd257; --star-glow: rgba(255, 196, 60, 0.85); }
.diamond { --star: #9fe8ff; --star-glow: rgba(120, 220, 255, 0.95); }
.legend { --star: #ff9de2; --star-glow: rgba(255, 140, 220, 0.95); }
.acct-btn.member.silver, .acct-btn.member.gold, .acct-btn.member.diamond, .acct-btn.member.legend { color: var(--star); }

/* ดาวบนหมาก */
.pstars {
  position: absolute;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: max(7px, 2.1cqw);
  line-height: 1;
  letter-spacing: -0.5px;
  white-space: nowrap;
  color: var(--star);
  text-shadow: 0 0 3px var(--star-glow), 0 1px 1px rgba(0, 0, 0, 0.9), 0 0 1px #000;
  pointer-events: none;
}
.piece:has(.crown) .pstars { top: -1%; }
.pstars.legend { animation: legendHue 3s linear infinite; }
@keyframes legendHue { to { filter: hue-rotate(360deg); } }

/* ป้ายยศข้างชื่อ */
.rank-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  color: var(--star);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px var(--star-glow);
  text-shadow: 0 0 4px var(--star-glow);
  white-space: nowrap;
}
.cm-name .rank-badge { font-size: 0.66rem; margin-left: 2px; }

/* หน้าสมาชิก */
#acctTabs { margin: 12px 0 4px; }
.acct-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding-right: 36px; }
.acct-av {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  background: var(--gold-soft);
  box-shadow: 0 0 0 2px var(--border-strong);
}
.acct-id { min-width: 0; }
.acct-id h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.champ-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  border-radius: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
}
.champ-card:not(.none) { border-color: var(--star-glow); box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.4), 0 0 18px -6px var(--star-glow); color: var(--star); }
.champ-stars { font-size: 2.2rem; letter-spacing: 4px; color: var(--star); text-shadow: 0 0 10px var(--star-glow); }
.acct-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.acct-stats div {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}
.acct-stats b { color: var(--text); font-size: 1.2rem; }

.lb-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); }
.lb-row.me { background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--border-strong); }
.lb-no { width: 26px; text-align: center; color: var(--gold); }

/* =========================================================
   ประเภทห้อง / รายการห้อง / ขออนุญาตเข้าห้อง
   ========================================================= */
#onlineTabs { margin: 12px 0 10px; }
.type-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.type-cards button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.type-cards button:hover { border-color: var(--border-strong); }
.type-cards button.active {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(232, 182, 90, 0.22), rgba(232, 182, 90, 0.06));
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.tc-icon { font-size: 1.6rem; line-height: 1.2; }
.type-cards strong { font-size: 0.92rem; font-weight: 500; }
.type-cards small { color: var(--muted); font-size: 0.72rem; line-height: 1.3; }
.hint-note { margin: 6px 2px 0; font-size: 0.8rem; color: var(--gold); line-height: 1.4; }

.room-list { display: flex; flex-direction: column; gap: 8px; max-height: min(46vh, 380px); overflow-y: auto; margin-bottom: 10px; padding-right: 2px; }
.room-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.room-row.lobby { border-color: var(--border-strong); background: linear-gradient(90deg, rgba(232, 182, 90, 0.14), var(--surface)); }
.rr-icon { font-size: 1.6rem; flex-shrink: 0; }
.rr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rr-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-sub, .rr-play { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-play { color: var(--text); opacity: 0.85; }
.rr-join { flex-shrink: 0; padding: 8px 14px; }

.room-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.room-lock { margin-left: 6px; }
.room-owner { font-size: 0.8rem; color: var(--muted); }
.room-owner:empty { display: none; }
.owner-tag {
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  background: var(--gold-soft);
  color: var(--gold);
  white-space: nowrap;
}

/* รอเจ้าของห้องกดรับ */
.knock-box { text-align: center; display: flex; flex-direction: column; align-items: center; }
.knock-door { font-size: 3.2rem; animation: knock 1.2s ease-in-out infinite; }
@keyframes knock { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-8deg); } 20%, 40% { transform: rotate(8deg); } }
.knock-box .spinner { margin: 8px 0 4px; }
.knock-box .sheet-actions { width: 100%; }

/* เจ้าของห้อง: คำขอเข้าห้อง */
.knock-panel {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 18;
  width: min(440px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.knock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  border-radius: 14px;
  background: rgba(36, 26, 17, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 0 3px var(--gold-soft);
  animation: fsMsgIn 0.25s ease-out;
}
.kr-who { flex: 1; min-width: 0; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; }
.knock-row .btn { padding: 7px 12px; flex-shrink: 0; }

@media (max-width: 400px) {
  .type-cards small { display: none; }
}

/* ---------- footer ---------- */
.site-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.7;
}
.site-footer a { display: block; color: var(--gold); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---------- คำเตือนห้ามเล่นการพนัน ---------- */
.no-gamble {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 2px solid #ff5a46;
  background: linear-gradient(135deg, rgba(255, 90, 70, 0.22), rgba(255, 90, 70, 0.08));
  box-shadow: 0 0 0 4px rgba(255, 90, 70, 0.12), 0 10px 30px rgba(0, 0, 0, 0.35);
}
.ng-icon { font-size: 2.6rem; line-height: 1; flex-shrink: 0; }
.no-gamble div { display: flex; flex-direction: column; min-width: 0; }
.no-gamble strong { font-size: 1.15rem; font-weight: 600; color: #fff; line-height: 1.35; }
.no-gamble span:not(.ng-icon) { font-size: 1.3rem; font-weight: 600; color: #ff8a7a; line-height: 1.35; }
.no-gamble-mini {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 90, 70, 0.14);
  border: 1px solid rgba(255, 90, 70, 0.5);
  color: #ffb3a8;
  font-size: 0.85rem;
  font-weight: 500;
}
@media (max-width: 400px) {
  .no-gamble { padding: 12px 14px; gap: 10px; }
  .ng-icon { font-size: 2.1rem; }
  .no-gamble strong { font-size: 1rem; }
  .no-gamble span:not(.ng-icon) { font-size: 1.12rem; }
}

/* =========================================================
   ฟีเจอร์เสริม: โจทย์ · ภารกิจ · หาคู่ด่วน · สกิน · เชียร์ · ทัวร์ · วิเคราะห์ · ชวนเพื่อน
   ========================================================= */

/* ---------- ธีมกระดานเพิ่มเติม (ใช้ได้ทั้ง body และตัวอย่างในหน้าสกิน) ---------- */
[data-theme='classic'] {
  --light-sq: #ecd3a8;
  --dark-sq: #9b6438;
  --frame-1: #6b4220;
  --frame-2: #3a2210;
  --coord-on-light: #9b6438;
  --coord-on-dark: #ecd3a8;
}
[data-theme='teak'] {
  --light-sq: #f0c98a;
  --dark-sq: #8a4b1c;
  --frame-1: #a0601f;
  --frame-2: #4a2408;
  --coord-on-light: #8a4b1c;
  --coord-on-dark: #f8dca8;
}
[data-theme='thai'] {
  --light-sq: #f4e3b8;
  --dark-sq: #7d1d1d;
  --frame-1: #c99a2e;
  --frame-2: #5a1010;
  --coord-on-light: #7d1d1d;
  --coord-on-dark: #f4d58a;
}
[data-theme='royal'] {
  --light-sq: #f7ecd0;
  --dark-sq: #23345e;
  --frame-1: #d6a83c;
  --frame-2: #3a2a08;
  --coord-on-light: #23345e;
  --coord-on-dark: #f3d27a;
}
/* ลายไม้สัก */
body[data-theme='teak'] .cell.dark,
.board-pv[data-theme='teak'] i.d {
  background:
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0.1) 0 2px, transparent 2px 7px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12)),
    var(--dark-sq);
}
/* ลายไทย: ลายประจำยามสีทองบนช่องแดง */
body[data-theme='thai'] .cell.dark,
.board-pv[data-theme='thai'] i.d,
.skin-preview[data-theme='thai'] i.d {
  background:
    radial-gradient(circle at 50% 50%, rgba(244, 196, 90, 0.55) 0 9%, transparent 10%),
    repeating-conic-gradient(from 45deg, rgba(244, 196, 90, 0.22) 0 25%, transparent 0 50%) 50% 50% / 50% 50%,
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(244, 196, 90, 0.35) 60%, transparent 64%),
    var(--dark-sq);
}
body[data-theme='thai'] .cell.light,
.board-pv[data-theme='thai'] i.l {
  background: radial-gradient(circle at 50% 50%, rgba(201, 154, 46, 0.25) 0 6%, transparent 7%), var(--light-sq);
}
/* ราชสำนัก: กรมท่าขลิบทอง */
body[data-theme='royal'] .cell.dark,
.board-pv[data-theme='royal'] i.d {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.15)),
    radial-gradient(circle, transparent 62%, rgba(243, 210, 122, 0.4) 64%, transparent 68%),
    var(--dark-sq);
}

/* ---------- สกินหมาก ---------- */
.piece.skin-marble.white {
  background:
    linear-gradient(120deg, transparent 38%, rgba(150, 150, 160, 0.35) 40%, transparent 44%),
    linear-gradient(60deg, transparent 58%, rgba(150, 150, 160, 0.28) 60%, transparent 63%),
    radial-gradient(circle at 50% 30%, #ffffff 0%, #ecebef 50%, #b9b8c2 100%);
}
.piece.skin-marble.black {
  background:
    linear-gradient(120deg, transparent 36%, rgba(120, 190, 160, 0.35) 38%, transparent 42%),
    linear-gradient(70deg, transparent 60%, rgba(220, 220, 220, 0.18) 62%, transparent 65%),
    radial-gradient(circle at 50% 30%, #3c4a45 0%, #1b2422 50%, #070a09 100%);
}
.piece.skin-teak.white {
  background:
    repeating-radial-gradient(circle at 30% 120%, rgba(120, 60, 10, 0.18) 0 3px, transparent 3px 7px),
    radial-gradient(circle at 50% 30%, #ffe2b0 0%, #e2a865 55%, #a86a2c 100%);
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.2), inset 0 2px 3px rgba(255, 240, 210, 0.8), 0 0.55cqw 0 #7a4514, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.45);
}
.piece.skin-teak.black {
  background:
    repeating-radial-gradient(circle at 30% 120%, rgba(0, 0, 0, 0.25) 0 3px, transparent 3px 7px),
    radial-gradient(circle at 50% 30%, #8a5228 0%, #55290c 55%, #2a1203 100%);
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.4), inset 0 2px 2px rgba(255, 200, 150, 0.25), 0 0.55cqw 0 #1a0a02, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.55);
}
.piece.skin-jade.white {
  background: radial-gradient(circle at 45% 30%, #f4fff6 0%, #bfe8c8 45%, #7cbf8e 100%);
  box-shadow: inset 0 -3px 6px rgba(20, 80, 40, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.9), 0 0.55cqw 0 #4f8f61, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.45);
}
.piece.skin-jade.black {
  background: radial-gradient(circle at 45% 30%, #4fae7e 0%, #1c6b47 45%, #072c1c 100%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.45), inset 0 2px 3px rgba(180, 255, 210, 0.35), 0 0.55cqw 0 #031a10, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.55);
}
.piece.skin-gold.white {
  background: radial-gradient(circle at 45% 28%, #fff7d1 0%, #ffd96a 35%, #d39a26 75%, #8f5f10 100%);
  box-shadow: inset 0 -3px 6px rgba(120, 70, 0, 0.35), inset 0 2px 3px rgba(255, 255, 230, 0.95), 0 0.55cqw 0 #8a5a0c, 0 1.1cqw 1.8cqw rgba(232, 182, 90, 0.4);
}
.piece.skin-gold.black {
  background: radial-gradient(circle at 45% 28%, #9b7440 0%, #5a3c16 45%, #24160a 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 214, 110, 0.75), inset 0 -3px 6px rgba(0, 0, 0, 0.5), 0 0.55cqw 0 #140c03, 0 1.1cqw 1.8cqw rgba(232, 182, 90, 0.3);
}
.piece.skin-gold::before { box-shadow: inset 0 0 0 2px rgba(255, 224, 140, 0.7), inset 0 2px 3px rgba(0, 0, 0, 0.25); }
.piece.skin-thai.white {
  background:
    repeating-conic-gradient(from 0deg, rgba(190, 40, 40, 0.28) 0 10deg, transparent 10deg 30deg),
    radial-gradient(circle at 50% 30%, #fff8e6 0%, #f3dcae 55%, #c9a46a 100%);
  box-shadow: inset 0 0 0 2px #c99a2e, inset 0 -3px 5px rgba(0, 0, 0, 0.18), 0 0.55cqw 0 #8a6420, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.45);
}
.piece.skin-thai.black {
  background:
    repeating-conic-gradient(from 0deg, rgba(244, 196, 90, 0.4) 0 10deg, transparent 10deg 30deg),
    radial-gradient(circle at 50% 30%, #b8312c 0%, #7d1414 55%, #3a0606 100%);
  box-shadow: inset 0 0 0 2px #e3b44a, inset 0 -3px 5px rgba(0, 0, 0, 0.4), 0 0.55cqw 0 #2a0404, 0 1.1cqw 1.6cqw rgba(0, 0, 0, 0.55);
}
.piece.skin-thai::before {
  inset: 22%;
  background: radial-gradient(circle, rgba(244, 196, 90, 0.9) 0 18%, transparent 20%);
  box-shadow: 0 0 0 2px rgba(244, 196, 90, 0.65);
}
.piece.skin-ruby.white {
  background: radial-gradient(circle at 40% 28%, #ffffff 0%, #f6eef6 35%, #e3cfe3 70%, #b9a2c4 100%);
  box-shadow: inset 0 -3px 6px rgba(120, 60, 120, 0.2), inset 0 2px 4px #fff, 0 0.55cqw 0 #9a86a6, 0 1.1cqw 1.8cqw rgba(255, 180, 220, 0.25);
}
.piece.skin-ruby.black {
  background: radial-gradient(circle at 40% 25%, #ff8a9c 0%, #d0143a 30%, #7a0620 70%, #33000c 100%);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 200, 210, 0.7), 0 0.55cqw 0 #2a0008, 0 1.1cqw 2cqw rgba(255, 40, 80, 0.35);
}
.piece.skin-dragon.white {
  background:
    conic-gradient(from var(--spin, 0deg), rgba(255, 255, 255, 0.5), transparent 25%, rgba(255, 255, 255, 0.4) 50%, transparent 75%, rgba(255, 255, 255, 0.5)),
    radial-gradient(circle at 45% 28%, #fff4c4 0%, #ffc94a 40%, #c87a10 80%, #7a4204 100%);
  box-shadow: inset 0 -3px 6px rgba(120, 60, 0, 0.35), 0 0.55cqw 0 #7a4204, 0 0 2.4cqw rgba(255, 190, 60, 0.6);
  animation: dragonGlow 2.6s ease-in-out infinite;
}
.piece.skin-dragon.black {
  background:
    conic-gradient(from var(--spin, 0deg), rgba(255, 80, 40, 0.45), transparent 25%, rgba(255, 160, 40, 0.35) 50%, transparent 75%, rgba(255, 80, 40, 0.45)),
    radial-gradient(circle at 45% 28%, #5a2a2a 0%, #241010 45%, #060202 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 110, 40, 0.6), 0 0.55cqw 0 #000, 0 0 2.4cqw rgba(255, 80, 30, 0.55);
  animation: dragonGlow 2.6s ease-in-out infinite;
}
@keyframes dragonGlow { 50% { filter: brightness(1.18) saturate(1.2); } }
.piece.skin-dragon .crown, .piece.skin-gold .crown { color: #fff3c0; }

/* ---------- เมนู: โจทย์ประจำวัน / ภารกิจ / หาคู่ด่วน ---------- */
.daily-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid rgba(95, 224, 160, 0.45);
  background: linear-gradient(135deg, rgba(95, 224, 160, 0.18), rgba(95, 224, 160, 0.04));
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}
.daily-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(95, 224, 160, 0.25); }
.dc-icon { font-size: 2rem; line-height: 1; filter: drop-shadow(0 2px 6px rgba(95, 224, 160, 0.4)); }
.dc-text { flex: 1; min-width: 0; }
.dc-text strong { display: block; font-weight: 500; font-size: 1.05rem; }
.dc-text strong em { font-style: normal; color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.dc-text small { color: var(--muted); font-size: 0.85rem; }
.dc-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #10261a;
  background: var(--ok);
  white-space: nowrap;
  animation: badgeBob 1.6s ease-in-out infinite;
}
.dc-badge.done { animation: none; background: rgba(95, 224, 160, 0.18); color: var(--ok); }
@keyframes badgeBob { 50% { transform: translateY(-2px) scale(1.05); } }

.mission-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.mission-strip:hover { border-color: var(--border-strong); }
.mission-strip b { font-weight: 500; }
.ms-bar { flex: 1; height: 6px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.ms-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--gold)); border-radius: inherit; transition: width 0.5s; }
.ms-arrow { color: var(--gold); font-size: 0.82rem; white-space: nowrap; }
.mission-strip.done { border-color: var(--border-strong); background: var(--gold-soft); }

.mode-card.quick {
  background: linear-gradient(135deg, rgba(255, 120, 60, 0.22), rgba(232, 182, 90, 0.08));
  border-color: rgba(255, 140, 70, 0.5);
}
.mode-card.quick .mode-icon { font-size: 1.7rem; background: rgba(255, 140, 70, 0.18); animation: zap 2.4s ease-in-out infinite; }
@keyframes zap { 0%, 80%, 100% { transform: none; } 85% { transform: rotate(-8deg) scale(1.08); } 90% { transform: rotate(8deg) scale(1.08); } }

.footer-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.install-btn { color: var(--ok); }

/* ---------- หาคู่ด่วน ---------- */
.quick-radar { position: relative; width: 110px; height: 110px; margin: 6px auto 10px; }
.quick-radar span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 140, 70, 0.6);
  animation: radar 1.8s ease-out infinite;
}
.quick-radar span + span { animation-delay: 0.9s; }
.quick-radar i {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 2rem;
  background: rgba(255, 140, 70, 0.2);
  box-shadow: 0 0 24px rgba(255, 140, 70, 0.4);
}
@keyframes radar { from { transform: scale(0.4); opacity: 1; } to { transform: scale(1.15); opacity: 0; } }
.quick-timer { font-size: 1.8rem; font-weight: 500; color: var(--gold); margin: 4px 0; font-variant-numeric: tabular-nums; }

/* ---------- ชวนเพื่อน ---------- */
.invite-qr {
  display: grid;
  place-items: center;
  margin: 12px auto;
  width: 216px;
  height: 216px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.invite-qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.invite-code { text-align: center; margin: 4px 0 12px; color: var(--muted); }
.invite-code strong { color: var(--gold); font-size: 1.4rem; letter-spacing: 0.18em; margin-left: 6px; }
.invite-actions { display: flex; flex-direction: column; gap: 8px; }
.line-btn {
  background: #06c755;
  border-color: #06c755;
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: 500;
}
.line-btn:hover { background: #05b34c; border-color: #05b34c; }

/* ---------- แถบผู้เล่น: แรงก์ / เชียร์ ---------- */
.tier-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.6;
  vertical-align: middle;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
}
.tier-chip.tier-silver { color: #dfe6ee; box-shadow: inset 0 0 0 1px rgba(223, 230, 238, 0.4); }
.tier-chip.tier-gold { color: #ffd36a; box-shadow: inset 0 0 0 1px rgba(255, 211, 106, 0.5); }
.tier-chip.tier-diamond { color: #8fe3ff; box-shadow: inset 0 0 0 1px rgba(143, 227, 255, 0.55); }
.tier-chip.tier-master { color: #ff9a5a; box-shadow: inset 0 0 0 1px rgba(255, 154, 90, 0.6), 0 0 8px rgba(255, 120, 60, 0.35); }

.player-bar { position: relative; }
.player-bar.cheered { animation: cheered 0.6s ease-out; }
@keyframes cheered { 30% { box-shadow: 0 0 0 3px rgba(255, 140, 70, 0.55), 0 0 26px rgba(255, 140, 70, 0.35); } }
.cheer-pop {
  position: absolute;
  top: -6px;
  font-size: 1.3rem;
  pointer-events: none;
  animation: cheerPop 1.2s ease-out forwards;
}
@keyframes cheerPop { from { transform: translateY(0) scale(0.6); opacity: 1; } to { transform: translateY(-38px) scale(1.2); opacity: 0; } }

.cheer-meter { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.cm-btn {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 140, 70, 0.5);
  background: rgba(255, 140, 70, 0.14);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.cm-btn:active { transform: scale(0.94); }
.cm-bar {
  position: relative;
  flex: 1;
  display: flex;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}
.cm-w { background: linear-gradient(90deg, #f3ece0, #cfc6b4); transition: width 0.4s; }
.cm-b { background: linear-gradient(90deg, #3a3a3a, #111); transition: width 0.4s; }
.cm-bar em {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 0.76rem;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}

/* ---------- ทัวร์นาเมนต์ ---------- */
.tour-card {
  background: linear-gradient(160deg, rgba(232, 182, 90, 0.16), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 10px 12px;
}
.tour-bracket { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.tb-col { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; min-width: 120px; flex: 1; }
.tb-match { border-radius: 10px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--border); overflow: hidden; }
.tb-match.current { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.tb-p { display: block; padding: 3px 8px; font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-p + .tb-p { border-top: 1px solid var(--border); }
.tb-p.win { color: var(--gold); font-weight: 500; }
.tb-p.lose { color: var(--muted); text-decoration: line-through; opacity: 0.7; }
.tb-p.me { background: var(--gold-soft); }
.tb-champ {
  padding: 10px 8px;
  border-radius: 12px;
  text-align: center;
  font-weight: 500;
  color: #2a1a05;
  background: linear-gradient(135deg, #ffe08a, var(--gold-2));
  box-shadow: 0 0 20px rgba(232, 182, 90, 0.4);
}

/* ---------- ผลการแข่ง: แรงก์ / วิเคราะห์ ---------- */
.rating-delta { margin: 10px 0 0; font-weight: 500; }
.rating-delta.up { color: var(--ok); }
.rating-delta.down { color: var(--danger); }
.analysis-box { margin-top: 14px; padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); text-align: left; }
.an-title { margin: 0 0 6px; font-weight: 500; color: var(--gold); }
.an-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 5px 0; }
.an-row + .an-row { border-top: 1px solid var(--border); }
.an-who { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-acc { font-size: 1.25rem; font-weight: 600; }
.an-acc.hi { color: var(--ok); }
.an-acc.mid { color: var(--gold); }
.an-acc.lo { color: var(--danger); }
.an-tags { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; }
.an-note { margin: 8px 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- ดูย้อน + คำแนะนำ ---------- */
.rp-marks { display: flex; gap: 2px; margin: 0 0 4px; height: 12px; }
.rp-mark { flex: 1; min-width: 2px; border: 0; padding: 0; border-radius: 2px; cursor: pointer; background: rgba(255, 255, 255, 0.14); }
.rp-mark.best { background: rgba(95, 224, 160, 0.45); }
.rp-mark.brilliant { background: #5fd8ff; }
.rp-mark.mistake { background: #ffb347; }
.rp-mark.blunder { background: var(--danger); }
.rp-mark.on { outline: 2px solid var(--text); outline-offset: 1px; }
.rp-note { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; padding: 7px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); font-size: 0.86rem; }
.rp-note span { flex: 1; min-width: 180px; }
.rp-note .btn { padding: 5px 10px; font-size: 0.82rem; }

/* ---------- หน้าสกิน ---------- */
.modal-box.wide { max-width: 520px; }
.skin-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 220px;
  margin: 12px auto 4px;
  border: 6px solid var(--frame-1);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  container-type: inline-size;
}
.skin-preview i, .board-pv i { display: grid; place-items: center; aspect-ratio: 1; }
.skin-preview i.l, .board-pv i.l { background: var(--light-sq); }
.skin-preview i.d, .board-pv i.d { background: var(--dark-sq); }
.skin-preview .piece { width: 80%; height: 80%; }
.skin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
.skin-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.skin-item:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.skin-item.active { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); }
.skin-item strong { font-size: 0.88rem; font-weight: 500; }
.skin-item small { font-size: 0.7rem; color: var(--muted); text-align: center; line-height: 1.25; }
.skin-item.active small { color: var(--gold); }
.skin-item.locked .si-pv { filter: grayscale(0.85) brightness(0.6); }
.si-pv { display: flex; gap: 4px; width: 84px; height: 40px; align-items: center; justify-content: center; container-type: inline-size; }
.si-pv .piece { width: 38px; height: 38px; flex-shrink: 0; }
.board-pv { display: grid; grid-template-columns: repeat(2, 1fr); width: 44px; height: 44px; gap: 0; border-radius: 6px; overflow: hidden; border: 3px solid var(--frame-1); }

/* ---------- ภารกิจ / เหรียญตรา ---------- */
.modal-box h2.mt { margin-top: 20px; }
.mission-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mission {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  grid-template-areas: 'icon label n' 'icon bar bar';
  align-items: center;
  gap: 2px 10px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
}
.mission.done { background: rgba(95, 224, 160, 0.12); }
.mi-icon { grid-area: icon; font-size: 1.3rem; text-align: center; }
.mi-label { grid-area: label; font-size: 0.92rem; }
.mi-n { grid-area: n; color: var(--gold); font-size: 0.85rem; }
.mi-bar { grid-area: bar; height: 5px; border-radius: 99px; background: rgba(0, 0, 0, 0.35); overflow: hidden; }
.mi-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.mission.done .mi-bar i { background: var(--ok); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 12px; }
.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  background: linear-gradient(160deg, var(--gold-soft), var(--surface));
  border: 1px solid var(--border-strong);
}
.badge-item strong { font-size: 0.84rem; font-weight: 500; }
.badge-item small { font-size: 0.7rem; color: var(--muted); line-height: 1.25; }
.bi-icon { font-size: 1.8rem; line-height: 1.2; }
.badge-item.locked { background: var(--surface); border-color: var(--border); opacity: 0.55; }
.badge-item.locked .bi-icon { filter: grayscale(1); }

/* ---------- บัญชี: แรงก์ / เหรียญ ---------- */
.rank-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
}
.rk-icon { font-size: 2rem; }
.rk-body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rk-body strong { font-weight: 500; }
.rk-body small { color: var(--muted); font-size: 0.8rem; }
.rk-bar { height: 6px; border-radius: 99px; background: rgba(0, 0, 0, 0.4); overflow: hidden; }
.rk-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }
.rank-card.tier-diamond { border-color: rgba(143, 227, 255, 0.45); }
.rank-card.tier-master { border-color: rgba(255, 154, 90, 0.55); box-shadow: 0 0 18px -6px rgba(255, 120, 60, 0.6); }
.acct-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.mini-badge { font-size: 1.25rem; padding: 3px 5px; border-radius: 10px; background: var(--gold-soft); cursor: default; }

/* ทัวร์ยาวๆ เลื่อนในการ์ดเอง ไม่ดันแชทจนแผงทั้งแผงต้องเลื่อน */
.tour-bracket { max-height: 190px; overflow-y: auto; }
@media (max-width: 400px) {
  .cm-btn { padding: 5px 8px; font-size: 0.75rem; }
  .skin-grid, .badge-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .piece.skin-dragon, .dc-badge, .mode-card.quick .mode-icon, .quick-radar span { animation: none; }
}


/* ---------- เด้งกลางจอ 3 หมวด: เชียร์ / เยาะเย้ย / อารมณ์ ---------- */
.taunt-pop { --c1: #ff7a5c; --c2: #d8432c; --ink: #fff; --glow: rgba(255, 110, 80, 0.55); }
.taunt-pop.kind-cheer { --c1: #ffe07a; --c2: #f0891c; --ink: #3a1d00; --glow: rgba(255, 200, 70, 0.6); }
.taunt-pop.kind-mood { --c1: #b69bff; --c2: #5967ff; --ink: #fff; --glow: rgba(140, 130, 255, 0.55); }
.taunt-pop .tp-emoji, .taunt-pop .tp-text, .taunt-pop .tp-name { position: relative; z-index: 1; }
.tp-text {
  background: linear-gradient(180deg, var(--c1), var(--c2));
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.18), 0 0 28px var(--glow);
}
.kind-taunt .tp-text { text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.tp-name { box-shadow: inset 0 0 0 1px var(--glow); }
.kind-cheer .tp-emoji { animation-name: cheerJump; }
.kind-mood .tp-emoji { animation-name: moodFloat; animation-duration: 0.7s; }
@keyframes cheerJump {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-14%) scale(1.08) rotate(-6deg); }
  70% { transform: translateY(0) scale(0.96, 1.04); }
}
@keyframes moodFloat { 50% { transform: translateY(-6%) scale(1.06); } }

/* แสงรัศมีหมุนด้านหลังอีโมจิ */
.tp-burst {
  position: absolute;
  left: 50%;
  top: 36%;
  width: min(30rem, 92vmin);
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--glow) 0 18%, transparent 52%),
    repeating-conic-gradient(from 0deg, var(--glow) 0 7deg, transparent 7deg 22deg);
  -webkit-mask: radial-gradient(circle, #000 14%, transparent 68%);
  mask: radial-gradient(circle, #000 14%, transparent 68%);
  opacity: 0.85;
  animation: burstSpin 7s linear infinite;
  pointer-events: none;
}
@keyframes burstSpin { to { rotate: 360deg; } }

/* ประกายอีโมจิเล็กๆ พุ่งออกรอบตัว */
.tp-sparks { position: absolute; left: 50%; top: 36%; width: 0; height: 0; pointer-events: none; }
.tp-sparks span {
  position: absolute;
  left: 0;
  top: 0;
  font-size: clamp(1.4rem, 6vmin, 2.4rem);
  translate: -50% -50%;
  opacity: 0;
  animation: sparkOut 1.1s cubic-bezier(0.15, 0.8, 0.3, 1) forwards;
}
@keyframes sparkOut {
  0% { transform: rotate(var(--a)) translateY(0) scale(0.3); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(calc(var(--a) * -1)) scale(1); opacity: 0; }
}

/* ---------- แชท: แถบเลื่อนบาง + ปุ่มข้อความใหม่ ---------- */
.chat-log { scrollbar-width: thin; scrollbar-color: rgba(232, 182, 90, 0.35) transparent; }
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(232, 182, 90, 0.35); border-radius: 99px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log .chat-msg:last-child { animation: chatIn 0.28s ease-out; }
@keyframes chatIn { from { transform: translateY(8px); opacity: 0; } }
.chat-new {
  position: absolute;
  left: 50%;
  bottom: 58px;
  translate: -50% 0;
  z-index: 2;
  padding: 5px 14px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(180deg, #ffd889, var(--gold-2));
  color: #2a1a05;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  animation: chatNewIn 0.25s ease-out;
}
@keyframes chatNewIn { from { translate: -50% 10px; opacity: 0; } }

/* เสียงแซว 🔊 */
.taunt-pop.kind-sfx { --c1: #8dffbe; --c2: #16a862; --ink: #04260f; --glow: rgba(70, 255, 150, 0.5); }
.kind-sfx .tp-emoji { animation-name: sfxPulse; animation-duration: 0.42s; }
@keyframes sfxPulse {
  0%, 100% { transform: scale(1) rotate(0); }
  30% { transform: scale(1.18) rotate(-8deg); }
  60% { transform: scale(0.94) rotate(6deg); }
}
.react-tabs { flex-wrap: wrap; }

/* ---------- ใบประกาศเกียรติคุณ ---------- */
.cert-btn {
  background: linear-gradient(180deg, #ffe08a, #d39a26);
  border-color: #ffe08a;
  color: #2a1a05;
  font-weight: 600;
  box-shadow: 0 0 0 0 rgba(255, 210, 100, 0.6);
  animation: certGlow 1.8s ease-in-out infinite;
}
.cert-btn:hover { filter: brightness(1.06); }
@keyframes certGlow { 50% { box-shadow: 0 0 0 6px rgba(255, 210, 100, 0), 0 0 22px rgba(255, 210, 100, 0.55); } }
.modal-box.cert-box { max-width: 760px; }
.cert-frame { position: relative; margin: 12px 0; border-radius: 10px; overflow: hidden; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55); background: #f7e9c8; }
.cert-frame canvas { display: block; width: 100%; height: auto; }
.cert-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(20, 12, 6, 0.82);
  color: var(--gold);
}
.cert-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.cert-actions .btn { text-align: center; text-decoration: none; }
.fb-btn { background: #1877f2; border-color: #1877f2; color: #fff; font-weight: 500; }
.fb-btn:hover { background: #166fe5; border-color: #166fe5; }
.fb-btn b { font-family: Arial, sans-serif; font-weight: 900; margin-right: 4px; }
@media (prefers-reduced-motion: reduce) { .cert-btn { animation: none; } }

/* ---------- สติกเกอร์เสียงน้าค่อม ---------- */
img.sticker { display: block; width: 100%; height: auto; pointer-events: none; user-select: none; }
.react-grid.stickers { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.react-btn.sticker-btn {
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 2.2rem;
  line-height: 1.1;
}
.react-btn.sticker-btn img.sticker { width: min(64px, 100%); }
.react-btn.sticker-btn small {
  font-size: 0.64rem;
  line-height: 1.25;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}
.react-btn.sticker-btn:hover { transform: scale(1.05); }
@media (max-width: 400px) { .react-grid.stickers { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rf-emoji.sticker { width: clamp(64px, 16cqw, 96px); filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)); }
.tp-emoji img.tp-sticker { width: clamp(150px, 42vmin, 260px); filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.6)); }
.taunt-pop.kind-khom { --c1: #ffd35c; --c2: #e0782a; --ink: #2a1300; --glow: rgba(255, 190, 80, 0.6); }
.kind-khom .tp-emoji { animation-name: khomBob; animation-duration: 0.6s; }
.kind-khom .tp-text { font-size: clamp(1.1rem, 4.6vmin, 1.9rem); max-width: min(92vw, 560px); text-align: center; border-radius: 22px; }
@keyframes khomBob { 50% { transform: translateY(-6px) rotate(-4deg) scale(1.04); } }
body.fs .react-grid.stickers { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body.fs .react-btn.sticker-btn small { display: none; }

/* =====================================================================
   ฟีเจอร์ชุดที่ 2
   ===================================================================== */
.react-tabs { overflow-x: auto; scrollbar-width: none; }
.react-tabs::-webkit-scrollbar { display: none; }
.react-tabs button { flex: 1 0 auto; }
.segmented.wrap { display: flex; flex-wrap: wrap; }
.segmented.wrap button { flex: 1 1 auto; white-space: nowrap; padding: 8px 10px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.mini-btn {
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 8px;
  padding: 3px 8px;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { border-color: var(--border-strong); }
.mini-btn.danger { color: var(--danger); }
.mini-btn:disabled { opacity: 0.45; cursor: default; }
.p-acts { display: flex; gap: 4px; margin-left: 4px; }

/* ประกาศจากผู้ดูแล */
.announce {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(91, 156, 255, 0.22), rgba(91, 156, 255, 0.06));
  border: 1px solid rgba(120, 170, 255, 0.45);
  line-height: 1.45;
}

/* เมนู: ตะลุยโจทย์ / บทเรียน */
.menu-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.rush-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 200, 60, 0.45);
  background: linear-gradient(135deg, rgba(255, 196, 60, 0.2), rgba(255, 120, 40, 0.05));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, box-shadow 0.2s;
  min-width: 0;
}
.rush-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); }
.rush-card.lesson { border-color: rgba(120, 190, 255, 0.45); background: linear-gradient(135deg, rgba(110, 170, 255, 0.2), rgba(110, 170, 255, 0.04)); }
.rush-card.lesson.done { border-color: var(--border); background: var(--surface); }
.rc-icon { font-size: 1.8rem; line-height: 1; }
.rc-text { min-width: 0; }
.rc-text strong { display: block; font-weight: 500; font-size: 0.98rem; }
.rc-text small { color: var(--muted); font-size: 0.78rem; line-height: 1.3; display: block; }
@media (max-width: 360px) { .menu-duo { grid-template-columns: 1fr; } }

/* เมนู: ทัวร์ประจำสัปดาห์ */
.event-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, rgba(232, 182, 90, 0.18), rgba(232, 182, 90, 0.03));
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.event-card.live { animation: eventGlow 2s ease-in-out infinite; }
@keyframes eventGlow { 50% { box-shadow: 0 0 0 3px rgba(232, 182, 90, 0.25), 0 0 26px rgba(232, 182, 90, 0.35); } }
.ec-icon { font-size: 1.8rem; }
.ec-text { flex: 1; min-width: 0; }
.ec-text strong { display: block; font-weight: 500; }
.ec-text small { color: var(--muted); font-size: 0.85rem; }
.ec-cta { color: var(--gold); font-weight: 500; white-space: nowrap; font-size: 0.9rem; }
.ev-when { color: var(--gold); font-weight: 500; margin: 4px 0 8px; }
.dot-badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.72rem;
  line-height: 18px;
  text-align: center;
  text-decoration: none;
}

/* แถบบนกระดาน: บทเรียน / ตะลุยโจทย์ */
.mode-hud {
  width: min(100%, 560px);
  margin: 0 auto 8px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.mode-hud.lesson { border-color: rgba(120, 190, 255, 0.45); background: linear-gradient(135deg, rgba(110, 170, 255, 0.16), rgba(110, 170, 255, 0.03)); }
.mode-hud.rush { border-color: rgba(255, 200, 60, 0.5); background: linear-gradient(135deg, rgba(255, 196, 60, 0.16), rgba(255, 120, 40, 0.03)); }
.mh-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mh-title { font-weight: 500; }
.mh-right { display: flex; gap: 4px; align-items: center; }
.mh-text { margin: 6px 0 0; line-height: 1.5; }
.mh-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mh-actions:empty { display: none; }
.mh-actions .btn { padding: 7px 12px; font-size: 0.9rem; }
.lh-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); }
.lh-dot.ok { background: var(--ok); }
.lh-dot.cur { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.rush-clock { font-variant-numeric: tabular-nums; font-size: 1.15rem; color: var(--gold); }
.rush-clock.low { color: var(--danger); animation: rushPulse 0.5s ease-in-out infinite alternate; }
@keyframes rushPulse { to { transform: scale(1.12); } }

/* ทายผล */
.bet-card {
  background: linear-gradient(135deg, rgba(178, 120, 255, 0.16), rgba(178, 120, 255, 0.03));
  border: 1px solid rgba(190, 140, 255, 0.4);
  border-radius: 16px;
  padding: 10px 12px;
}
.bet-pool { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.bp-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bp-row.right { text-align: right; }
.bp-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: #1b1b1b; }
.bp-bar .bp-w { background: linear-gradient(90deg, #fff, #d9d2c6); transition: width 0.4s; }
.bp-bar .bp-b { flex: 1; background: linear-gradient(90deg, #444, #222); }
.bet-pick { margin-top: 8px; }
.bet-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bet-side { padding: 8px 6px; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bet-amounts { display: flex; gap: 4px; margin-top: 6px; }
.bet-amounts button {
  flex: 1;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 0;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.bet-amounts button::after { content: ' 🪙'; font-size: 0.75rem; }
.bet-amounts button.active { border-color: rgba(200, 150, 255, 0.8); background: rgba(178, 120, 255, 0.25); }
.bet-amounts button:disabled { opacity: 0.35; cursor: default; }
.bet-note { margin: 6px 0 0; font-size: 0.78rem; color: var(--muted); }

/* สมาชิก: เหรียญ / แผนก / ฤดูกาล */
.acct-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.coin-chip { flex: 1 1 100%; font-size: 0.88rem; color: var(--gold); }
.dept-row { display: flex; align-items: center; gap: 8px; flex: 1 1 100%; font-size: 0.9rem; }
.dept-row select {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
}
.acct-seasons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.acct-seasons .label { flex: 1 1 100%; margin: 8px 0 0; }
.season-chip { font-size: 0.8rem; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); }
.season-chip.gold { background: var(--gold-soft); color: var(--gold); }

/* ตารางแผนก */
.lb-row.dept { flex-wrap: wrap; }
.lb-row.dept .p-name { white-space: normal; }
.dept-bar { flex: 1 1 100%; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.dept-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); }

/* เพื่อน */
.friend-ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); }
.friend-row.offline { opacity: 0.65; }
.fr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fr-body strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-body small { font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-status { color: var(--ok); }
.friend-row.offline .fr-status { color: var(--muted); }
.friend-row .btn { padding: 6px 10px; font-size: 0.85rem; }
#friendsBody .label { margin-top: 14px; }

/* =====================================================================
   เกม X O
   ===================================================================== */
.xo-card .xo-icon { gap: 1px; font-size: 1.25rem; font-weight: 600; background: linear-gradient(135deg, rgba(255, 95, 110, 0.2), rgba(80, 170, 255, 0.2)); }
.xo-icon b { color: #ff6b7a; font-weight: 700; }
.xo-icon i { color: #5fb4ff; font-style: normal; font-weight: 700; }
.xo-variants button small { text-align: center; }
.xo-online { margin-top: 12px; }

.xo-board {
  --n: 3;
  --x: #ff5f6d;
  --o: #46a8ff;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n), minmax(0, 1fr));
  gap: 8px;
  aspect-ratio: 1;
  width: 100%;
  padding: 14px;
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(160deg, #2a1d12, #150e09);
  box-shadow: 0 0 0 2px rgba(232, 182, 90, 0.45), 0 24px 60px rgba(0, 0, 0, 0.65);
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.xc {
  position: relative;
  border-radius: 16px;
  background: rgba(255, 244, 228, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 230, 190, 0.1);
  display: grid;
  place-items: center;
  transition: background 0.15s, box-shadow 0.2s;
}
.xc.can { cursor: pointer; }
.xc.can:hover { background: rgba(255, 244, 228, 0.12); }
/* เงาตัวที่จะวาง ตอนชี้ */
.xo-board.playable .xc.can:hover::after {
  content: '';
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  opacity: 0.25;
  border: 0.9cqw solid var(--o);
}
.xo-board.playable[data-turn='x'] .xc.can:hover::after {
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(45deg, transparent 45%, var(--x) 45% 55%, transparent 55%),
    linear-gradient(-45deg, transparent 45%, var(--x) 45% 55%, transparent 55%);
}
.xc.last { box-shadow: inset 0 0 0 2px rgba(255, 220, 120, 0.55); }
.xo-m { position: absolute; inset: 10%; display: block; pointer-events: none; }
.xo-m svg { width: 100%; height: 100%; overflow: visible; }
.xo-m path, .xo-m circle { fill: none; stroke-linecap: round; stroke-width: 13; }
.xo-m.x path { stroke: var(--x); filter: drop-shadow(0 0 1.2cqw rgba(255, 95, 109, 0.55)); }
.xo-m.o circle { stroke: var(--o); filter: drop-shadow(0 0 1.2cqw rgba(70, 168, 255, 0.55)); }
/* วาดเส้นตอนวาง */
.xo-m.draw path, .xo-m.draw circle { stroke-dasharray: 190; stroke-dashoffset: 190; animation: xoDraw 0.32s ease-out forwards; }
.xo-m.draw path.d2 { animation-delay: 0.14s; }
.xo-m.draw { animation: xoPop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes xoDraw { to { stroke-dashoffset: 0; } }
@keyframes xoPop { from { transform: scale(0.6); } }
/* แบบหมากหายได้: ตัวที่จะหาย + เงาตอนหาย */
.xc.fading .xo-m { animation: xoFade 1.1s ease-in-out infinite alternate; }
.xc.fading::before { content: '⏳'; position: absolute; top: 6%; right: 8%; font-size: clamp(0.8rem, 4cqw, 1.3rem); opacity: 0.8; }
@keyframes xoFade { to { opacity: 0.28; transform: scale(0.92); } }
.xo-m.ghost { animation: xoGone 0.65s ease-in forwards; }
@keyframes xoGone { to { opacity: 0; transform: scale(1.5) rotate(25deg); filter: blur(4px); } }
/* เรียงครบ */
.xc.win { background: rgba(255, 215, 90, 0.2); box-shadow: inset 0 0 0 2px rgba(255, 215, 90, 0.85), 0 0 3cqw rgba(255, 200, 70, 0.45); animation: xoWin 0.9s ease-in-out infinite alternate; }
@keyframes xoWin { to { background: rgba(255, 215, 90, 0.34); } }

/* กระดานใหญ่ 15×15: แบบกระดานโกะ วางบนจุดตัดเส้น */
.xo-board.big {
  gap: 0;
  padding: 2.2cqw;
  border-radius: 14px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(160deg, #d9a862, #b98142);
}
.xo-board.big .xc { border-radius: 0; background: none; box-shadow: none; }
.xo-board.big .xc::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(60, 30, 5, 0.55), rgba(60, 30, 5, 0.55)) center / 1px 100% no-repeat,
    linear-gradient(rgba(60, 30, 5, 0.55), rgba(60, 30, 5, 0.55)) center / 100% 1px no-repeat;
}
.xo-board.big .xc.can:hover { background: rgba(255, 255, 255, 0.18); }
.xo-board.big .xc.last { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.9); border-radius: 50%; }
.xo-board.big .xc.win { border-radius: 50%; background: rgba(255, 240, 150, 0.55); }
.xo-board.big .xo-m { inset: 6%; }
.xo-board.big .xo-m path, .xo-board.big .xo-m circle { stroke-width: 15; }
.xo-board.big .xo-m.x path { stroke: #c4162a; filter: none; }
.xo-board.big .xo-m.o circle { stroke: #0b5fb0; filter: none; }
.xo-board.big .xc.fading::before { content: none; }

/* แถบผู้เล่น */
.avatar.xo-x { box-shadow: 0 0 0 2px rgba(255, 95, 109, 0.7); }
.avatar.xo-o { box-shadow: 0 0 0 2px rgba(70, 168, 255, 0.7); }
.xo-mark-big { font-size: 1.5rem; line-height: 1; }
.xo-mark-big.x { color: #ff5f6d; }
.xo-mark-big.o { color: #46a8ff; }
