/* ============================================================
   LinguaPlay Theme — ปรับจาก Design System (Image 26)
   Gamified tactile / dimensional flat • Dark mode สมบูรณ์
   ============================================================ */

:root {
  --lp-primary: #58cc02; --lp-primary-deep: #46a302; --lp-primary-dark: #1e5000;
  --lp-sky: #1cb0f6; --lp-sky-deep: #1899d6; --lp-sky-dark: #004666;
  --lp-orange: #ff9600; --lp-orange-deep: #cc7a00; --lp-orange-dark: #683a00;
  --lp-red: #ff4b4b; --lp-red-deep: #d33131;
  --lp-violet: #a463f8; --lp-violet-deep: #8544d6;

  --lp-bg: #f7f9fa; --lp-surface: #ffffff; --lp-surface-2: #f0f3f4;
  --lp-border: #e5e5e5; --lp-text: #3c3c3c; --lp-muted: #777777;

  --lp-shadow-card: 0 4px 0 0 var(--lp-border);
  --lp-radius: 1rem; --lp-radius-lg: 2rem;
  --lp-header-h: 64px;
}

[data-bs-theme="dark"] {
  --lp-bg: #131f14; --lp-surface: #1b2a1f; --lp-surface-2: #223527;
  --lp-border: #2e4535; --lp-text: #e8f0e8; --lp-muted: #9db3a2;
  --lp-primary-dark: #d6ffbe; --lp-sky-dark: #bfe9ff; --lp-orange-dark: #ffe1b3;
  --lp-shadow-card: 0 4px 0 0 #0d1610;
}

* { scrollbar-width: thin; }
body {
  background: var(--lp-bg); color: var(--lp-text);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.55;
  padding-bottom: 76px; /* เผื่อ bottom nav มือถือ */
}
@media (min-width: 992px) { body { padding-bottom: 0; } }

h1,h2,h3,h4,h5,h6,.fw-bolder,.fw-bold,button,.lp-brand { font-family: Rubik, "Nunito Sans", sans-serif; }
a { text-decoration: none; }

/* ---------- Material symbols helper ---------- */
.ms-icon {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal;
  line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block;
  white-space: nowrap; word-wrap: normal; direction: ltr;
  -webkit-font-feature-settings: "liga"; -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
  font-size: 20px; vertical-align: middle; user-select: none;
}
.ms-icon.big { font-size: 34px; }
.ms-icon.fire, .ms-icon.star { color: var(--lp-orange); }
.ms-icon.gem { color: var(--lp-sky); }
.ms-icon.heart { color: var(--lp-red); }

/* ---------- Header ---------- */
.lp-header {
  background: color-mix(in srgb, var(--lp-surface) 92%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 8px rgba(0,0,0,.05);
  z-index: 1040;
}
.lp-header-inner {
  height: var(--lp-header-h); max-width: 1280px; margin-inline: auto;
  padding-inline: .75rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.lp-logo { height: 34px; width: 34px; border-radius: 50%; object-fit: cover; }
.lp-brand { font-weight: 800; color: var(--lp-primary); font-size: 1.15rem; letter-spacing: -.02em; }
.lp-tagline { font-size: .72rem; color: var(--lp-muted); font-weight: 700; }
.lp-nav { display: flex; gap: .15rem; background: var(--lp-surface-2); padding: .2rem; border-radius: 9999px; }
.lp-nav a {
  padding: .35rem .9rem; border-radius: 9999px; font-size: .82rem; font-weight: 700; color: var(--lp-muted);
  transition: all .15s;
}
.lp-nav a:hover { color: var(--lp-text); }
.lp-nav a.active { background: var(--lp-primary); color: #fff; }

.lp-stat-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--lp-surface); border: 1px solid var(--lp-border);
  border-radius: 9999px; padding: .15rem .55rem; font-size: .78rem;
}
.lp-round-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--lp-border);
  background: var(--lp-surface); color: var(--lp-text); display: inline-flex;
  align-items: center; justify-content: center; transition: transform .1s;
  position: relative; flex-shrink: 0;
}
.lp-round-btn:hover { background: var(--lp-surface-2); }
.lp-round-btn:active { transform: translateY(2px); }
.lp-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--lp-primary);
  color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.lp-level { color: var(--lp-primary); font-size: .7rem; font-weight: 800; }

