:root {
  --red: #0165fc;
  --red-dark: #014fc6;
  --red-soft: #e8f1ff;
  --navy: #1d3557;
  --teal: #1baf7a;
  --teal-soft: #e6f6f0;
  --gold: #eb6834;
  --gold-soft: #fdeee6;
  --bg: #f7f6f3;
  --card: #ffffff;
  --ink: #22303e;
  --ink-soft: #64748b;
  --line: #e8e6e1;
  --good: #1baf7a;
  --bad: #d03b3b;
  --bad-soft: #fdecec;
  --bad-dark: #a32c2c;
  --ok: #eb6834;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(29,53,87,.07), 0 10px 30px rgba(29,53,87,.06);
  --shadow-lg: 0 8px 40px rgba(29,53,87,.16);
}
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior:smooth; }
body { font-family:'Nunito',system-ui,sans-serif; background:var(--bg); color:var(--ink); min-height:100vh; }
button { font-family:inherit; cursor:pointer; border:none; }
input, textarea, select { font-family:inherit; }
#app { max-width: 1080px; margin:0 auto; padding: 0 16px 90px; }
#confetti { position:fixed; inset:0; pointer-events:none; z-index:999; }

.boot { display:flex; flex-direction:column; align-items:center; justify-content:center; height:80vh; gap:14px; color:var(--ink-soft); font-weight:700; }
.boot-paw { font-size:56px; animation: bounce 1s infinite alternate ease-in-out; }
@keyframes bounce { from { transform:translateY(0) rotate(-8deg);} to { transform:translateY(-14px) rotate(8deg);} }

