/* ============================================================
   HW Family — Minimal Luxury design system
   ============================================================ */
:root {
  /* ===== Theme C — Soft Pastel (kid-friendly, gentle on the eyes) ===== */
  --bg:         #FBF8FF;   /* soft lavender white */
  --surface:    #ffffff;
  --surface-2:  #F6F2FF;   /* light lavender tint */
  --ink:        #3E3550;   /* soft deep plum (not pure black = less eye strain) */
  --ink-soft:   #5B5170;
  --muted:      #9089A3;   /* soft mauve gray */
  --line:       #ECE7F6;   /* soft hairline */
  --line-2:     #DCD4EE;
  --primary:    #8B7CF0;   /* lavender */
  --primary-deep:#6E59E0;  /* deeper lavender for links/contrast */
  --accent:     #FF9EB5;   /* soft pink */
  --accent-soft:#FFE5EC;
  --ok:         #3FC79A;   /* soft mint green */
  --err:        #FB7D6B;   /* soft coral */
  --radius:     22px;
  --radius-sm:  14px;
  --shadow:     0 2px 6px rgba(95,75,150,.06), 0 18px 40px -22px rgba(95,75,150,.26);
  --shadow-sm:  0 2px 5px rgba(95,75,150,.07), 0 10px 22px -14px rgba(95,75,150,.28);
  /* ฟอนต์ตัวจีน: ค่าเริ่มต้น = ตัวเขียน Kaiti (楷体) เหมือนข้อสอบระดับต้น/หัดเขียน
     สลับเป็นตัวพิมพ์ Songti (宋体) ได้ด้วยคลาส html.zh-song (ปุ่มสลับ) */
  --zh-kai:  "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", "Kaiti TC", "BiauKai", "楷体", serif;
  --zh-song: "Noto Serif SC", "Songti SC", "STSong", "Songti TC", "SimSun", "宋体", serif;
  --zh: var(--zh-kai);
}
html.zh-song { --zh: var(--zh-song); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', var(--zh), system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .005em;
}
h1, h2, h3, .display {
  font-family: 'Mali', Georgia, serif;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.01em;
  color: var(--ink);
}
a { color: var(--primary-deep); text-decoration: none; }
.muted { color: var(--muted); }
.eyebrow {
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; color: var(--accent);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251,248,255,.82);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 1.15rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--ink); color: var(--bg); font-family: 'Mali', serif; font-weight: 600; font-size: 1.45rem;
}
.brand-text { font-family: 'Mali', serif; font-weight: 600; font-size: 1.35rem; color: var(--ink); display: flex; flex-direction: column; line-height: 1.05; }
.brand-text small { font-family: 'Plus Jakarta Sans'; font-weight: 600; font-size: .6rem; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; margin-top: 2px; }
.mainnav { margin-left: auto; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.mainnav a {
  padding: .62rem 1.05rem; border-radius: 11px; font-weight: 600; color: var(--ink-soft);
  font-size: 1.08rem; transition: color .15s, background .15s;
}
.mainnav a:hover { color: var(--ink); background: rgba(0,0,0,.04); }
/* ปุ่มของหน้าที่กำลังอยู่: แถบสีไฮไลต์ค้างไว้ */
.mainnav a.active, .mainnav a.active:hover { background: var(--ink); color: #fff; }
.nav-profile { display: inline-flex; align-items: center; gap: .55rem; }
.nav-ava { font-size: 1.75rem; }
.nav-admin { color: var(--primary); }
.nav-muted { color: var(--muted); }
.nav-toggle { display: none; margin-left: auto; border: 1px solid var(--line-2); background: var(--surface); font-size: 1.2rem;
  width: 44px; height: 44px; border-radius: 11px; cursor: pointer; color: var(--ink); }

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 2.4rem 1.5rem 4rem; }
.section-title { font-size: 1.7rem; margin: .2rem 0 1.2rem; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 2.4rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.5rem; border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  font-family: 'Plus Jakarta Sans'; font-weight: 700; font-size: .95rem; color: #fff;
  background: var(--ink); transition: transform .14s ease, opacity .15s, background .15s; text-decoration: none;
  letter-spacing: .01em;
}
.btn:hover { transform: translateY(-2px); opacity: .94; }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); }
.btn-orange  { background: var(--accent); color: #fff; }
.btn-green   { background: var(--ok); }
.btn-lg { padding: .95rem 1.9rem; font-size: 1.02rem; }
.btn-sm { padding: .45rem 1rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: rgba(0,0,0,.03); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 1.8rem;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.grid { display: grid; gap: 1.3rem; }
.grid-games { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* ---------- Hero (dark luxe) ---------- */
.hero {
  background: linear-gradient(135deg, #EFE9FF 0%, #FBEFF6 52%, #E7F7F0 100%);
  color: var(--ink); border-radius: 28px; padding: 4rem 3rem; box-shadow: var(--shadow);
  position: relative; overflow: hidden; border: 1px solid var(--line);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(50% 70% at 100% 0%, rgba(139,124,240,.16), transparent 70%);
  pointer-events: none;
}
.hero .eyebrow { color: var(--primary-deep); }
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); margin: .6rem 0 .8rem; color: var(--ink); font-weight: 600; }
.hero h1 em { font-style: italic; color: var(--primary); }
.hero p { font-size: 1.12rem; max-width: 36rem; margin: 0 0 1.8rem; color: var(--ink-soft); }
.hero .btn-ghost { color: var(--ink); border-color: var(--line-2); }
.hero .btn-ghost:hover { background: rgba(139,124,240,.08); }
.emoji-rain { display: none; }

/* ---------- Game cards ---------- */
.game-card {
  display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  transition: transform .16s ease, border-color .16s, box-shadow .16s; text-decoration: none; color: var(--ink);
}
.game-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--shadow); }
.game-cover { height: 150px; display: flex; align-items: center; justify-content: center; font-size: 3.2rem;
  border-bottom: 1px solid var(--line); position: relative; }