.lp-mobile-nav { border-top: 1px solid var(--lp-border); background: var(--lp-surface); padding: .5rem .75rem; }
.lp-mobile-nav a { display: block; padding: .6rem .75rem; border-radius: .8rem; font-weight: 700; color: var(--lp-text); }
.lp-mobile-nav a.active { background: var(--lp-primary); color: #fff; }

/* ---------- Buttons ---------- */
.btn-lp-primary {
  background: var(--lp-primary); color: #fff; font-weight: 700;
  box-shadow: 0 4px 0 0 var(--lp-primary-deep); border: 0;
}
.btn-lp-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--lp-primary-deep); }
.btn-lp-secondary {
  background: var(--lp-sky); color: #fff; font-weight: 700;
  box-shadow: 0 4px 0 0 var(--lp-sky-deep); border: 0;
}
.btn-lp-secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--lp-sky-deep); }
.btn-lp-ghost {
  background: var(--lp-surface); color: var(--lp-text); font-weight: 700;
  border: 2px solid var(--lp-border); box-shadow: 0 3px 0 0 var(--lp-border);
}
.btn-lp-ghost:active { transform: translateY(2px); box-shadow: none; }
.btn-lp-primary:hover, .btn-lp-secondary:hover, .btn-lp-ghost:hover { filter: brightness(1.05); color: #fff; }

/* ---------- Cards ---------- */
.lp-card {
  background: var(--lp-surface); border: 1px solid var(--lp-border);
  border-radius: var(--lp-radius); box-shadow: var(--lp-shadow-card);
}
.lp-card-header, .lp-card-footer {
  background: transparent; border-color: var(--lp-border); color: var(--lp-text);
}
.lp-soft { opacity: .92; }

/* ---------- Control bar / quests ---------- */
.lp-seg { display: inline-flex; background: var(--lp-surface-2); padding: .2rem; border-radius: 9999px; gap: .2rem; flex-wrap: wrap; }
.lp-seg button {
  border: 0; background: transparent; border-radius: 9999px; padding: .4rem .9rem;
  font-size: .8rem; font-weight: 700; color: var(--lp-muted);
  box-shadow: 0 3px 0 0 var(--lp-border); transition: all .15s;
}
.lp-seg button.active { background: var(--lp-surface); color: var(--lp-text); }
.lp-seg-sm button { padding: .3rem .6rem; font-size: .74rem; }
.lp-quest-ico {
  width: 42px; height: 42px; border-radius: 50%; background: var(--lp-orange);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 0 var(--lp-orange-deep); flex-shrink: 0;
}
.lp-progress { height: 12px; background: var(--lp-surface-2); border-radius: 9999px; }
.lp-progress .progress-bar { background: var(--lp-orange); border-radius: 9999px; }
.lp-green { color: var(--lp-primary); } .lp-orange { color: var(--lp-orange); }

/* ---------- Badges ---------- */
.lp-badge { font-size: .68rem; font-weight: 800; letter-spacing: .05em; padding: .15rem .55rem; border-radius: 9999px; text-transform: uppercase; }
.lp-badge-primary { background: var(--lp-primary); color: #fff; }
.lp-badge-sky { background: var(--lp-sky); color: #fff; }
.lp-badge-orange { background: var(--lp-orange); color: #fff; }
.lp-badge-green { background: color-mix(in srgb, var(--lp-primary) 18%, transparent); color: var(--lp-primary); }
.lp-star-pill {
  display: inline-flex; align-items: center; gap: .25rem; background: var(--lp-surface-2);
  padding: .35rem .8rem; border-radius: 9999px; font-weight: 700; font-size: .85rem; align-self: flex-start;
}
.lp-star-pill .ms-icon { color: var(--lp-orange); }
.lp-star-pill.muted { color: var(--lp-muted); }

/* ---------- Adventure map nodes ---------- */
.lp-world-ico {
  width: 48px; height: 48px; border-radius: 1rem; display: flex; align-items: center;
  justify-content: center; color: #fff; flex-shrink: 0;
}
.lp-world-ico.primary { background: var(--lp-primary); box-shadow: 0 4px 0 0 var(--lp-primary-deep); }
.lp-world-ico.sky { background: var(--lp-sky); box-shadow: 0 4px 0 0 var(--lp-sky-deep); }
.lp-world-ico.orange { background: var(--lp-orange); box-shadow: 0 4px 0 0 var(--lp-orange-deep); }

.lp-node-wrap { position: relative; max-width: 420px; margin-inline: auto; display: flex; flex-direction: column; align-items: center; gap: 1.4rem; padding-block: .5rem; }
.lp-node-wrap.compact { gap: 1rem; }
.lp-spine { position: absolute; top: 30px; bottom: 30px; left: 50%; width: 6px; transform: translateX(-50%); background: var(--lp-surface-2); border-radius: 9999px; }
.lp-node { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; transform: translateX(var(--nx, 0)); text-align: center; max-width: 230px; }
.lp-node-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; transition: transform .12s; position: relative; color: #fff;
}
.lp-node-btn:hover { transform: translateY(-3px); }
.lp-node-btn:active { transform: translateY(3px); }
.lp-node-btn .ms-icon.big { font-size: 38px; }
.lp-node-btn.done { background: var(--lp-primary); box-shadow: 0 6px 0 0 var(--lp-primary-deep); }
.lp-node-btn.current { width: 92px; height: 92px; background: var(--lp-primary); box-shadow: 0 8px 0 0 var(--lp-primary-deep); }
.lp-node-btn.current small { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.lp-node-btn.locked { background: var(--lp-surface-2); color: var(--lp-muted); box-shadow: 0 6px 0 0 var(--lp-border); }
.lp-chest { position: absolute; top: -10px; right: -12px; width: 34px; height: 34px; background: var(--lp-orange); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 2px 0 0 var(--lp-orange-deep); }
.lp-node-cap { margin-top: .4rem; background: var(--lp-surface); border: 1px solid var(--lp-border); border-radius: .9rem; padding: .35rem .6rem; display: flex; flex-direction: column; gap: 1px; box-shadow: 0 2px 0 0 var(--lp-border); }
.lp-node-cap b { font-size: .78rem; }
.lp-node-cap small { font-size: .7rem; }
.lp-bubble {
  background: var(--lp-surface); border: 1px solid var(--lp-border); box-shadow: 0 3px 0 0 var(--lp-border);
  border-radius: 9999px; padding: .3rem .8rem; font-weight: 700; font-size: .8rem;
  display: flex; align-items: center; gap: .4rem; margin-bottom: .4rem;
}
.bounce { animation: lp-bounce 1.6s infinite; }
@keyframes lp-bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-5px);} }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--lp-primary); }
.dot.ping { animation: lp-ping 1.2s infinite; }
@keyframes lp-ping { 0% { opacity: 1; } 50% { opacity: .35; } 100% { opacity: 1; } }

