:root {
  --mint: #7be0b0; --mint2: #3fcf9b; --mint-soft: #d9f7e8; --mint-ink: #0b6b4b;
  --peach: #ffb899; --peach2: #ff9f7e; --peach-soft: #ffe6d8;
  --ink: #1d3b35; --muted: #5b7a72; --warn: #d9480f;
  --radius: 26px; --shadow: 0 10px 30px rgba(255, 159, 126, .22), 0 2px 6px rgba(63, 207, 155, .15);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font: 17px/1.5 var(--font); color: var(--ink);
  background: linear-gradient(160deg, #d9f7e8 0%, #fff3ea 52%, #ffd8c2 100%) fixed;
  overflow-x: hidden;
}
/* floating background blobs */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.bg i { position: absolute; border-radius: 50%; filter: blur(8px); opacity: .55; animation: drift 14s ease-in-out infinite alternate; }
.bg i:nth-child(1) { width: 260px; height: 260px; left: -80px; top: 8%; background: radial-gradient(circle at 30% 30%, #b6f3d4, #7be0b0); }
.bg i:nth-child(2) { width: 200px; height: 200px; right: -60px; top: 30%; background: radial-gradient(circle at 30% 30%, #ffd9c4, #ffb899); animation-duration: 18s; }
.bg i:nth-child(3) { width: 180px; height: 180px; left: 20%; bottom: -60px; background: radial-gradient(circle at 30% 30%, #ffe6d8, #ffc9ac); animation-duration: 16s; }
.bg i:nth-child(4) { width: 140px; height: 140px; right: 12%; bottom: 8%; background: radial-gradient(circle at 30% 30%, #d9f7e8, #8fe9bf); animation-duration: 20s; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(30px, -40px) scale(1.12); } }

/* HUD */
.hud { position: sticky; top: 0; z-index: 10; padding: 10px 16px 8px; background: linear-gradient(180deg, rgba(255, 255, 255, .85), rgba(255, 255, 255, .55)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hud[hidden] { display: none; }
.hud-in { max-width: 560px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.logo { color: var(--mint-ink); }
.xp { background: linear-gradient(135deg, #fff1c9, #ffd978); padding: 4px 14px; border-radius: 99px; box-shadow: 0 2px 8px rgba(255, 190, 70, .35); }
.xp.bump { animation: bump .45s ease; }
.track { max-width: 560px; margin: 8px auto 0; height: 12px; border-radius: 99px; background: rgba(255, 255, 255, .8); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .08); }
.track i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--mint), var(--peach2)); transition: width .5s cubic-bezier(.3, 1.4, .5, 1); position: relative; }
.track i::after { content: "🚀"; position: absolute; right: -8px; top: -10px; font-size: 20px; transform: rotate(45deg); }

main { max-width: 560px; margin: 0 auto; padding: 18px 16px 60px; }
.loading { text-align: center; color: var(--muted); margin-top: 30vh; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 6px 0 10px; font-weight: 900; }
h2 { font-size: 1.25rem; margin: 0 0 6px; font-weight: 800; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.center { text-align: center; }

.card { background: rgba(255, 255, 255, .88); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; animation: slideUp .4s ease both; }
.card.tint { background: linear-gradient(135deg, #ecfcf4, #fff1e8); }
.note { font-size: .92rem; color: var(--mint-ink); background: var(--mint-soft); border-radius: 16px; padding: 10px 14px; }
.err { color: var(--warn); font-weight: 700; margin: 8px 0 0; }

/* buttons */
button { font: inherit; cursor: pointer; border: 0; }
.btn {
  font-weight: 800; border-radius: 20px; padding: 15px 26px; min-height: 52px; color: #07412d;
  background: linear-gradient(135deg, #9af0c4, #3fcf9b); box-shadow: 0 6px 0 #2aa77c, 0 10px 20px rgba(63, 207, 155, .35);
  transition: transform .12s, box-shadow .12s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #2aa77c; }
.btn.peach { color: #5a2410; background: linear-gradient(135deg, #ffd2b8, #ff9f7e); box-shadow: 0 6px 0 #e07e5c, 0 10px 20px rgba(255, 159, 126, .35); }
.btn.peach:active { box-shadow: 0 2px 0 #e07e5c; }
.btn.ghost { background: rgba(255, 255, 255, .85); color: var(--ink); box-shadow: 0 4px 0 #d8e6e0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.linkbtn { background: none; color: var(--muted); text-decoration: underline; padding: 10px; font-size: .95rem; }

/* mascot */
.mascot-wrap { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.mascot { width: 92px; height: 92px; flex: none; animation: floaty 3.2s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(63, 207, 155, .35)); }
.mascot.big { width: 150px; height: 150px; margin: 0 auto; display: block; }
.mascot .eye { transform-origin: center; transform-box: fill-box; animation: blink 4.5s infinite; }
.mascot .arm { transform-origin: 50% 10%; transform-box: fill-box; }
.mascot.cheer { animation: jump .6s ease; }
.mascot.cheer .arm.l { animation: wave .6s ease 2; }
.mascot.cheer .arm.r { animation: wave .6s ease 2 reverse; }
.bubble { position: relative; background: #fff; border-radius: 20px 20px 20px 6px; padding: 10px 14px; font-weight: 700; font-size: .98rem; box-shadow: 0 6px 16px rgba(255, 159, 126, .2); min-height: 44px; display: flex; align-items: center; animation: popIn .35s ease both; }

/* role cards */
.roles { display: grid; gap: 12px; margin: 16px 0; }
.role { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px 18px; border-radius: 24px; font-weight: 800; font-size: 1.1rem; color: var(--ink); background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); transition: transform .15s; }
.role:hover, .role:focus-visible { transform: translateY(-3px) rotate(-.6deg); }
.role .em { font-size: 2rem; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--mint-soft), var(--peach-soft)); }
.role small { display: block; font-weight: 600; color: var(--muted); font-size: .85rem; }

/* form */
label.field { display: block; font-weight: 800; margin: 14px 0 6px; }
input[type=text] { width: 100%; font: inherit; padding: 14px 16px; border: 3px solid var(--mint-soft); border-radius: 18px; background: #fff; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
input[type=text]:focus { border-color: var(--mint2); box-shadow: 0 0 0 5px rgba(123, 224, 176, .3); }
input.code { font-size: 1.5rem; letter-spacing: .15em; text-transform: uppercase; text-align: center; }
textarea { width: 100%; min-height: 130px; font: inherit; padding: 14px 16px; border: 3px solid var(--mint-soft); border-radius: 18px; resize: vertical; color: var(--ink); background: #fff; outline: none; }
textarea:focus { border-color: var(--mint2); box-shadow: 0 0 0 5px rgba(123, 224, 176, .3); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-width: 52px; padding: 11px 14px; border-radius: 16px; font-weight: 800; background: #fff; color: var(--ink); border: 3px solid var(--peach-soft); transition: transform .12s; }
.chip:active { transform: scale(.94); }
.chip[aria-pressed=true] { background: linear-gradient(135deg, #9af0c4, #3fcf9b); border-color: transparent; color: #07412d; animation: popIn .3s ease; }
label.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-top: 10px; background: #fff; border-radius: 18px; border: 3px solid var(--mint-soft); cursor: pointer; font-size: .95rem; }
label.check input { width: 26px; height: 26px; flex: none; accent-color: #2aa77c; margin: 1px 0 0; }

/* game */
.chips-top { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin: 4px 0 10px; font-size: .88rem; font-weight: 800; }
.pill { background: rgba(255, 255, 255, .9); border-radius: 99px; padding: 4px 12px; color: var(--mint-ink); }
.pill.peach { color: #8a3b1c; background: var(--peach-soft); }
.qcard { background: rgba(255, 255, 255, .92); border-radius: 30px; padding: 22px 20px; box-shadow: var(--shadow); animation: slideUp .35s ease both; }
.qtext { font-size: 1.28rem; font-weight: 800; line-height: 1.35; margin: 0 0 18px; }
.opts { display: grid; gap: 10px; }
.opt { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 13px 16px; border-radius: 22px; background: #fff; color: var(--ink); font-weight: 700; font-size: 1.02rem; border: 3px solid var(--peach-soft); box-shadow: 0 4px 0 var(--peach-soft); transition: transform .12s, background .2s, border-color .2s; animation: popIn .35s ease both; }
.opt:nth-child(2) { animation-delay: .04s; } .opt:nth-child(3) { animation-delay: .08s; } .opt:nth-child(4) { animation-delay: .12s; } .opt:nth-child(5) { animation-delay: .16s; }
.opt .em { font-size: 1.9rem; width: 44px; text-align: center; flex: none; transition: transform .2s; }
.opt .num { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 900; background: linear-gradient(135deg, var(--mint-soft), var(--peach-soft)); }
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--peach-soft); }
.opt[aria-pressed=true] { background: linear-gradient(135deg, #c9f7df, #8fe9bf); border-color: var(--mint2); box-shadow: 0 4px 0 #2aa77c; }
.opt[aria-pressed=true] .em { transform: scale(1.25) rotate(-8deg); }
.opt[aria-pressed=true]::after { content: "✓"; position: absolute; right: 16px; font-weight: 900; color: var(--mint-ink); font-size: 1.4rem; animation: popIn .3s ease; }
.opts.grid-num { grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); }
.opts.grid-num .opt { justify-content: center; padding: 14px 0; }
.opts.grid-num .opt::after { display: none; }
.opts.locked .opt { pointer-events: none; }
.scale-ends { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 8px; font-weight: 700; }

/* interstitial + finish */
.level-card { text-align: center; padding: 28px 20px; }
.level-card .big-n { font-size: 4.2rem; font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--mint2), var(--peach2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.badges { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.badge { background: linear-gradient(135deg, #fff1c9, #ffe0b5); padding: 8px 14px; border-radius: 99px; font-weight: 800; font-size: .92rem; animation: popIn .5s ease both; }
.lottie-box { margin: 0 auto; }
.lottie-fixed { position: fixed; z-index: 50; pointer-events: none; }
.float-xp { position: fixed; z-index: 60; pointer-events: none; font-weight: 900; font-size: 1.4rem; color: #c27a00; text-shadow: 0 2px 0 #fff, 0 0 8px #fff; animation: floatUp .95s ease forwards; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; background: #fff; border-radius: 22px; padding: 12px 20px; font-weight: 800; box-shadow: 0 12px 30px rgba(255, 159, 126, .4); animation: toast 2.6s ease both; max-width: 90vw; text-align: center; }

@keyframes slideUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.8); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes jump { 0% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(-22px) scale(.95, 1.08); } 60% { transform: translateY(0) scale(1.08, .92); } 100% { transform: translateY(0) scale(1); } }
@keyframes wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-35deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.3) rotate(-4deg); } 100% { transform: scale(1); } }
@keyframes floatUp { from { opacity: 1; transform: translateY(0) scale(.8); } to { opacity: 0; transform: translateY(-70px) scale(1.2); } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 30px); } 12%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
