:root{
  --bg:#FFF7E8; --card:#ffffff; --ink:#25304a; --muted:#5b6478;
  --green:#15803d; --green-bg:#dcfce7; --red:#b91c1c; --red-bg:#fee2e2;
  --brand:#ff5d5d; --brand-dark:#c73e3e; --yellow:#ffb703; --blue:#2563eb;
  --radius:20px;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;overflow-x:hidden}
body{
  font-family:system-ui,"Segoe UI",Roboto,"Noto Sans",sans-serif;
  background:#FFF3D6;
  color:var(--ink); min-height:100vh;
}

/* ===== Background vui: trời hồng + mặt trời + mây + anh đào rơi + đồi sóng ===== */
.bg{position:fixed;inset:0;z-index:0;overflow:hidden;pointer-events:none;
  background:linear-gradient(180deg,#ffd9e8 0%,#ffe9c9 34%,#FFF7E8 62%,#e8f6ff 100%)}
.sun{position:absolute;top:5%;right:7%;width:110px;height:110px;border-radius:50%;
  background:radial-gradient(circle at 35% 35%,#fff8cf,#ffcf5c 58%,#ff9d5c);
  box-shadow:0 0 60px 22px rgba(255,183,92,.45)}
.cloud{position:absolute;background:#fff;opacity:.85;border-radius:999px;filter:blur(1px)}
.cloud.c1{top:9%;left:6%;width:120px;height:34px;box-shadow:30px 8px 0 -4px #fff,-28px 10px 0 -6px #fff;
  animation:drift 14s ease-in-out infinite alternate}
.cloud.c2{top:22%;right:4%;width:90px;height:26px;box-shadow:24px 6px 0 -4px #fff,-22px 8px 0 -6px #fff;opacity:.7;
  animation:drift 18s ease-in-out infinite alternate-reverse}
@keyframes drift{from{transform:translateX(-12px)}to{transform:translateX(14px)}}
.petal{position:absolute;top:-8%;font-size:20px;opacity:.9;animation:fall linear infinite}
.petal.p1{left:6%;animation-duration:9s;animation-delay:0s}
.petal.p2{left:24%;animation-duration:12s;animation-delay:2s;font-size:15px}
.petal.p3{left:45%;animation-duration:10s;animation-delay:5s}
.petal.p4{left:63%;animation-duration:13s;animation-delay:1s;font-size:16px}
.petal.p5{left:80%;animation-duration:11s;animation-delay:4s}
.petal.p6{left:92%;animation-duration:14s;animation-delay:7s;font-size:14px}
@keyframes fall{
  0%{transform:translateY(-5vh) rotate(0deg);opacity:0}
  10%{opacity:.95}
  100%{transform:translateY(112vh) translateX(-6vw) rotate(340deg);opacity:.3}
}
.hills{position:absolute;left:0;right:0;bottom:0;height:170px;
  background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 170' preserveAspectRatio='none'%3E%3Cpath d='M0 110 Q120 60 240 100 T480 90 V170 H0 Z' fill='%23ffb703' fill-opacity='.18'/%3E%3Cpath d='M0 130 Q140 90 280 120 T480 115 V170 H0 Z' fill='%232563eb' fill-opacity='.12'/%3E%3Cpath d='M0 150 Q160 125 320 145 T480 142 V170 H0 Z' fill='%23ff5d5d' fill-opacity='.12'/%3E%3C/svg%3E") no-repeat bottom/100% 100%}
.app{position:relative;z-index:1;max-width:480px;margin:0 auto;padding:12px 12px 96px;min-height:100vh}

/* Header */
.topbar{position:sticky;top:0;z-index:5;background:rgba(255,255,255,.88);
  backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
  padding:10px 10px 12px;border-radius:0 0 24px 24px;
  border:2px solid #ffe1a8;border-top:none;box-shadow:0 4px 0 rgba(255,217,142,.6)}
.brand{display:flex;gap:10px;align-items:center}
.mascot{font-size:44px;line-height:1;filter:drop-shadow(0 3px 0 rgba(0,0,0,.08));
  animation:bob 2.4s ease-in-out infinite}
@keyframes bob{0%,100%{transform:translateY(0) rotate(-4deg)}50%{transform:translateY(-5px) rotate(4deg)}}
.brand h1{font-size:22px;margin:0;letter-spacing:.2px}
.tagline{margin:2px 0 0;font-size:13px;color:var(--muted)}
.stats{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.pill{background:#fff;border:2px solid #f1d9a0;border-radius:999px;
  padding:8px 12px;font-size:14px;min-height:44px;display:inline-flex;align-items:center;gap:4px;
  box-shadow:0 2px 0 #f1d9a0}
.pill b{font-size:15px}
.levelbar{height:10px;background:#f3e4bd;border-radius:99px;margin-top:8px;overflow:hidden}
.levelbar div{height:100%;width:0%;border-radius:99px;
  background:linear-gradient(90deg,var(--yellow),var(--brand));transition:width .5s}

/* Cards */
.card{background:var(--card);border-radius:var(--radius);padding:16px;margin:12px 0;
  border:2px solid #ffe1a8;box-shadow:0 4px 0 #ffd98e;animation:rise .25s ease-out}
@keyframes rise{from{transform:translateY(8px);opacity:.4}to{transform:none;opacity:1}}
.start-card{text-align:center;position:relative;overflow:hidden}
.start-card::before{content:"";position:absolute;inset:0 0 auto 0;height:8px;
  background:repeating-linear-gradient(90deg,var(--brand) 0 18px,var(--yellow) 18px 36px,#4ade80 36px 54px,#60a5fa 54px 72px);
  border-radius:var(--radius) var(--radius) 0 0}
.start-card .hello{margin-top:10px}
.hello{font-size:18px;font-weight:800;margin:4px 0 10px}
.hint{font-size:13px;color:var(--muted);line-height:1.5}
.seg{display:flex;gap:8px;margin:8px 0 12px}
.seg button{flex:1;min-height:48px;border-radius:14px;border:2px solid #e5e7eb;background:#f8fafc;
  color:var(--ink);font-size:14px;font-weight:700;cursor:pointer}
.seg button.on{background:#fff7d6;border-color:var(--yellow);box-shadow:0 2px 0 var(--yellow)}

/* Buttons: 1 verb, >=44px */
.btn-big{width:100%;min-height:56px;font-size:19px;font-weight:800;color:#fff;cursor:pointer;
  background:linear-gradient(180deg,#ff7b7b,var(--brand));border:none;border-radius:18px;
  box-shadow:0 5px 0 var(--brand-dark);transition:transform .08s}
.btn-big:active{transform:translateY(3px);box-shadow:0 2px 0 var(--brand-dark)}
.btn-mock{background:linear-gradient(180deg,#60a5fa,var(--blue));box-shadow:0 5px 0 #1e40af}
.btn-ghost{margin-top:10px;min-height:44px;border-radius:12px;border:2px dashed #cbd5e1;
  background:#fff;color:var(--muted);font-size:14px;padding:8px 16px;cursor:pointer}
.mock-card{border-color:#bfdbfe;box-shadow:0 4px 0 #93c5fd}

/* Quiz card: 1 question per screen */
.q-top{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px}
.q-count{font-size:13px;font-weight:800;background:#25304a;color:#fff;border-radius:99px;padding:6px 12px}
.timer{font-size:14px;font-weight:800;background:#fff7d6;border:2px solid var(--yellow);
  border-radius:99px;padding:6px 12px;color:#92400e;min-height:36px;display:inline-flex;align-items:center}
.timer.urgent{background:var(--red-bg);border-color:var(--red);color:var(--red);animation:shake .4s infinite}
@keyframes shake{0%,100%{transform:translateX(0)}25%{transform:translateX(-2px)}75%{transform:translateX(2px)}}
.progress{height:8px;background:#f1f5f9;border-radius:99px;overflow:hidden;margin:8px 0 4px}
.progress div{height:100%;background:linear-gradient(90deg,#4ade80,#22c55e);border-radius:99px;transition:width .3s}
.q{font-size:19px;line-height:1.55;font-weight:700;margin:12px 0 14px}
.q .sec-tag{font-size:12px;font-weight:800;color:#fff;background:#8b5cf6;border-radius:8px;padding:3px 8px;margin-right:6px;vertical-align:middle}

/* Choices: full-width, big */
.choice{display:flex;align-items:center;gap:10px;width:100%;text-align:left;
  margin:8px 0;padding:0 14px;min-height:56px;font-size:17px;font-weight:600;
  border:2px solid #e5e7eb;border-radius:16px;background:#fff;color:var(--ink);cursor:pointer;
  transition:transform .08s}
.choice:active{transform:scale(.98)}
.choice .key{flex:none;width:32px;height:32px;border-radius:50%;background:#f1f5f9;
  display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:800}
.choice:not(:disabled):hover{border-color:var(--yellow);background:#fffbeb}
.choice.correct{border-color:var(--green);background:var(--green-bg);color:#14532d}
.choice.correct .key{background:var(--green);color:#fff}
.choice.wrong{border-color:var(--red);background:var(--red-bg);color:#7f1d1d}
.choice.wrong .key{background:var(--red);color:#fff}
.choice:disabled{cursor:default;opacity:1}
.choice.picked{outline:3px solid #fde68a}

/* Order (sắp xếp): 4 ô đáp án + 4 mảnh bấm */
.order-slots{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin:10px 0}
.oslot{min-height:52px;font-size:17px;font-weight:700;border-radius:14px;
  border:2px dashed #cbd5e1;background:#f8fafc;color:var(--ink);cursor:pointer;padding:6px 4px}
.oslot.filled{border-style:solid;border-color:var(--yellow);background:#fffbeb}

/* Feedback: icon + text, not color-only */
.exp{margin-top:10px;border-radius:14px;padding:12px;font-size:15px;line-height:1.5;
  display:none}
.exp.show{display:block;animation:pop .25s}
.exp.ok{background:var(--green-bg);border:2px solid var(--green);color:#14532d}
.exp.ng{background:var(--red-bg);border:2px solid var(--red);color:#7f1d1d}
@keyframes pop{from{transform:scale(.96);opacity:0}to{transform:scale(1);opacity:1}}

.q-actions{display:flex;gap:8px;margin-top:10px}
.btn-skip{flex:1;min-height:48px;border-radius:14px;border:2px solid #e5e7eb;background:#fff;
  font-size:15px;font-weight:700;color:var(--muted);cursor:pointer}
.btn-next{flex:2;min-height:48px;border-radius:14px;border:none;font-size:16px;font-weight:800;
  background:#25304a;color:#fff;cursor:pointer}

/* Result */
.result{text-align:center;padding:8px 4px}
.result .big{font-size:52px;margin:0}
.result h3{margin:8px 0;font-size:20px}

/* Bottom nav: one-thumb */
.bottomnav{position:fixed;left:50%;transform:translateX(-50%);bottom:10px;z-index:10;
  width:min(480px,calc(100% - 20px));display:flex;gap:8px;background:#25304ad9;
  backdrop-filter:blur(8px);border-radius:22px;padding:8px}
.bottomnav[hidden]{display:none}
.bottomnav button{flex:1;min-height:56px;border:none;border-radius:16px;background:transparent;
  color:#cbd5e1;font-size:13px;font-weight:800;cursor:pointer;display:flex;flex-direction:column;
  align-items:center;justify-content:center;gap:2px}
.bottomnav button span{font-size:22px}
.bottomnav button.active{background:#fff;color:#25304a}

/* XP float */
#xpFloat{position:fixed;left:50%;top:40%;pointer-events:none;z-index:50}
.xp-pop{position:absolute;font-weight:900;font-size:22px;color:#16a34a;
  animation:fly 1s ease-out forwards;text-shadow:0 2px 0 #fff}
@keyframes fly{from{transform:translate(-50%,0);opacity:1}to{transform:translate(-50%,-90px);opacity:0}}

.fun-card h2{margin:0 0 8px;font-size:19px}
.exam-card{border-color:#fda4af;box-shadow:0 4px 0 #fb7185}
.btn-exam{background:linear-gradient(180deg,#fb7185,#e11d48);box-shadow:0 5px 0 #9f1239}
.rules{text-align:left;background:#fff1f2;border:2px dashed #fda4af;border-radius:14px;
  padding:10px 14px;margin:10px 0;font-size:14px;line-height:1.7}
.rules p{margin:4px 0}
.exam-grid{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.exam-grid button{min-width:44px;min-height:44px;border-radius:12px;border:2px solid #e5e7eb;
  background:#fff;font-size:14px;font-weight:800;color:var(--muted);cursor:pointer}
.exam-grid button.done{background:#dcfce7;border-color:var(--green);color:#14532d}
.exam-grid button.now{background:#25304a;border-color:#25304a;color:#fff}
.who{font-size:13px;color:var(--muted);margin-top:8px}
.linklike{border:none;background:none;color:var(--blue);font-size:13px;font-weight:700;cursor:pointer;
  min-height:44px;padding:8px;text-decoration:underline}
.reg-form{display:grid;gap:6px;text-align:left;margin:10px 0}
.reg-form label{font-size:13px;font-weight:800}
.reg-form input{min-height:52px;font-size:17px;border:2px solid #e5e7eb;border-radius:14px;
  padding:8px 14px;color:var(--ink);background:#fff;width:100%}
.reg-form input:focus{border-color:var(--yellow);outline:none}
.reg-err{background:var(--red-bg);border:2px solid var(--red);border-radius:12px;color:#7f1d1d;
  font-size:14px;padding:10px;margin:8px 0}
#guestBtn{margin-top:8px;width:100%}

/* Leaderboard */
.board-row{display:flex;align-items:center;gap:10px;padding:10px 12px;margin:6px 0;
  background:#f8fafc;border:2px solid #e5e7eb;border-radius:14px;font-size:15px;min-height:52px}
.board-row .rank{font-size:18px;font-weight:900;min-width:34px;text-align:center}
.board-row .who-name{flex:1;font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.board-row .pts{font-weight:800;white-space:nowrap}
.board-row.me{background:#fff7d6;border-color:var(--yellow);box-shadow:0 2px 0 var(--yellow)}
.board-empty{text-align:center;color:var(--muted);font-size:14px;padding:12px}
.my-rank{margin-top:8px;font-size:15px;font-weight:800;text-align:center}
.badges{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}
.badge{background:#fff7d6;border:2px solid var(--yellow);border-radius:14px;padding:8px 12px;font-size:14px;font-weight:700}
.net-err{background:var(--red-bg);border:2px solid var(--red);border-radius:14px;padding:14px;
  font-size:15px;color:#7f1d1d;text-align:center}
.net-err button{margin-top:8px;min-height:48px;width:100%;border-radius:12px;border:none;
  background:var(--red);color:#fff;font-size:16px;font-weight:800;cursor:pointer}

/* Contrast + focus */
button:focus-visible{outline:3px solid var(--blue);outline-offset:2px}
@media (max-width:360px){.app{padding:8px 8px 96px}.q{font-size:18px}.choice{font-size:16px}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
.passage{background:#f8fafc;border-left:4px solid #8b5cf6;border-radius:8px;padding:10px 12px;margin:10px 0;font-size:15px;line-height:1.9;white-space:pre-wrap}
.btn-listen{display:block;width:100%;margin:10px 0;padding:12px;border:none;border-radius:12px;background:#0ea5e9;color:#fff;font-size:16px;font-weight:800;cursor:pointer}
.btn-listen:disabled{opacity:.55;cursor:default}