.game-cover::after { content: ""; position: absolute; left: 1.6rem; bottom: 1rem; width: 28px; height: 2px; background: var(--accent); opacity: .8; }
.game-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* รูปอวตาร: ขนาด = 1em ปรับตาม font-size ของกล่องที่ครอบ (แทนอิโมจิเดิมได้ทันที) */
.ava-img { width: 1em; height: 1em; object-fit: cover; border-radius: 50%; display: inline-block;
  vertical-align: -.15em; box-shadow: 0 1px 3px rgba(95,75,150,.25); }
.game-body { padding: 1.3rem 1.5rem 1.6rem; }
.game-body h3 { margin: 0 0 .3rem; font-size: 1.28rem; }
.game-body p { margin: 0; font-size: .92rem; color: var(--muted); }
.badge { display: inline-block; padding: .28rem .75rem; border-radius: 999px; font-size: .72rem;
  font-weight: 700; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
  margin-top: .9rem; letter-spacing: .03em; }
.badge-soon { background: var(--accent-soft); color: #8a6d25; border-color: transparent; }

/* ---------- Forms ---------- */
.auth-wrap { max-width: 440px; margin: 2rem auto; }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .9rem; color: var(--ink-soft); }
.input {
  width: 100%; padding: .85rem 1rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; background: var(--surface-2); transition: border-color .15s, box-shadow .15s; color: var(--ink);
}
.input:focus { outline: 0; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px rgba(75,70,196,.12); }
.form-hint { font-size: .82rem; color: var(--muted); margin-top: .35rem; }

/* ---------- Flash ---------- */
.flash { padding: .85rem 1.15rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; font-size: .92rem;
  border: 1px solid var(--line); background: var(--surface); }