/* ---------- Table ---------- */
.lp-table-wrap { max-height: 65vh; overflow: auto; }
.lp-table { --bs-table-bg: transparent; --bs-table-color: var(--lp-text); margin: 0; }
.lp-table thead th {
  position: sticky; top: 0; background: var(--lp-surface); color: var(--lp-muted);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--lp-border);
  z-index: 2;
}
.lp-table td { border-color: var(--lp-border); font-size: .9rem; }
.lp-table tbody tr:hover { background: color-mix(in srgb, var(--lp-primary) 6%, transparent); }
.lp-word-img { width: 46px; height: 46px; border-radius: .8rem; object-fit: cover; background: var(--lp-surface-2); }
.lp-xp-pill { background: color-mix(in srgb, var(--lp-orange) 18%, transparent); color: var(--lp-orange); font-weight: 800; border-radius: 9999px; padding: .1rem .6rem; font-size: .8rem; }
.lp-star-cell { color: var(--lp-orange); letter-spacing: 1px; font-size: .85rem; }
.lp-ig { background: var(--lp-surface-2); border-color: var(--lp-border); color: var(--lp-muted); }
.lp-input { background: var(--lp-surface); border-color: var(--lp-border); color: var(--lp-text); border-radius: .9rem !important; }
.lp-input:focus { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--lp-primary) 25%, transparent); border-color: var(--lp-primary); }
.lp-level-pill { font-size: .7rem; font-weight: 800; padding: .12rem .55rem; border-radius: 9999px; }
.lp-level-beginner { background: color-mix(in srgb, var(--lp-primary) 16%, transparent); color: var(--lp-primary); }
.lp-level-intermediate { background: color-mix(in srgb, var(--lp-sky) 16%, transparent); color: var(--lp-sky); }
.lp-level-advanced { background: color-mix(in srgb, var(--lp-violet) 16%, transparent); color: var(--lp-violet); }