/* ============ AUTH ============ */
.auth-wrap { min-height:92vh; display:flex; align-items:center; justify-content:center; }
.auth-card { background:var(--card); border-radius:26px; box-shadow:var(--shadow-lg); padding:38px 34px; width:100%; max-width:430px; }
.auth-logo { text-align:center; font-size:44px; }
.auth-title { text-align:center; font-size:26px; font-weight:900; color:var(--navy); margin-top:6px; }
.auth-sub { text-align:center; color:var(--ink-soft); font-size:14.5px; margin:6px 0 24px; }
.field { margin-bottom:14px; }
.field label { display:block; font-size:12.5px; font-weight:800; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-soft); margin-bottom:6px; }
.field input { width:100%; padding:13px 15px; border:2px solid var(--line); border-radius:12px; font-size:16px; font-weight:600; transition:border-color .15s; background:#fbfaf8; }
.field input:focus { outline:none; border-color:var(--red); background:#fff; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:14px 22px; border-radius:14px; font-size:16px; font-weight:800; transition: transform .1s, box-shadow .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background:var(--red); color:#fff; width:100%; box-shadow: 0 6px 16px rgba(1,101,252,.28); }
.btn-primary:hover { background:var(--red-dark); }
.btn-ghost { background:transparent; color:var(--ink-soft); font-weight:700; }
.btn-secondary { background:var(--navy); color:#fff; }
.btn-teal { background:var(--teal); color:#fff; }
.btn-small { padding:9px 16px; font-size:14px; border-radius:11px; }
.auth-toggle { text-align:center; margin-top:16px; font-size:14.5px; color:var(--ink-soft); font-weight:600; }
.auth-toggle a { color:var(--red); font-weight:800; cursor:pointer; text-decoration:none; }
.auth-err { background:var(--bad-soft); color:var(--bad-dark); border-radius:11px; padding:11px 14px; font-size:14px; font-weight:700; margin-bottom:14px; display:none; }

/* ============ HEADER ============ */
.topbar { display:flex; align-items:center; justify-content:space-between; padding:18px 2px 10px; gap:10px; flex-wrap:wrap; }
.brand { display:flex; align-items:center; gap:10px; font-weight:900; font-size:19px; color:var(--navy); cursor:pointer; }
.brand .paw { font-size:26px; }
.brand small { display:block; font-size:11px; color:var(--red); letter-spacing:.12em; text-transform:uppercase; font-weight:800; }
.top-right { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.chip { background:var(--card); border-radius:999px; padding:7px 14px; font-size:13.5px; font-weight:800; box-shadow:var(--shadow); display:inline-flex; gap:6px; align-items:center; color:var(--navy); }
.chip.xp { color:var(--gold); }
.nav { display:flex; gap:6px; margin:8px 0 20px; flex-wrap:wrap; }
.nav button { background:transparent; padding:9px 16px; border-radius:999px; font-weight:800; font-size:14.5px; color:var(--ink-soft); }
.nav button.active { background:var(--navy); color:#fff; }

/* ============ DASHBOARD ============ */
.hero { background:linear-gradient(120deg, var(--navy) 0%, #2c4a75 100%); color:#fff; border-radius:24px; padding:28px 30px; box-shadow:var(--shadow-lg); display:flex; justify-content:space-between; align-items:center; gap:18px; flex-wrap:wrap; }
.hero h1 { font-size:24px; font-weight:900; }
.hero p { opacity:.85; font-size:14.5px; margin-top:4px; max-width:480px; }
.hero .ring-wrap { text-align:center; }
.ring { position:relative; width:110px; height:110px; }
.ring svg { transform:rotate(-90deg); }
.ring .pct { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; font-weight:900; font-size:22px; }
.ring .pct small { font-size:10px; opacity:.8; font-weight:700; letter-spacing:.08em; }
.area-label { margin:26px 0 10px; font-size:13px; font-weight:900; text-transform:uppercase; letter-spacing:.1em; color:var(--ink-soft); }
.mod-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:14px; }
.mod-card { background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); padding:20px; cursor:pointer; transition:transform .12s, box-shadow .2s; position:relative; overflow:hidden; border: 2px solid transparent; }
.mod-card:hover { transform:translateY(-3px); box-shadow:var(--shadow-lg); }
.mod-card.done { border-color:var(--teal); }
.mod-card.locked { opacity:.55; cursor:not-allowed; }
.mod-icon { font-size:30px; }
.mod-num { position:absolute; top:14px; right:16px; font-size:12px; font-weight:900; color:var(--ink-soft); background:var(--bg); padding:4px 10px; border-radius:999px; }
.mod-title { font-weight:900; font-size:16.5px; margin-top:10px; color:var(--navy); line-height:1.25; }
.mod-sub { font-size:13px; color:var(--ink-soft); margin-top:5px; line-height:1.4; }
.mod-meta { display:flex; gap:8px; margin-top:12px; align-items:center; font-size:12.5px; font-weight:800; color:var(--ink-soft); }
.mod-bar { height:7px; background:var(--bg); border-radius:99px; margin-top:12px; overflow:hidden; }
.mod-bar i { display:block; height:100%; background:var(--teal); border-radius:99px; transition:width .4s; }
.badge-done { color:var(--teal); font-weight:900; }
.badge-score { background:var(--gold-soft); color:#c25415; padding:3px 9px; border-radius:99px; }

/* ============ MODULE PLAYER ============ */
.player-head { display:flex; align-items:center; gap:14px; margin-bottom:16px; flex-wrap:wrap; }
.player-head h2 { font-size:21px; font-weight:900; color:var(--navy); flex:1; min-width:200px; }
.dots { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:18px; }
.dot { width:26px; height:8px; background:#e2e0da; border-radius:99px; transition:background .3s; }
.dot.on { background:var(--teal); }
.dot.now { background:var(--red); }
.stage { background:var(--card); border-radius:24px; box-shadow:var(--shadow); padding:30px; min-height:380px; }
.stage h3 { font-size:22px; font-weight:900; color:var(--navy); margin-bottom:6px; }
.stage .lead { color:var(--ink-soft); font-size:15px; margin-bottom:20px; line-height:1.55; font-weight:600; }
.stage-foot { display:flex; justify-content:space-between; align-items:center; margin-top:26px; gap:10px; flex-wrap:wrap; }
.count-tag { font-size:13px; font-weight:800; color:var(--ink-soft); }

/* learn cards */
.lcard { background:linear-gradient(135deg,#fff 0%,#faf8f4 100%); border:2px solid var(--line); border-radius:20px; padding:28px; min-height:230px; display:flex; flex-direction:column; justify-content:center; animation:pop .25s ease; }
@keyframes pop { from { opacity:0; transform:scale(.97);} to { opacity:1; transform:scale(1);} }
.lcard .lc-title { font-size:19px; font-weight:900; color:var(--red); margin-bottom:10px; }
.lcard .lc-body { font-size:16.5px; line-height:1.65; font-weight:600; }
.lcard .lc-ex { margin-top:14px; background:var(--teal-soft); border-left:4px solid var(--teal); padding:12px 16px; border-radius:0 12px 12px 0; font-size:14.5px; line-height:1.55; font-weight:600; color:#12805e; }

/* options / mcq */
.opt { display:block; width:100%; text-align:left; background:#fbfaf8; border:2px solid var(--line); border-radius:14px; padding:15px 18px; font-size:15.5px; font-weight:700; margin-bottom:10px; transition:all .15s; line-height:1.45; color:var(--ink); }
.opt:hover { border-color:var(--navy); background:#fff; }
.opt.sel-good { border-color:var(--good); background:var(--teal-soft); }
.opt.sel-bad { border-color:var(--bad); background:var(--bad-soft); }
.opt.sel-ok { border-color:var(--ok); background:var(--gold-soft); }
.opt.reveal-good { border-color:var(--good); }
.opt:disabled { cursor:default; opacity:.85; }
.why { border-radius:14px; padding:14px 18px; font-size:14.5px; font-weight:700; line-height:1.5; margin-top:6px; animation:pop .25s; }
.why.good { background:var(--teal-soft); color:#12805e; }
.why.bad { background:var(--bad-soft); color:var(--bad-dark); }
.why.ok { background:var(--gold-soft); color:#b04f16; }
.situ { background:var(--navy); color:#fff; border-radius:16px; padding:16px 20px; font-size:15.5px; font-weight:700; line-height:1.5; margin-bottom:14px; }

/* match game */
.match-cols { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.match-item { background:#fbfaf8; border:2px solid var(--line); border-radius:13px; padding:13px 15px; font-size:13.8px; font-weight:700; cursor:pointer; transition:all .15s; line-height:1.4; }
.match-item.picked { border-color:var(--navy); background:#eef2f8; }
.match-item.matched { border-color:var(--good); background:var(--teal-soft); opacity:.75; cursor:default; }
.match-item.wrong { border-color:var(--bad); background:var(--bad-soft); animation:shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* order game */
.order-pool, .order-out { display:flex; flex-direction:column; gap:8px; }
.order-out { min-height:50px; margin-bottom:16px; }
.order-slot { background:var(--teal-soft); border:2px solid var(--teal); border-radius:13px; padding:12px 15px; font-size:14px; font-weight:700; line-height:1.4; }
.order-slot .n { color:var(--teal); font-weight:900; margin-right:8px; }
.order-item { background:#fbfaf8; border:2px solid var(--line); border-radius:13px; padding:12px 15px; font-size:14px; font-weight:700; cursor:pointer; line-height:1.4; transition:all .15s; }
.order-item:hover { border-color:var(--navy); }
.order-item.wrong { border-color:var(--bad); background:var(--bad-soft); animation:shake .3s; }

/* label drill */
.drill-box textarea { width:100%; min-height:100px; border:2px solid var(--line); border-radius:14px; padding:15px; font-size:16px; font-weight:600; resize:vertical; background:#fbfaf8; }
.drill-box textarea:focus { outline:none; border-color:var(--red); background:#fff; }
.sample { background:var(--gold-soft); border-left:4px solid var(--gold); padding:13px 16px; border-radius:0 12px 12px 0; font-size:14.5px; font-weight:600; line-height:1.5; margin-top:12px; color:#8f3f12; }

/* roleplay */
.rp-scene { background:var(--gold-soft); border-radius:14px; padding:14px 18px; font-size:14px; font-weight:700; color:#8f3f12; margin-bottom:16px; line-height:1.5; }
.rp-chat { display:flex; flex-direction:column; gap:12px; margin-bottom:18px; max-height:340px; overflow-y:auto; padding:4px; }
.bubble { max-width:82%; padding:13px 17px; border-radius:18px; font-size:15px; font-weight:600; line-height:1.5; animation:pop .3s; }
.bubble.cust { background:#eef2f8; color:var(--navy); border-bottom-left-radius:4px; align-self:flex-start; }
.bubble.rep { background:var(--red); color:#fff; border-bottom-right-radius:4px; align-self:flex-end; }
.bubble.coach { background:var(--teal-soft); color:#12805e; align-self:center; max-width:94%; font-size:13.5px; border-radius:12px; border:1.5px dashed var(--teal); }
.bubble .who { display:block; font-size:10.5px; font-weight:900; letter-spacing:.08em; text-transform:uppercase; opacity:.65; margin-bottom:3px; }
.rp-speaker { background:none; font-size:17px; cursor:pointer; border:none; padding:0 4px; }

/* quiz */
.quiz-track { font-size:13px; font-weight:900; color:var(--ink-soft); margin-bottom:14px; }
.quiz-q { font-size:18px; font-weight:800; line-height:1.5; margin-bottom:16px; color:var(--navy); }
.result-card { text-align:center; padding:30px 10px; }
.result-emoji { font-size:64px; }
.result-title { font-size:26px; font-weight:900; color:var(--navy); margin-top:10px; }
.result-sub { color:var(--ink-soft); font-weight:700; margin-top:6px; font-size:15px; }
.score-big { font-size:52px; font-weight:900; margin-top:12px; }
.score-big.pass { color:var(--teal); }
.score-big.fail { color:var(--red); }

/* flashcards */
.flash { perspective:1200px; cursor:pointer; height:250px; }
.flash-inner { position:relative; width:100%; height:100%; transition:transform .5s; transform-style:preserve-3d; }
.flash.flipped .flash-inner { transform:rotateY(180deg); }
.flash-face { position:absolute; inset:0; backface-visibility:hidden; border-radius:20px; display:flex; align-items:center; justify-content:center; padding:30px; text-align:center; font-weight:800; font-size:17px; line-height:1.55; box-shadow:var(--shadow); }
.flash-front { background:var(--navy); color:#fff; }
.flash-back { background:var(--card); color:var(--ink); transform:rotateY(180deg); border:2px solid var(--teal); }

/* library */
.lib-cat { background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); margin-bottom:12px; overflow:hidden; }
.lib-cat-head { display:flex; align-items:center; gap:10px; padding:16px 20px; cursor:pointer; font-weight:900; font-size:16px; color:var(--navy); }
.lib-cat-head .arrow { margin-left:auto; transition:transform .2s; color:var(--ink-soft); }
.lib-cat.open .arrow { transform:rotate(90deg); }
.lib-phrases { display:none; padding:0 20px 16px; }
.lib-cat.open .lib-phrases { display:block; }
.lib-p { padding:12px 16px; background:#fbfaf8; border-radius:11px; margin-bottom:8px; font-size:14.5px; font-weight:600; line-height:1.5; display:flex; justify-content:space-between; gap:10px; align-items:center; }
.lib-p button { background:none; font-size:16px; opacity:.6; }
.lib-p button:hover { opacity:1; }

/* admin */
.admin-card { background:var(--card); border-radius:var(--radius); box-shadow:var(--shadow); padding:24px; margin-bottom:16px; }
.admin-card h3 { color:var(--navy); font-size:18px; margin-bottom:12px; }
.table-wrap { overflow-x:auto; }
table.progress { width:100%; border-collapse:collapse; font-size:13.5px; }
table.progress th { text-align:left; padding:9px 10px; font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--ink-soft); border-bottom:2px solid var(--line); white-space:nowrap; }
table.progress td { padding:10px; border-bottom:1px solid var(--line); font-weight:700; white-space:nowrap; }
.cell-done { color:var(--teal); font-weight:900; }
.cell-part { color:var(--gold); font-weight:900; }
.cell-none { color:#cbd5e1; }
.mgr-row { display:flex; gap:8px; margin-bottom:8px; align-items:center; }
.mgr-row input { flex:1; padding:10px 13px; border:2px solid var(--line); border-radius:10px; font-size:14.5px; font-weight:600; }
.pill { display:inline-flex; align-items:center; gap:6px; background:var(--bg); padding:6px 12px; border-radius:999px; font-size:13px; font-weight:800; margin:0 6px 6px 0; }
.pill button { background:none; color:var(--red); font-weight:900; }

.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--navy); color:#fff; padding:13px 22px; border-radius:14px; font-weight:800; font-size:14.5px; box-shadow:var(--shadow-lg); z-index:1000; animation:pop .25s; max-width:90vw; text-align:center; }

@media (max-width: 640px) {
  .stage { padding:20px 16px; }
  .match-cols { grid-template-columns:1fr; }
  .hero { padding:22px 20px; }
  .mod-grid { grid-template-columns:1fr 1fr; }
}
@media (max-width: 460px) {
  .mod-grid { grid-template-columns:1fr; }
}