.flash-success { background: #edf7f1; color: #1d6b4a; border-color: #cdeadd; }
.flash-error   { background: #fbecea; color: #a23925; border-color: #f3d4cd; }
.flash-info    { background: #eef0fb; color: #3b3a86; border-color: #d9dbf3; }

/* ---------- Profiles ---------- */
.profile-grid { display: flex; flex-wrap: wrap; gap: 1.3rem; justify-content: center; }
.profile-pick {
  width: 168px; padding: 1.6rem 1rem; border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); border: 1px solid var(--line); cursor: pointer; text-align: center;
  transition: transform .16s, border-color .16s; text-decoration: none; color: var(--ink);
}
.profile-pick:hover { transform: translateY(-4px); border-color: var(--primary); }
.profile-ava { font-size: 3.2rem; line-height: 1; }
.profile-pick .pname { font-family: 'Mali', serif; font-weight: 600; font-size: 1.15rem; margin-top: .5rem; }
.profile-add { border: 1px dashed var(--line-2); box-shadow: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted); background: transparent; }

/* ---------- Stats ---------- */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat { flex: 1 1 130px; background: var(--surface); border-radius: var(--radius); padding: 1.4rem 1rem; text-align: center;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.stat .num { font-family: 'Mali', serif; font-size: 2.1rem; font-weight: 600; color: var(--ink); }
.stat .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
/* การ์ดสถิติแบบกดได้ (หน้า Overview + Vocabulary) */
a.stat { display: block; text-decoration: none; color: inherit; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
a.stat:hover { transform: translateY(-2px); border-color: var(--accent); }
a.stat.stat-active { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-sm); }
a.stat.stat-active .num { color: var(--accent); }
.progressbar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progressbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .4s ease; }

/* ---------- ปุ่มสลับฟอนต์จีน ตัวเขียน(楷体) / ตัวพิมพ์(宋体) ---------- */
.zh-toggle { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.zh-toggle-lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.zh-toggle button { font: inherit; font-size: .9rem; cursor: pointer; padding: .42rem .85rem;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-soft);
  border-radius: 999px; transition: border-color .12s ease, background .12s ease, color .12s ease; }
.zh-toggle button:hover { border-color: var(--accent); }
.zh-toggle button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 3rem; padding: 3rem 1.5rem; text-align: center; border-top: 1px solid var(--line); }
.footer-inner .brand-logo { margin: 0 auto .8rem; }
.footer-inner p { margin: .25rem 0; }

/* ---------- Admin ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
.table th { background: var(--surface-2); font-weight: 700; color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.table code { background: var(--surface-2); padding: .1rem .4rem; border-radius: 6px; font-size: .82rem; }
.admin-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.admin-tabs a { padding: .55rem 1.1rem; border-radius: 999px; background: var(--surface); font-weight: 600; font-size: .9rem;
  border: 1px solid var(--line); color: var(--ink-soft); }
.admin-tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .mainnav { display: none; width: 100%; flex-direction: column; align-items: stretch; margin-top: .7rem; }
  body.nav-open .mainnav { display: flex; }
  .topbar-inner { flex-wrap: wrap; }
  .mainnav a { padding: .8rem 1rem; }
  .hero { padding: 2.8rem 1.6rem; }
  .container { padding: 1.8rem 1.2rem 3rem; }
}

/* ---------- Decorative cartoon art (2026-06) ---------- */
/* มาสคอตมุมฮีโร่ — absolute เกาะขวาล่างของ .hero (ซึ่งมี position:relative;overflow:hidden อยู่แล้ว) */
.hero-art {
  position: absolute; right: 2.2rem; bottom: -.4rem;
  width: min(33%, 250px); max-height: 94%; object-fit: contain;
  pointer-events: none; filter: drop-shadow(0 12px 26px rgba(95,75,150,.20));
}
/* รูปอาร์ตทั่วไป (สถิติ/หัวการ์ด/แบนเนอร์) — ปรับขนาดด้วย width ที่จุดใช้ */
.art-img { display: inline-block; object-fit: contain; vertical-align: middle; }
/* มาสคอตต้อนรับเหนือการ์ด login/register */
.auth-mascot { display: block; width: 120px; margin: 0 auto -.2rem; pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(95,75,150,.18)); }
/* อาร์ตบนการ์ดสถิติ + ป้ายรางวัลเล็ก (ใช้ร่วมหลายหน้า) */
.stat-art { width: 40px; height: 40px; object-fit: contain; display: block; margin: 0 auto .3rem; }
.reward-badge { width: 22px; height: 22px; object-fit: contain; vertical-align: -5px; }
@media (max-width: 760px) {
  .hero-art { width: 150px; right: .5rem; opacity: .92; }
  .auth-mascot { width: 96px; }
  /* เมนูมือถือ (mockup 06): ปุ่ม CTA เต็มกว้าง + ปุ่ม ☰ ขอบไฮไลต์ตอนเปิด */
  .mainnav .btn { width: 100%; justify-content: center; }
  body.nav-open .nav-toggle { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
}