/* ---------- Chat ---------- */
.lp-chatbox { height: 55vh; min-height: 320px; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--lp-bg); }
.lp-msg { display: flex; gap: .5rem; max-width: 85%; }
.lp-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.lp-msg-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--lp-sky); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; font-size: .85rem; }
.lp-msg-bubble { background: var(--lp-surface); border: 1px solid var(--lp-border); border-radius: 1.1rem; padding: .45rem .8rem; box-shadow: 0 2px 0 0 var(--lp-border); }
.lp-msg.mine .lp-msg-bubble { background: color-mix(in srgb, var(--lp-primary) 16%, var(--lp-surface)); border-color: color-mix(in srgb, var(--lp-primary) 35%, transparent); }
.lp-msg-name { font-size: .7rem; font-weight: 800; color: var(--lp-muted); }
.lp-msg-text { font-size: .92rem; overflow-wrap: anywhere; }
.lp-msg-time { font-size: .65rem; color: var(--lp-muted); text-align: end; }
.room-item { border: 1px solid var(--lp-border); background: var(--lp-surface-2); border-radius: .9rem; padding: .55rem .7rem; cursor: pointer; transition: all .12s; }
.room-item:hover { background: var(--lp-surface); }
.room-item.active { background: color-mix(in srgb, var(--lp-primary) 14%, var(--lp-surface)); border-color: var(--lp-primary); }
.room-item b { font-size: .85rem; }

/* ---------- Leaderboard ---------- */
.lb-row { display: flex; align-items: center; gap: .6rem; background: var(--lp-surface-2); border-radius: .9rem; padding: .45rem .6rem; }
.lb-rank { width: 26px; height: 26px; border-radius: 50%; background: var(--lp-orange); color: #fff; font-weight: 800; font-size: .75rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lb-row:first-child .lb-rank { background: gold; color: #6a3b00; }
.lb-row.me { outline: 2px solid var(--lp-primary); }
.lb-name { font-weight: 700; font-size: .85rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-xp { font-weight: 800; color: var(--lp-orange); font-size: .8rem; }

/* ---------- Connection status ---------- */
.conn-row { display: flex; justify-content: space-between; gap: .5rem; }
.conn-ok { color: var(--lp-primary); font-weight: 700; }
.conn-warn { color: var(--lp-orange); font-weight: 700; }

/* ---------- Notifications ---------- */
.notif-badge {
  position: absolute; top: -4px; right: -4px; background: var(--lp-red); color: #fff;
  font-size: .62rem; font-weight: 800; min-width: 17px; height: 17px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center; padding-inline: 3px;
}
.lp-drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1080; }
.lp-drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(360px, 92vw);
  background: var(--lp-surface); box-shadow: -8px 0 30px rgba(0,0,0,.15);
  overflow-y: auto; animation: lp-slide .18s ease-out;
}
@keyframes lp-slide { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.notif-item { background: var(--lp-surface-2); border-radius: .9rem; padding: .55rem .75rem; }
.notif-item b { font-size: .82rem; }
.notif-item small { color: var(--lp-muted); }

/* ---------- Network banner ---------- */
.net-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1090; text-align: center;
  padding: .45rem 1rem; font-weight: 700; font-size: .85rem; color: #fff;
}
.net-banner.offline { background: var(--lp-red); }
.net-banner.online { background: var(--lp-primary); }

/* ---------- Ads (กลมกลืนกับธีม) ---------- */
.ad-slot {
  background: var(--lp-surface); border: 1px dashed var(--lp-border);
  border-radius: var(--lp-radius); min-height: 90px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: .5rem; padding: .6rem; overflow: hidden; color: var(--lp-muted); font-size: .78rem;
}
.ad-slot.ad-disabled { opacity: .55; min-height: 64px; gap: .35rem; }
.ad-slot .ad-unit { width: 100%; }
.ad-slot.ad-disabled .ms-icon { font-size: 18px; }

/* ---------- Admin ---------- */
.adm-metric { background: var(--lp-surface); border: 1px solid var(--lp-border); border-radius: var(--lp-radius); box-shadow: var(--lp-shadow-card); padding: 1rem 1.1rem; }
.adm-metric .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--lp-muted); font-weight: 800; }
.adm-metric .value { font-size: 1.7rem; font-weight: 800; font-family: Rubik; }
.adm-metric .ico { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.form-check.form-switch input { width: 2.8em; height: 1.4em; }
.ads-row { background: var(--lp-surface-2); border-radius: .9rem; padding: .6rem .8rem; display: flex; align-items: center; gap: .6rem; }
.ads-row .form-control { font-size: .75rem; }
.evt-type { font-size: .7rem; font-weight: 800; padding: .1rem .5rem; border-radius: 9999px; background: var(--lp-surface-2); }

/* ---------- Views / bottom nav ---------- */
.lp-view { animation: lp-fadein .18s ease-out; }
@keyframes lp-fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.lp-bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 1040;
  background: var(--lp-surface); border-top: 1px solid var(--lp-border);
  display: flex; justify-content: space-around; padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
}
.lp-bottomnav button {
  border: 0; background: transparent; color: var(--lp-muted); display: flex; flex-direction: column;
  align-items: center; gap: 1px; font-size: .62rem; font-weight: 700; border-radius: .9rem; padding: .25rem .8rem;
}
.lp-bottomnav button.active { color: var(--lp-primary); background: color-mix(in srgb, var(--lp-primary) 12%, transparent); }

/* ---------- Landing / pre-auth ---------- */
.pre-auth { display: flex; flex-direction: column; min-height: 100vh; justify-content: flex-start; }
.lp-feature-ico { border-radius: 1rem; padding: .5rem; color: #fff; }
.lp-feature-ico.primary { background: var(--lp-primary); }
.lp-feature-ico.secondary { background: var(--lp-sky); }
.lp-feature-ico.tertiary { background: var(--lp-orange); }

/* ---------- Toast ---------- */
.lp-toast-wrap { position: fixed; bottom: 90px; right: 12px; z-index: 1100; display: flex; flex-direction: column; gap: .5rem; }
@media (min-width: 992px) { .lp-toast-wrap { bottom: 20px; } }
.lp-toast {
  background: var(--lp-surface); color: var(--lp-text); border: 1px solid var(--lp-border);
  border-left: 5px solid var(--lp-primary); border-radius: .9rem; padding: .6rem .9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); font-size: .85rem; font-weight: 600; max-width: 320px;
  animation: lp-slide .2s ease-out;
}
.lp-toast.err { border-left-color: var(--lp-red); }
.lp-toast.info { border-left-color: var(--lp-sky); }

/* ---------- สตูดิโออ่านออกเสียง ---------- */
.studio-queue { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; padding: .2rem; }
.studio-item {
  display: flex; align-items: center; gap: .6rem; border: 1px solid var(--lp-border);
  background: var(--lp-surface-2); border-radius: .9rem; padding: .35rem .6rem; cursor: pointer;
  transition: all .12s; text-align: start; color: var(--lp-text);
}
.studio-item:hover { background: var(--lp-surface); }
.studio-item.active { border-color: var(--lp-primary); background: color-mix(in srgb, var(--lp-primary) 12%, var(--lp-surface)); }
.studio-item img { width: 36px; height: 36px; border-radius: .6rem; object-fit: cover; }
.studio-item span { flex-shrink: 0; }
.studio-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#voiceSeg button { display: flex; align-items: center; justify-content: center; gap: .3rem; }

/* ---------- เกมส์คำศัพท์ ---------- */
.game-card { cursor: pointer; transition: transform .12s; }
.game-card:hover { transform: translateY(-4px); }
.lp-feature-ico.sky2 { background: var(--lp-sky); }
.lp-feature-ico.violet2 { background: var(--lp-violet); }
.builder-slots { display: flex; justify-content: center; gap: .4rem; flex-wrap: wrap; margin: .8rem 0; }
.builder-slot {
  min-width: 44px; height: 52px; border: 2px dashed var(--lp-border); border-radius: .8rem;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800;
  font-family: Rubik; background: var(--lp-surface-2);
}
.builder-slot:not(.empty) { border-style: solid; border-color: var(--lp-primary); background: color-mix(in srgb, var(--lp-primary) 10%, var(--lp-surface)); }
.builder-tiles { display: flex; justify-content: center; gap: .4rem; flex-wrap: wrap; }
.builder-tile {
  width: 48px; height: 52px; border: 0; border-radius: .8rem; background: var(--lp-sky); color: #fff;
  font-size: 1.4rem; font-weight: 800; font-family: Rubik; box-shadow: 0 4px 0 0 var(--lp-sky-deep); cursor: pointer;
}
.builder-tile:active { transform: translateY(3px); box-shadow: none; }
.builder-tile.used { opacity: .35; box-shadow: none; transform: none; }
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; max-width: 560px; margin-inline: auto; }
@media (max-width: 480px) { .memory-grid { grid-template-columns: repeat(3, 1fr); } }
.memory-card {
  aspect-ratio: 1; border: 2px solid var(--lp-border); border-radius: 1rem; background: var(--lp-primary);
  position: relative; cursor: pointer; perspective: 600px; padding: 0;
}
.memory-card .memory-face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border-radius: .8rem; backface-visibility: hidden; transition: transform .25s; padding: .2rem;
  font-weight: 800; font-size: .85rem; font-family: Rubik;
}
.memory-card .front { background: var(--lp-primary); color: #fff; font-size: 1.6rem; }
.memory-card .back { background: var(--lp-surface); color: var(--lp-text); transform: rotateY(180deg); border: 1px solid var(--lp-border); }
.memory-card.flip .front { transform: rotateY(180deg); }
.memory-card.flip .back { transform: rotateY(0); }
.memory-card.matched { border-color: var(--lp-primary); pointer-events: none; }
.memory-card.matched .back { background: color-mix(in srgb, var(--lp-primary) 14%, var(--lp-surface)); color: var(--lp-primary); }
.game-q-timer { font-variant-numeric: tabular-nums; }

/* ---------- Duel game (ดวลคำศัพท์) ---------- */
.duel-vs { display: flex; align-items: center; justify-content: center; gap: 1.2rem; padding: .4rem 0 .6rem; }
.duel-player { display: flex; flex-direction: column; align-items: center; gap: .15rem; min-width: 84px; }
.duel-ava { width: 44px; height: 44px; font-size: 1.1rem; }
.duel-player:nth-child(3) .duel-ava { background: var(--lp-sky); }
.duel-score { font-family: Rubik; font-weight: 800; font-size: 1.3rem; color: var(--lp-primary); }
.duel-vs-badge {
  font-family: Rubik; font-weight: 800; font-size: 1rem; color: #fff;
  background: var(--lp-orange); border-radius: 9999px; padding: .35rem .8rem;
  box-shadow: 0 3px 0 0 var(--lp-orange-deep);
}
.duel-dot { width: 10px; height: 10px; border-radius: 9999px; background: var(--lp-surface-2); border: 1px solid var(--lp-border); display: inline-block; }
.duel-dot.done { background: var(--lp-primary); border-color: var(--lp-primary); }
.duel-dot.cur { background: var(--lp-orange); border-color: var(--lp-orange); animation: lp-ping 1.2s infinite; }
.duel-urgent { color: var(--lp-red) !important; font-weight: 800; }
.duel-q-img { width: 84px; height: 84px; border-radius: 1.2rem; object-fit: cover; box-shadow: 0 4px 0 0 var(--lp-border); }
.duel-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; max-width: 420px; margin-inline: auto; }
.duel-choice {
  border: 2px solid var(--lp-border); background: var(--lp-surface); color: var(--lp-text);
  border-radius: 9999px; padding: .65rem 1rem; font-weight: 700; font-size: .95rem; font-family: Rubik;
  box-shadow: 0 3px 0 0 var(--lp-border); transition: transform .08s; cursor: pointer;
}
.duel-choice:hover { background: var(--lp-surface-2); }
.duel-choice:active { transform: translateY(2px); box-shadow: none; }
.duel-choice.picked { border-color: var(--lp-primary); }
.duel-choice.right { border-color: var(--lp-primary); background: color-mix(in srgb, var(--lp-primary) 16%, var(--lp-surface)); }
.duel-choice.wrong { border-color: var(--lp-red); background: color-mix(in srgb, var(--lp-red) 12%, var(--lp-surface)); }
.duel-choice:disabled { cursor: default; opacity: .92; }
.duel-feedback { max-width: 420px; margin: .8rem auto 0; border-radius: .9rem; padding: .5rem .9rem; font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: .4rem; justify-content: center; }
.duel-feedback.ok { background: color-mix(in srgb, var(--lp-primary) 14%, var(--lp-surface)); color: var(--lp-primary); }
.duel-feedback.bad { background: color-mix(in srgb, var(--lp-red) 12%, var(--lp-surface)); color: var(--lp-red); }
@media (max-width: 420px) { .duel-choices { grid-template-columns: 1fr; } }

/* ลด motion ตามความชอบของผู้ใช้ */
@media (prefers-reduced-motion: reduce) {
  .bounce, .dot.ping, .lp-node-btn, .btn-lp-primary, .btn-lp-secondary, .duel-dot.cur { animation: none !important; transition: none !important; }
}
