/* Shared palette for the Makit interface and its standalone pages. */
:root {
  color-scheme: light;
  --bg: #fff;
  --card: #fff;
  --surface: #f6f6f8;
  --secondary: #e2e3e8;
  --ink: #202227;
  --muted: #565c68;
  --brand: #3458ef;
  --brand2: #18c5a8;
  --line: #d9dce2;
  --warn: #c28508;
  --bad: #b42336;
  --radius: 10px;
  --r-s: 9px;
  --r-m: 10px;
  --page-inset: clamp(16px, 2vw, 40px);
}
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
.top { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:10px 16px; max-width:1100px; margin:0 auto; }
.brand { display:flex; align-items:center; gap:10px; font-weight:800; font-size:22px; color:var(--ink); text-decoration:none; }
.logo { display:grid; place-items:center; width:36px; height:36px; border-radius:11px; background:linear-gradient(135deg,var(--brand),var(--brand2)); color:#fff; }
.badge { font-size:12px; padding:4px 10px; border-radius:99px; background:var(--card); border:1px solid var(--line); color:var(--muted); }
main { max-width:1100px; margin:0 auto; padding:12px 16px 48px; }
h1 { font-size:26px; margin:4px 0 12px; } h2 { font-size:20px; margin:0 0 8px; } h3 { font-size:16px; margin:0 0 6px; }
p { margin:6px 0; } .muted { color:var(--muted); } .small { font-size:14px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px; }
.grid { display:grid; gap:16px; } .g2 { grid-template-columns:1fr 1fr; } .g3 { grid-template-columns:repeat(auto-fill,minmax(260px,1fr)); }
@media (max-width:760px) { .g2 { grid-template-columns:1fr; } }
.row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
button, .btn { font:inherit; font-weight:700; cursor:pointer; border:0; border-radius:var(--r-s); padding:10px 16px; background:var(--brand); color:#fff; min-height:44px; }
button.sec { background:transparent; color:var(--ink); border:2px solid var(--line); }
button.good { background:var(--brand2); color:#06352c; } button.danger { background:var(--bad); }
button.icon { padding:0; width:44px; } button:disabled { opacity:.45; cursor:not-allowed; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline:3px solid var(--brand); outline-offset:2px; }
.chip { font-weight:600; background:var(--card); color:var(--ink); border:2px solid var(--line); border-radius:99px; padding:6px 12px; min-height:40px; }
.chip.on { border-color:var(--brand); background:color-mix(in srgb, var(--brand) 14%, var(--card)); }
input, textarea, select { font:inherit; width:100%; padding:10px 12px; border-radius:12px; border:2px solid var(--line); background:var(--card); color:var(--ink); }
label { font-weight:700; display:block; margin:12px 0 4px; }
.hero { padding:20px; border-radius:24px; background:linear-gradient(135deg,var(--brand),#a24cf1 55%,var(--brand2)); color:#fff; }
.hero p { opacity:.92; }
.big-emoji { font-size:56px; line-height:1; }
.err { background:color-mix(in srgb, var(--bad) 14%, var(--card)); border:1px solid var(--bad); border-radius:12px; padding:10px 12px; margin:10px 0; }
.note { background:color-mix(in srgb, var(--warn) 16%, var(--card)); border:1px solid var(--warn); border-radius:12px; padding:10px 12px; margin:10px 0; }
canvas { width:100%; height:auto; border-radius:var(--radius); background:#000; display:block; touch-action:none; }
.pad { display:flex; gap:8px; justify-content:center; margin-top:10px; }
.pad button { width:64px; height:56px; font-size:22px; }
.stage { display:flex; gap:12px; align-items:center; padding:12px; border:1px solid var(--line); border-radius:14px; background:var(--card); }
.stage .n { width:36px; height:36px; border-radius:50%; background:var(--brand); color:#fff; display:grid; place-items:center; font-weight:800; flex:none; }
.stage .grow { flex:1; min-width:0; }
.tag { font-size:12px; padding:2px 8px; border-radius:99px; background:var(--line); }
.tag.mine { background:var(--brand2); color:#06352c; }
.chat { max-height:min(62vh, 560px); overflow:auto; display:flex; flex-direction:column; gap:8px; margin-bottom:10px; }
.msg { padding:8px 12px; border-radius:14px; max-width:92%; } .msg.ai { background:var(--line); align-self:flex-start; } .msg.me { background:var(--brand); color:#fff; align-self:flex-end; }
.field { padding:10px 0; border-top:1px solid var(--line); } .field:first-of-type { border-top:0; }
.st { font-size:13px; font-weight:700; } .st.ok { color:var(--brand2); } .st.miss { color:var(--bad); } .st.def { color:var(--muted); }
.bar { height:10px; border-radius:99px; background:var(--line); overflow:hidden; } .bar > i { display:block; height:100%; background:linear-gradient(90deg,var(--brand),var(--brand2)); }
pre { background:#0e0b22; color:#d7d3ff; padding:12px; border-radius:12px; overflow:auto; font-size:13px; max-height:260px; }
.spin { display:inline-block; animation:sp 1s linear infinite; } @keyframes sp { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation:none; } }
.overlay { position:relative; } .overlay .gameframe { position:absolute; inset:0; width:100%; height:100%; border:0; border-radius:var(--radius); background:transparent; display:block; } .overlay .ov { position:absolute; inset:0; display:grid; place-items:center; background:rgba(10,8,30,.72); border-radius:var(--radius); color:#fff; text-align:center; padding:16px; }
.ov .box { max-width:420px; }
.bigcard { text-align:center; padding:24px; border-radius:24px; color:#fff; }

.hero { padding:24px 22px; } .hero h1 { font-size:32px; margin-top:0; } .hero p { margin:0; font-size:18px; }
.steps { list-style:none; display:grid; grid-template-columns:repeat(4,1fr); gap:10px; padding:0; margin:18px 0 0; }
.steps li { display:flex; align-items:center; gap:10px; background:rgba(255,255,255,.16); border-radius:14px; padding:10px 12px; font-weight:600; font-size:14px; }
.steps b { flex:none; width:28px; height:28px; border-radius:50%; background:#fff; color:#4b32c9; display:grid; place-items:center; }
@media (max-width:760px) { .steps { grid-template-columns:1fr 1fr; } .hero h1 { font-size:26px; } .hero p { font-size:16px; } }
.gamecard { display:flex; flex-direction:column; }
.thumb { height:112px; border-radius:12px; margin-bottom:12px; background:linear-gradient(180deg,var(--a),var(--b)); display:flex; align-items:flex-end; justify-content:space-around; padding:0 14px 12px; font-size:30px; }
.head { display:flex; gap:14px; align-items:center; flex-wrap:wrap; margin:6px 0 14px; } .head .grow { flex:1; min-width:200px; }
.avatar { width:56px; height:56px; border-radius:50%; display:grid; place-items:center; font-size:30px; flex:none; }
.stages { display:grid; gap:10px; }
.stage { border-left:6px solid var(--c, var(--brand)); background:linear-gradient(90deg, color-mix(in srgb, var(--a) 14%, var(--card)), var(--card) 40%); flex-wrap:wrap; }
.stage .n { background:linear-gradient(135deg,var(--a),var(--b)); color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.5); border:2px solid var(--c); }
.tag.d1 { background:#c8f5e6; color:#065f46; } .tag.d2 { background:#fff0c2; color:#7a4b00; } .tag.d3 { background:#ffd5d5; color:#8a1c1c; }
.tip { color:var(--warn); margin-top:2px; }
.stepper { list-style:none; display:flex; gap:8px; flex-wrap:wrap; padding:0; margin:0 0 14px; }
.stepper li { display:flex; align-items:center; gap:8px; padding:6px 12px; border-radius:99px; background:var(--card); border:1px solid var(--line); color:var(--muted); font-size:14px; font-weight:600; }
.stepper li b { width:22px; height:22px; border-radius:50%; background:var(--line); color:var(--ink); display:grid; place-items:center; font-size:12px; }
.stepper li.cur { color:var(--ink); border-color:var(--brand); } .stepper li.cur b { background:var(--brand); color:#fff; }
.stepper li.done b { background:var(--brand2); color:#06352c; }
.bars { display:grid; gap:6px; margin:6px 0; } .bars > div { display:grid; grid-template-columns:96px 1fr 44px; gap:8px; align-items:center; font-size:14px; } .bars b { text-align:right; }
.rl { margin:8px 0; }
.ov { z-index:2; }
button:hover:not(:disabled) { filter:brightness(1.08); } button:active:not(:disabled) { transform:translateY(1px); }
@media (prefers-reduced-motion: reduce) { * { transition:none !important; } button:active:not(:disabled) { transform:none; } }



.lvl { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:6px; }
.chip.sm { min-height:32px; padding:2px 12px; font-size:14px; }


.ico { display:inline-block; vertical-align:-0.3em; flex:none; }
.chip .ico { margin-right:2px; }


.params { margin-top:8px; padding:12px; border:1px dashed var(--line); border-radius:14px; background:color-mix(in srgb, var(--brand) 6%, var(--card)); }
.pgrid { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:12px; }
.pf { display:grid; gap:4px; margin:0; font-weight:400; }
.pin { display:flex; align-items:center; gap:8px; } .pin input { width:110px; }

.score { margin:6px auto; border-collapse:collapse; font-size:14px; min-width:260px; } .score td { padding:3px 10px; border-bottom:1px solid rgba(255,255,255,.12); text-align:left; } .score td:last-child { text-align:right; white-space:nowrap; }
.rules { margin:8px 0 0 18px; padding:0; font-size:14px; } .rules li { margin:3px 0; }

/* how to play (shown before every game): storybook scene built from the stage's own pictures */
.ov:has(.how) { background:#9fd8ff; padding:0; overflow:hidden; display:block; }
.ov:has(.how) .box { max-width:none; width:100%; height:100%; overflow:auto; padding:0; }
.how { display:flex; flex-direction:column; --ink:#3a2a74; --pink:#ff5a8a; position:relative; min-height:100%; overflow:hidden; color:var(--ink); background:var(--sky) center bottom/cover no-repeat, linear-gradient(#8fd3ff,#e9f7ff); text-align:left; }
.how-sun { position:absolute; right:5%; top:3%; width:120px; height:120px; background:var(--sun) center/contain no-repeat; opacity:.95; animation:how-spin 40s linear infinite; }
.how-cl { position:absolute; height:48px; background:var(--cloud) center/contain no-repeat; opacity:.85; animation:how-drift 22s ease-in-out infinite alternate; }
.how-cl1 { left:3%; top:5%; width:150px; } .how-cl2 { left:62%; top:14%; width:120px; animation-duration:30s; animation-direction:alternate-reverse; }
.how-hl { position:absolute; left:0; right:0; bottom:0; height:46%; background:var(--hills) left bottom/auto 100% repeat-x; opacity:.9; }
.how-hm { height:30%; background-image:var(--hmid); opacity:1; }
.how-in { flex:1; position:relative; z-index:1; display:flex; flex-direction:column; gap:10px; min-height:100%; padding:10px 18px 0; box-sizing:border-box; }
.how-head { text-align:center; display:flex; flex-direction:column; align-items:center; gap:2px; }
.how-by { font-size:12.5px; font-weight:700; background:rgba(255,255,255,.8); border-radius:99px; padding:2px 12px; color:var(--ink); }
.how-title { margin:0; font-size:38px; line-height:1.1; font-weight:900; letter-spacing:.5px; color:#fff; display:flex; align-items:center; gap:10px; text-shadow:0 3px 0 #ff5a8a, 0 6px 0 #c2305f, 0 9px 14px rgba(70,30,120,.45); -webkit-text-stroke:1px #c2305f; paint-order:stroke fill; }
.how-spk { width:26px; height:26px; animation:how-twinkle 1.6s ease-in-out infinite; } .how-spk:last-child { animation-delay:.8s; } .how-spk2 { width:24px; height:24px; }
.how-grid { flex:1; min-height:0; display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.how-card { background:rgba(255,255,255,.86); backdrop-filter:blur(6px); border:2px solid rgba(255,255,255,.95); border-radius:20px; box-shadow:0 8px 20px rgba(70,50,140,.22); padding:6px; display:flex; flex-direction:column; gap:6px; min-width:0; }
.how-pic { border-radius:15px; overflow:hidden; flex:1; min-height:140px; position:relative; }
.how-sc { position:absolute; inset:0; background:var(--sky) center/cover; overflow:hidden; }
.how-sc::before { content:''; position:absolute; left:0; right:0; bottom:0; height:62%; background:var(--hills) left bottom/auto 120% repeat-x; }
.how-rd { position:absolute; left:0; right:0; bottom:0; height:64%; overflow:hidden; clip-path:polygon(34% 0,66% 0,100% 100%,0 100%); }
.how-rimg { width:143%; height:auto; min-height:100%; filter:brightness(1.35) saturate(1.15); margin-left:-21.5%; display:block; }
.how-obj { position:absolute; left:var(--x,50%); top:var(--y); transform:translate(-50%,-100%); display:flex; flex-direction:column; align-items:center; }
.how-obj img.ico { width:62px; height:62px; filter:drop-shadow(0 3px 3px rgba(40,20,80,.35)); }
.how-obj img.how-pill { width:68px; height:auto; margin-bottom:-14px; position:relative; z-index:1; filter:drop-shadow(0 2px 4px rgba(200,40,70,.5)); }
.how-obj.how-hero img.ico { width:62px; height:62px; } .how-emo { font-size:54px; line-height:1; filter:drop-shadow(0 3px 3px rgba(40,20,80,.35)); }
.how-big { position:absolute; top:34%; font-size:34px; line-height:1; color:#ffc82e; text-shadow:0 2px 0 #c77a00, 0 4px 8px rgba(80,40,0,.4); animation:how-nudge 1s ease-in-out infinite; }
.how-big.l { left:7%; } .how-big.r { right:7%; animation-name:how-nudge-r; }
.how-blink { animation:how-pulse 1.1s ease-in-out infinite; }
.how-sway { animation:how-sway .7s ease-in-out infinite; }
.how-tx { min-height:58px; display:flex; flex-direction:column; gap:2px; padding:0 6px 4px; font-size:13px; line-height:1.3; }
.how-tx b { font-size:14.5px; color:#d62f5f; } .how-tx span { color:var(--ink); } .how-tx span b { font-size:inherit; color:var(--ink); background:#ffe27a; border-radius:5px; padding:0 4px; }
.how-dodge { animation:how-dodge 2.8s ease-in-out infinite; }
.how-jump { animation:how-jump 1.8s ease-in-out infinite; }
.how-slide { animation:how-slide 2.2s ease-in-out infinite; }
.how-duo { display:grid; grid-template-columns:1fr 1.25fr; gap:10px; }
.how-strip { display:flex; align-items:center; gap:10px; background:rgba(255,255,255,.88); border:2px solid #fff; border-radius:18px; box-shadow:0 6px 16px rgba(70,50,140,.2); padding:6px 12px; font-size:13.5px; line-height:1.3; color:var(--ink); }
.how-strip b { color:#d62f5f; } .how-ic { display:flex; align-items:center; gap:2px; flex:none; } .how-ic img.ico { filter:drop-shadow(0 2px 3px rgba(80,40,0,.3)); }
.how-ic img.ico:nth-child(1) { animation:how-bob 1.2s ease-in-out infinite; } .how-ic img.ico:nth-child(2) { animation:how-bob 1.2s ease-in-out .3s infinite; }
.how-start { position:sticky; bottom:0; margin:auto -18px 0; padding:8px 18px 12px; display:flex; align-items:center; justify-content:center; gap:16px; flex-wrap:wrap; background:linear-gradient(transparent, rgba(255,255,255,.55) 40%); }
.how-phone { font-size:13px; font-weight:700; background:rgba(255,255,255,.85); border-radius:99px; padding:6px 14px; color:var(--ink); }
.how-go { font-size:26px; font-weight:900; letter-spacing:.5px; color:#fff; min-width:230px; padding:12px 34px; border:3px solid #fff; border-radius:99px; cursor:pointer; background:linear-gradient(#ffb23c,#ff5a6e); text-shadow:0 2px 0 rgba(150,30,50,.55); box-shadow:0 6px 0 #c2305f, 0 10px 22px rgba(194,48,95,.5), inset 0 3px 0 rgba(255,255,255,.45); animation:how-breathe 1.8s ease-in-out infinite; }
.how-go:hover { filter:brightness(1.07); } .how-go:active { transform:translateY(4px); box-shadow:0 2px 0 #c2305f, 0 4px 10px rgba(194,48,95,.4); animation:none; }
.how-go:focus-visible { outline:4px solid #3a2a74; outline-offset:3px; }
@keyframes how-spin { to { transform:rotate(360deg); } }
@keyframes how-drift { to { transform:translateX(40px); } }
@keyframes how-twinkle { 0%,100% { transform:scale(.7) rotate(0); opacity:.6; } 50% { transform:scale(1.25) rotate(25deg); opacity:1; } }
@keyframes how-nudge { 0%,100% { transform:translateX(0); } 50% { transform:translateX(-7px); } }
@keyframes how-nudge-r { 0%,100% { transform:translateX(0); } 50% { transform:translateX(7px); } }
@keyframes how-pulse { 0%,100% { transform:translate(-50%,-100%) scale(1); } 50% { transform:translate(-50%,-100%) scale(1.07); } }
@keyframes how-sway { 0%,100% { transform:translate(-50%,-100%); } 50% { transform:translate(-50%,-112%); } }
@keyframes how-bob { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-4px); } }
@keyframes how-breathe { 0%,100% { transform:scale(1); } 50% { transform:scale(1.06); } }
@keyframes how-dodge { 0%,15% { left:50%; } 40%,70% { left:20%; } 95%,100% { left:50%; } }
@keyframes how-jump { 0%,30%,100% { transform:translate(-50%,-100%); } 50% { transform:translate(-50%,-190%); } 70% { transform:translate(-50%,-100%); } }
@keyframes how-slide { 0%,30%,100% { transform:translate(-50%,-100%) scaleY(1); } 45%,70% { transform:translate(-50%,-100%) scaleY(.55) scaleX(1.15); } }
.how-hero.how-dodge { --x:50%; }
@media (max-width:760px) { .how-grid { grid-template-columns:repeat(2,1fr); } .how-duo { grid-template-columns:1fr; } .how-title { font-size:32px; } .how-sun { width:80px; height:80px; } .overlay:has(.how) { min-height:clamp(460px,calc(100svh - 210px),640px); } .how-obj img.ico, .how-obj.how-hero img.ico { width:52px; height:52px; } .how-obj img.how-pill { width:58px; } .how-emo { font-size:46px; } .how-pic { min-height:150px; } }
@media (max-width:420px) { .how-in { padding:8px 10px 0; } .how-start { margin:auto -10px 0; padding:8px 10px 10px; } .how-go { min-width:0; width:100%; font-size:24px; } .how-tx { font-size:12.5px; } .how-card { padding:4px; } }
@media (prefers-reduced-motion: reduce) { .how *, .how-go { animation:none !important; } }

/* The opening screen previews the real three-stage 3D journey instead of the retired 2D obstacle cards. */
.how-tour .how-in { gap:8px; }
.how-sub { display:inline-flex; align-items:center; min-height:24px; padding:2px 12px; border-radius:99px; background:rgba(255,255,255,.84); color:#4b3d7d; font-size:13px; font-weight:800; box-shadow:0 3px 10px rgba(61,43,105,.14); }
.how-journey { flex:1; min-height:205px; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.how-stage { min-width:0; overflow:hidden; display:flex; flex-direction:column; border:2px solid rgba(255,255,255,.96); border-radius:20px; background:rgba(255,255,255,.9); box-shadow:0 8px 22px rgba(56,40,110,.24); }
.how-stage-pic { position:relative; flex:1; min-height:128px; background-image:var(--stage-preview),var(--stage-fallback); background-position:center; background-size:cover; background-repeat:no-repeat; border-bottom:2px solid rgba(255,255,255,.9); }
.how-stage-art { position:absolute; inset:26% 6% 5%; display:flex; align-items:flex-end; justify-content:space-around; gap:3px; }
.how-stage-art img { width:29%; height:72%; object-fit:contain; filter:drop-shadow(0 5px 5px rgba(34,24,74,.35)); }
.how-stage-no,.how-3d { position:absolute; top:9px; display:grid; place-items:center; min-width:30px; min-height:30px; padding:0 8px; border-radius:99px; color:#fff; font-size:13px; font-weight:900; box-shadow:0 3px 9px rgba(20,20,60,.28); }
.how-stage-no { left:9px; background:#6c4cf1; font-size:16px; }
.how-3d { right:9px; background:#0c9d87; letter-spacing:.6px; }
.how-stage-tx { display:flex; flex-direction:column; gap:1px; padding:7px 10px 9px; color:#3a2a74; line-height:1.22; }
.how-stage-tx b { color:#d62f5f; font-size:15px; }
.how-stage-tx span { font-size:12.5px; font-weight:800; }
.how-stage-tx small { font-size:11.5px; color:#615987; }
.how-actions { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.how-action { min-width:0; display:flex; align-items:center; gap:8px; padding:6px 9px; border:2px solid #fff; border-radius:15px; background:rgba(255,255,255,.9); color:#3a2a74; box-shadow:0 5px 14px rgba(56,40,110,.17); }
.how-action>div { min-width:0; display:flex; flex-direction:column; line-height:1.15; }
.how-action b { font-size:13px; color:#d62f5f; }
.how-action small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; color:#615987; }
.how-key { flex:none; min-width:50px; padding:5px 6px; border-radius:9px; background:#ffe27a; color:#3a2a74; font-size:12px; font-weight:900; text-align:center; box-shadow:inset 0 -2px 0 rgba(176,123,0,.22); }
.how-duo-mini .how-strip { padding:4px 10px; font-size:12px; }
.how-tour .how-start { padding-top:5px; padding-bottom:9px; }
.how-tour .how-go { min-width:245px; padding:9px 28px; font-size:22px; }
@media (max-width:760px) {
  .how-journey { grid-template-columns:none; grid-auto-flow:column; grid-auto-columns:82%; min-height:245px; overflow-x:auto; scroll-snap-type:x mandatory; padding:0 3px 5px; }
  .how-stage { scroll-snap-align:center; }
  .how-actions { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .how-stage-pic { min-height:150px; }
}
@media (max-width:420px) {
  .how-title { font-size:28px; }
  .how-sub { font-size:11.5px; }
  .how-journey { grid-auto-columns:88%; }
  .how-action { padding:5px 7px; }
  .how-key { min-width:44px; font-size:11px; }
}

/* result screens (stage won / game over / game summary): reuse the how-to-play backdrop and title */
@property --n { syntax:'<integer>'; inherits:false; initial-value:0; }
.res-in { align-items:center; justify-content:center; gap:8px; padding:10px 18px 0; }
.res-main { width:100%; max-width:820px; display:grid; grid-template-columns:minmax(230px,1fr) 1.25fr; gap:12px; align-items:center; }
.res-main.res-one { grid-template-columns:1fr; max-width:460px; justify-items:center; }
.res-hero, .res-side { background:rgba(255,255,255,.88); backdrop-filter:blur(6px); border:2px solid #fff; border-radius:22px; box-shadow:0 8px 20px rgba(70,50,140,.22); padding:10px 14px; display:flex; flex-direction:column; align-items:center; gap:6px; min-width:0; }
.res-one .res-hero { width:100%; }
.res-big { display:flex; align-items:center; gap:10px; } .res-big > div { display:flex; flex-direction:column; align-items:flex-start; line-height:1; }
.res-star { width:64px; height:64px; filter:drop-shadow(0 3px 5px rgba(200,120,0,.5)); animation:res-pop 1.6s ease-in-out infinite; }
.res-lb { font-size:13px; font-weight:800; color:#d62f5f; }
.res-num { font-size:56px; font-weight:900; line-height:1.05; color:var(--ink); counter-reset:c var(--n); animation:res-count 1.1s ease-out both, res-bump .6s ease-out 1.05s; }
.res-num span { font-size:0; } .res-num::after { content:counter(c); }
.res-total .res-num, .res-total { font-size:19px; } .res-total .res-num { font-size:30px; vertical-align:-3px; }
.res-total { font-weight:900; color:var(--ink); text-align:center; display:flex; align-items:center; justify-content:center; gap:6px; }
.res-lives { display:flex; flex-direction:column; align-items:center; gap:2px; }
.res-hearts { display:flex; align-items:center; gap:4px; } .res-x { font-size:24px; color:var(--ink); }
.res-h { filter:drop-shadow(0 2px 3px rgba(200,30,70,.45)); animation:how-bob 1.2s ease-in-out calc(var(--i) * .2s) infinite; }
.res-h.off { filter:grayscale(1) opacity(.35); animation:none; }
.res-by { font-size:13px; font-weight:700; color:var(--ink); text-align:center; }
.res-flag { font-size:52px; line-height:1; } .res-hero-ic img.ico { width:64px; height:64px; filter:drop-shadow(0 3px 3px rgba(40,20,80,.35)); }
.res-side { align-items:stretch; padding:8px 10px; }
.res-rows { display:flex; flex-direction:column; gap:5px; max-height:176px; overflow:auto; }
.res-row { display:flex; align-items:center; gap:8px; background:#fff; border:2px solid #efe8ff; border-radius:14px; padding:4px 10px; font-size:14px; color:var(--ink); }
.res-row.cur { background:linear-gradient(#fff6cf,#ffe27a); border-color:#ffb23c; box-shadow:0 0 0 3px rgba(255,178,60,.35); font-weight:800; }
.res-no { flex:none; width:24px; height:24px; border-radius:50%; background:#d62f5f; color:#fff; font-weight:900; font-size:13px; display:grid; place-items:center; }
.res-nm { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.res-sc { flex:none; display:flex; align-items:center; gap:3px; color:var(--muted); } .res-sc b { color:var(--ink); font-size:16px; }
.res-next { width:100%; max-width:560px; display:flex; flex-wrap:wrap; justify-content:center; gap:2px 14px; background:rgba(255,255,255,.88); border:2px solid #fff; border-radius:18px; padding:6px 14px 10px; position:relative; font-size:14px; color:var(--ink); box-shadow:0 6px 16px rgba(70,50,140,.2); }
.res-next b { color:#d62f5f; } .res-cd { color:var(--muted); font-size:13px; }
.res-bar { flex:0 0 100%; height:8px; border-radius:99px; background:#eadfff; overflow:hidden; margin-top:4px; } .res-bar i { display:block; height:100%; width:100%; border-radius:99px; background:linear-gradient(90deg,#18c5a8,#ffc82e,#ff5a8a); transform-origin:left; animation:res-bar 6s linear forwards; }
.res-cheer { margin:0; font-size:15px; font-weight:800; color:var(--ink); background:rgba(255,255,255,.88); border:2px solid #fff; border-radius:18px; padding:8px 16px; text-align:center; box-shadow:0 6px 16px rgba(70,50,140,.2); }
.res-lose .how-title { font-size:32px; }
.res-btns { background:none; width:100%; margin:0 -18px 0; position:sticky; bottom:0; padding:6px 18px 12px; }
.res-sec { font-size:20px; font-weight:900; color:#d62f5f; padding:9px 24px; border:3px solid #fff; border-radius:99px; cursor:pointer; background:rgba(255,255,255,.92); box-shadow:0 5px 0 #d9c8f5, 0 8px 16px rgba(70,50,140,.25); }
.res-sec:hover { filter:brightness(1.04); } .res-sec:active { transform:translateY(4px); box-shadow:0 1px 0 #d9c8f5; } .res-sec:focus-visible { outline:4px solid #3a2a74; outline-offset:3px; }
.res-btns .how-go { font-size:24px; min-width:0; padding:10px 30px; }
.res-conf { position:absolute; inset:0; overflow:hidden; pointer-events:none; z-index:0; }
.res-conf i { position:absolute; left:var(--x); top:-14px; width:9px; height:14px; background:var(--c); border-radius:2px; transform:rotate(var(--r)); animation:res-fall var(--t) linear var(--d) infinite; }
.res-conf i:nth-child(3n) { width:12px; height:8px; border-radius:50%; }
@keyframes res-fall { 0% { transform:translateY(0) rotate(var(--r)); opacity:1; } 100% { transform:translateY(560px) rotate(calc(var(--r) + 540deg)); opacity:.9; } }
@keyframes res-count { from { --n:0; } to { --n:var(--v); } }
@keyframes res-bump { 0%,100% { transform:scale(1); } 50% { transform:scale(1.18); } }
@keyframes res-pop { 0%,100% { transform:scale(1) rotate(-6deg); } 50% { transform:scale(1.14) rotate(6deg); } }
@keyframes res-bar { to { transform:scaleX(0); } }
@media (max-width:760px) { .res-main { grid-template-columns:1fr; } .res-num { font-size:46px; } .res-in { justify-content:flex-start; } .res-rows { max-height:none; } }
@media (max-width:760px) { .res-btns { background:linear-gradient(transparent,rgba(255,255,255,.7) 45%); } }
@media (max-width:420px) { .res-in { padding:8px 10px 0; } .res-btns { margin:0 -10px; padding:6px 10px 10px; } .res-btns .how-go, .res-sec { width:100%; } .res-sec { font-size:18px; } }
@media (prefers-reduced-motion: reduce) { .res *, .res-btns * { animation:none !important; } .res-conf { display:none; } .res-num { --n:var(--v); } }

/* tạo chặng: tiến trình thật */
.pg { list-style:none; margin:8px 0; padding:0; display:grid; gap:6px; }
.pg > li { display:flex; flex-wrap:wrap; gap:8px; align-items:baseline; padding:6px 10px; border-radius:10px; background:rgba(255,255,255,.05); }
.pg > li ul { flex-basis:100%; margin:2px 0 0 26px; padding-left:16px; }
.pg-ok, .pg-bad, .pg-wait { display:inline-block; width:1.4em; text-align:center; font-weight:700; }
.pg-ok { color:#4ade80; } .pg-bad { color:#f87171; } .pg-wait { opacity:.5; }
.pg > li.pgs-run { background:rgba(124,92,255,.22); outline:1px solid rgba(124,92,255,.5); } .pg > li.pgs-wait { opacity:.6; }

/* Gợi ý sáng tạo */
.ideas { margin-top:10px; }
.idea-card { margin-top:8px; border-left:4px solid #ffd166; }
.idea-card h3 { margin:0 0 9px; font-size:21px; }
.idea-specs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; margin:8px 0; }
.idea-specs>div { display:flex; flex-direction:column; gap:2px; min-width:0; padding:8px 10px; border:1px solid color-mix(in srgb,var(--brand) 28%,var(--line)); border-radius:11px; background:color-mix(in srgb,var(--brand) 6%,var(--card)); }
.idea-specs span { color:var(--muted); font-size:12px; font-weight:700; }
.idea-specs b { overflow-wrap:anywhere; font-size:14px; }
.idea-tip { margin:8px 0 4px; font-weight:700; }
.idea-token { margin:9px 0; padding:7px 9px; border-radius:10px; background:color-mix(in srgb,#ffd166 20%,var(--card)); font-size:13px; }
.audit-card { margin:10px 0; border-left:4px solid #18c5a8; }
.audit-card .tl { margin-bottom:4px; }
@media (max-width:520px) { .idea-specs { grid-template-columns:1fr; } }
.engine-card { margin-top:8px; border-left:4px solid #a56bff; }
/* the student's own project (level 2): label, AI change progress, versions */
.tag.l2 { background:#e9ddff; color:#3b1d80; font-weight:600; }
.eng-pg > li ul li { overflow-wrap:anywhere; }
.vers { margin-top:14px; } .verl { list-style:none; margin:8px 0 0; padding:0; display:grid; gap:6px; }
.verl > li { display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:6px 10px; border-radius:10px; background:rgba(255,255,255,.05); }
.verl > li button { min-height:34px; padding:0 12px; }

/* round of 29/10: one main action row (3 buttons) + a "more" row, bigger touch targets, sticky continue button, folded options */
.g1 { grid-template-columns:1fr; }
.more-btn { width:100%; margin:6px 0 10px; justify-content:flex-start; text-align:left; }
.more[hidden] { display:none; }
@media (max-width:760px) {
  button, .chip { min-height:44px; }
  .chip.sm { min-height:44px; font-size:14px; }
  .tag { font-size:13px; }
  .stage .lvl .chip { min-height:44px; }
}
@keyframes flashrow { 0%,60% { box-shadow:0 0 0 4px var(--brand2); background-color:color-mix(in srgb, var(--brand2) 22%, var(--card)); } 100% { box-shadow:0 0 0 0 transparent; } }
.stage.flash { animation:flashrow 3.5s ease-out 1; }
@media (prefers-reduced-motion: reduce) { .stage.flash { animation:none; outline:3px solid var(--brand2); } }
/* text under the game while a stage is loading (the game picture covers it as soon as it paints) */
.overlay::after { content:"⏳ Đang nạp chặng…"; position:absolute; inset:0; display:grid; place-items:center; color:#fff; font-weight:800; font-size:20px; text-shadow:0 2px 6px rgba(0,0,0,.5); z-index:0; pointer-events:none; }
.overlay canvas, .overlay .gameframe { position:relative; z-index:1; } .overlay .gameframe { position:absolute; } .overlay .ov { z-index:2; }
/* phone: the "Cách chơi" screen is never taller than the window; the Start button stays at the bottom of it while the cards scroll */
.how { overflow:clip; }
@media (max-width:760px) { .overlay:has(.how) { height:clamp(460px,calc(100svh - 200px),640px); overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; } }   /* scrolls inside, so nothing is cut on a small phone; the Start / result buttons stay at the bottom (sticky) */

/* runner seen from behind: four pictures shown in turn = the running animation (also used in "Cách chơi") */
.how-run { display:inline-block; position:relative; width:var(--s); height:var(--s); }
.how-run .how-fr { position:absolute; inset:0; opacity:0; animation:how-fr .48s steps(1) infinite; animation-delay:calc(var(--k) * -.12s); }
@keyframes how-fr { 0% { opacity:1; } 25%,100% { opacity:0; } }
/* last screen: warm congratulations */
.res-stars { display:flex; justify-content:center; align-items:flex-end; gap:6px; margin-top:6px; }
.res-fs { animation:res-pop 1.4s ease-in-out infinite; animation-delay:calc(var(--k) * .18s); filter:drop-shadow(0 2px 3px rgba(60,30,100,.35)); }
.res-praise { margin:2px auto 8px; max-width:640px; padding:10px 18px; border-radius:18px; background:rgba(255,255,255,.88); color:#3a2a74; font-weight:800; font-size:20px; line-height:1.35; text-align:center; box-shadow:0 4px 14px rgba(60,30,100,.25); }
.res-cheer-hero { animation:res-hop 1s ease-in-out infinite; } @keyframes res-hop { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-12px); } }
.res-end .res-title, .res-end .how-title { font-size:clamp(34px,7vw,56px); }
@media (max-width:420px) { .res-praise { font-size:16px; padding:8px 12px; } }
@media (prefers-reduced-motion: reduce) { .how-run .how-fr { animation:none; } .how-run .how-fr:first-child { opacity:1; } .res-fs, .res-cheer-hero { animation:none; } }
.res-cheer-hero img.ico { width:120px !important; height:120px !important; }
.res-stars { margin-bottom:12px; }
/* between stages the game goes straight on; this small pop says what the stage just finished gave */
.stage-pop { position:absolute; left:50%; bottom:74px; transform:translateX(-50%); z-index:3; pointer-events:none; display:flex; align-items:center; gap:8px; padding:8px 18px; border-radius:99px; background:rgba(255,255,255,.94); color:#3a2a74; font-weight:900; font-size:20px; box-shadow:0 6px 18px rgba(40,20,90,.35); animation:pop-in 3.2s ease-out 1 both; white-space:nowrap; }
@keyframes pop-in { 0% { opacity:0; transform:translate(-50%,-14px) scale(.8); } 10%,75% { opacity:1; transform:translate(-50%,0) scale(1); } 100% { opacity:0; transform:translate(-50%,-6px) scale(1); } }
@media (max-width:420px) { .stage-pop { font-size:15px; bottom:40px; padding:6px 12px; } }
@media (prefers-reduced-motion: reduce) { .stage-pop { animation:none; } }
.res-hl { color:#d62f5f; font-size:1.12em; }

/* the runner in the child's colour (see runnerHtml in app.js) */
.rn { position:relative; display:inline-block; width:var(--s); height:var(--s); isolation:isolate; }
.rn > * { position:absolute; left:0; top:0; width:100%; height:100%; }
.rn .rn-c { background:var(--c); -webkit-mask:var(--m) center/contain no-repeat; mask:var(--m) center/contain no-repeat; }
.rn .rn-s { mix-blend-mode:multiply; }
.how-run .rn { --s:100%; }

/* "Bộ hình" setting */
.packs { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:14px; margin-top:12px; }
.packcard { display:flex; flex-direction:column; gap:6px; align-items:flex-start; text-align:left; height:auto; padding:10px; border-radius:16px; border:2px solid var(--line); background:var(--card); color:var(--ink); font-weight:600; cursor:pointer; }
.packcard.on { border-color:var(--brand2); box-shadow:0 0 0 3px color-mix(in srgb, var(--brand2) 30%, transparent); }
.packcard b { font-size:18px; }
.packrows { display:flex; flex-direction:column; gap:8px; margin-top:12px; }
.packrow { display:flex; flex-wrap:wrap; gap:4px 8px; align-items:center; text-align:left; justify-content:flex-start; height:auto; padding:10px 14px; border-radius:14px; border:2px solid var(--line); background:var(--card); color:var(--ink); font-weight:500; cursor:pointer; }
.packrow.on { border-color:var(--brand2); box-shadow:0 0 0 3px color-mix(in srgb, var(--brand2) 30%, transparent); }
.packrow .packlost { flex-basis:100%; color:var(--bad, #b42318); }
.pack-pic { display:flex; align-items:flex-end; justify-content:space-around; gap:2px; width:100%; height:96px; border-radius:12px; background:#9fd8ff center/cover no-repeat; padding:6px 4px; overflow:hidden; }
.pack-pic img { height:60px; width:auto; max-width:19%; object-fit:contain; }
.pack-stage-preview { position:relative; height:164px; padding:0; background-position:center; background-size:cover; border:1px solid color-mix(in srgb,var(--line) 72%,transparent); }
.pack-stage-preview>span { position:absolute; left:9px; bottom:9px; padding:4px 10px; border-radius:99px; background:rgba(21,18,52,.82); color:#fff; font-size:12px; font-weight:900; box-shadow:0 3px 9px rgba(0,0,0,.24); }

.toast.ok { background:var(--brand2); color:#06352c; }

/* ---- round of 30/10: one-row top bar, ways back, icons, calmer rhythm ---- */
.i { flex:none; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; vertical-align:-4px; }
button .i { vertical-align:-4px; }
.top { flex-wrap:nowrap; } .brand { flex:none; }
#nav { display:flex; gap:6px; align-items:center; margin-left:auto; min-width:0; }
.navb { min-height:40px; min-width:40px; padding:4px 10px; font-size:14px; display:inline-flex; align-items:center; justify-content:center; gap:6px; }
.navb[aria-current=page] { border-color:var(--brand); background:color-mix(in srgb, var(--brand) 14%, var(--card)); }
.badge { position:fixed; right:8px; bottom:8px; z-index:11; opacity:.85; white-space:nowrap; }
@media (max-width:520px) {
  .top { padding:8px 12px; } main { padding-left:12px; padding-right:12px; }
  .brand { font-size:20px; gap:8px; }
  .navb { min-height:44px; min-width:44px; padding:4px 8px; } .navb .nl { display:none; }
  h1 { font-size:22px; }
}
.toast { position:fixed; left:50%; top:64px; bottom:auto; transform:translateX(-50%); max-width:min(560px,92vw); background:var(--bad); color:#fff; padding:10px 16px; border-radius:var(--r-s); font-weight:600; z-index:20; box-shadow:0 6px 24px rgba(0,0,0,.4); animation:toast-in .2s ease-out; }
@keyframes toast-in { from { opacity:0; transform:translate(-50%,-8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation:none; } }
.crumb { margin:0 0 6px; }
button.sm { min-height:40px; padding:2px 12px; font-size:14px; display:inline-flex; align-items:center; gap:4px; }
.pagehead { gap:12px; margin-bottom:4px; } .pagehead h1 { margin:0; }
.sect { margin:22px 0 8px; }
.top-start { align-items:start; }
.chip.ibtn { display:inline-flex; align-items:center; justify-content:center; min-width:44px; padding:2px 8px; margin-left:6px; vertical-align:middle; }
button:not(.chip):not(.act):not(.how-go):not(.res-sec) .i, .chip .i { margin-right:2px; }
.chip.ibtn .i { margin:0; }
button.icon .i { margin:0; }
.playbar { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
.playbar h2 { flex:1; min-width:0; margin:0; font-size:18px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
button.icon { display:inline-grid; place-items:center; flex:none; }
/* stage cards */
.acts { display:grid; grid-template-columns:repeat(3,84px); gap:6px; align-items:center; margin-left:auto; }
.acts.acts2 { grid-template-columns:repeat(5,84px); flex-basis:100%; width:100%; margin-left:0; justify-content:flex-start; padding-top:6px; border-top:1px dashed var(--line); }
.acts .act { width:100%; min-height:60px; padding:4px 2px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; border-radius:var(--r-s); }
.act .ai { display:grid; line-height:1; } .act .al { font-size:13px; font-weight:700; line-height:1.1; text-align:center; }
.act .i { margin:0; }
.stage .lvl { margin-top:4px; }
.tip .i { vertical-align:-3px; }
@media (max-width:760px) { .acts, .acts.acts2 { grid-template-columns:repeat(3,1fr); } .acts { margin-left:0; width:100%; } .pgrid { grid-template-columns:1fr 1fr; } }
/* buttons at the end of the stage list: one main action */
.actions-end { gap:8px; }
.actions-end .primary { order:5; margin-left:auto; box-shadow:0 3px 0 color-mix(in srgb, var(--brand) 60%, #000); }
@media (max-width:520px) { .actions-end .primary { order:-1; flex:1 1 100%; margin-left:0; } .actions-end > button { flex:1 1 auto; } }
/* stage creation */
.stepper li { padding:4px 10px; font-size:13px; }
@media (max-width:520px) { .stepper { flex-wrap:nowrap; overflow-x:auto; gap:6px; } .stepper li { flex:none; } .stepper li:not(.cur) span { display:none; } }
.mob-only { display:none; }
@media (max-width:760px) { .mob-only { display:inline-block; } .desk-only { display:none; } }
.more-btn .small { font-weight:400; }

/* phone: the result buttons are a 2-column group in the flow (not four tall buttons covering the score and the rows); toast clear of the back button; no empty sticky bar */
@media (max-width:520px) {
  .res-btns { position:sticky; bottom:0; display:grid; grid-template-columns:repeat(auto-fit,minmax(88px,1fr)); gap:8px; margin:0; padding:8px 10px 12px; background:linear-gradient(transparent,rgba(255,255,255,.75) 35%); }
  .res-btns .how-go { grid-column:1 / -1; font-size:20px; padding:8px 16px; }
  .res-btns .res-sec { width:auto; font-size:14px; padding:8px 6px; box-shadow:0 3px 0 #d9c8f5; }
  .toast { top:auto; bottom:84px; }
}

.navb { position:relative; } .navdot { position:absolute; top:4px; right:4px; width:11px; height:11px; border-radius:50%; background:var(--bad); border:2px solid var(--bg); }

/* the bell */
.notewrap { position:relative; display:inline-flex; }
.notes { position:absolute; right:0; top:calc(100% + 8px); z-index:30; width:min(340px,calc(100vw - 24px)); max-height:min(420px,70vh); overflow:auto; background:var(--card); border:1px solid var(--line); border-radius:var(--r-m,14px); box-shadow:0 12px 32px rgba(0,0,0,.35); padding:10px; text-align:left; }
.notes-h { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:2px 4px 8px; }
.notes ul { list-style:none; margin:0; padding:0; display:grid; gap:6px; }
.notes li { display:flex; gap:8px; align-items:flex-start; justify-content:space-between; padding:8px; border-radius:10px; background:color-mix(in srgb, var(--card) 85%, var(--ink) 6%); }
.notes li.new { box-shadow:inset 3px 0 0 var(--bad); }
.notes .nt { font-size:14px; line-height:1.35; } .notes .ago { display:block; font-size:12px; color:var(--muted); margin-top:2px; }
.notes .na { display:flex; gap:4px; flex-shrink:0; }
.notes .sm { min-height:32px; padding:2px 10px; font-size:13px; }

.tag.cloud { font-size:12px; } .tag.cloud.ok { color:var(--brand2); } .tag.cloud.error { color:var(--bad); border-color:var(--bad); }

.tl { list-style:none; margin:4px 0 8px; padding:0; } .tl li { padding:1px 0; } .tl li.ok { color:var(--brand2); } .tl li.bad { color:var(--bad); font-weight:700; }

/* built stage: one row of round icon buttons under the preview; words show only on hover / focus (data-tip) */
.tbar { display:flex; justify-content:center; flex-wrap:wrap; gap:10px; margin:12px 0 8px; }
button.tb { position:relative; width:48px; min-height:48px; height:48px; padding:0; border-radius:50%; }
button.tb .i { margin:0; }
button.tb[data-tip]::after { content:attr(data-tip); position:absolute; left:50%; bottom:calc(100% + 6px); transform:translateX(-50%); padding:3px 9px; border-radius:8px; background:var(--ink); color:var(--bg); font-size:13px; font-weight:700; line-height:1.3; white-space:nowrap; pointer-events:none; opacity:0; transition:opacity .12s; z-index:20; }
button.tb[data-tip]:hover::after, button.tb[data-tip]:focus-visible::after { opacity:1; }
@media (prefers-reduced-motion: reduce) { button.tb[data-tip]::after { transition:none; } }
.card > .lvl[aria-label="Độ khó khi chơi"] { margin:6px 0 12px; }
@media (max-width:520px) { .tbar { gap:8px; } .card > .lvl[aria-label="Độ khó khi chơi"] .chip { min-height:44px; } }
@media (min-width:521px) { .card > .lvl[aria-label="Độ khó khi chơi"] .chip { min-height:40px; } }

/* "Thẻ chặng" (right column): compact header, thin progress bar, sub-cards, equal small chips in a grid, icon tools, one clear main button */
.bar.thin { height:5px; margin-bottom:10px; }
.grid > .card:last-child .field { border:1px solid var(--line); border-radius:var(--r-m); padding:10px 12px; margin:0 0 10px; background:color-mix(in srgb, var(--card) 92%, var(--ink) 3%); }
.grid > .card:last-child .field > b { font-size:15px; }
.grid > .card:last-child .st { font-size:12px; margin-left:4px; }
.row.cg { display:grid; grid-template-columns:repeat(auto-fill,minmax(122px,1fr)); gap:6px; }
.row.cg .chip { min-height:38px; padding:2px 8px; font-size:14px; border-radius:12px; display:flex; align-items:center; justify-content:flex-start; gap:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.row.cg .chip.on { border-color:var(--brand); background:color-mix(in srgb, var(--brand) 22%, var(--card)); box-shadow:0 0 0 1px var(--brand); }
button.tb.tb-sq { border-radius:12px; }
@media (max-width:520px) { .row.cg { grid-template-columns:1fr 1fr; } .row.cg .chip { min-height:44px; } }

/* contrast: green TEXT is darker on light backgrounds (the bright green stays for dark mode and for buttons) */
:root { --okc:#0a6e5a; --badc:#b3262b; }
.tag.cloud.ok, .tl li.ok, .st.ok { color:var(--okc); } .tl li.bad, .st.miss, .tag.cloud.error { color:var(--badc); }
.tag.cloud.error { border-color:var(--badc); }
/* touch targets on phones */
@media (max-width:760px) {
  .notes .sm, .chip.sm, button.sm { min-height:44px; min-width:44px; }
  .notes .na { gap:6px; }
}
/* the hint above the sticky bar is never hidden by it */

/* desktop review: long unbroken text must wrap inside the chat and card; the sticky bar keeps room under the last line; the toast sits below the top bar */
.chat, .chat > *, .note, .card, .bubble { min-width:0; overflow-wrap:anywhere; }
main { min-width:0; }
/* wide screens: the page grows a little so the sides are not empty (still a readable line length) */
@media (min-width:1700px) { .top, main { max-width:1320px; } }

/* desktop review 2: the Send button stays on screen at 768px high; result title readable in dark mode */
@media (max-height:800px) and (min-width:900px) { #msg { height:84px; min-height:0; } }
.how-head .how-title { color:#2b2a5a; text-shadow:none; }

/* mobile review: landscape play keeps the controls on screen; the pad stays under the thumb; bigger small text and touch targets; results bar smaller on tiny screens */
@media (orientation:landscape) and (max-height:520px) {
  .overlay { width:min(100%, calc((100vh - 118px) * 16 / 9)); margin-left:auto; margin-right:auto; }
  .pad { margin-top:6px; } .pad button { height:48px; }
}
@media (pointer:coarse) {
  .pad { position:sticky; bottom:0; z-index:6; padding:8px 0 calc(8px + env(safe-area-inset-bottom)); background:linear-gradient(transparent, var(--bg) 35%); }
  .logo { width:44px; height:44px; }
}
@media (max-width:760px) {
  .small, .note .small, .tag, label, .more-btn .small { font-size:14px; }
  button.sm, .chip.sm, .sm { min-height:44px; min-width:44px; }
}
@media (max-width:380px) {
  .res-btns { padding:4px 12px 8px; margin:0 -12px 0; } .res-btns .how-go { font-size:19px; padding:8px 18px; }
  .res-rows { max-height:96px; overflow:auto; }
  .toast { max-width:92vw; bottom:12px; top:auto; }
}
@media (pointer:coarse) { button, .chip, .chip.sm { min-height:44px; } .pad button { min-height:48px; } }

/* the "Chỉnh" box: the send icon sits to the right of the text box, level with its bottom edge */
.tweak-row { display:flex; gap:10px; align-items:flex-end; }
.tweak-row textarea { flex:1; min-width:0; }
.icon-send { flex:none; width:52px; min-height:52px; padding:0; display:inline-flex; align-items:center; justify-content:center; }
.vh { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
/* the project line ("Game mẫu của Makit", "Đã lưu trên máy chủ") is not shown; it stays readable for screen readers. A warning (not saved, saved in another window) is still shown. */
.tag.projtag, .tag.cloud.ok, .tag.cloud.saving { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; padding:0; border:0; margin:-1px; }
/* "Tạo game": the three steps */
.wiz { list-style:none; display:flex; gap:8px; flex-wrap:wrap; padding:0; margin:6px 0 12px; }
.wiz li { display:flex; align-items:center; gap:8px; padding:6px 12px; border-radius:99px; background:var(--card); border:1px solid var(--line); font-weight:700; font-size:14px; }
.wiz li.off { color:var(--muted); font-weight:500; }
.wiz b { width:24px; height:24px; border-radius:50%; background:var(--brand); color:#fff; display:grid; place-items:center; font-size:13px; }
.wiz li.off b { background:var(--line); color:var(--muted); }
.gcard { display:flex; flex-direction:column; align-items:flex-start; }
.gcard-actions { margin-top:auto; }
.gdelete { color:var(--bad) !important; border-color:color-mix(in srgb, var(--bad) 55%, var(--line)) !important; }
.gdelete-box { width:100%; margin-top:auto; padding:10px 12px; border:1px solid var(--bad); border-radius:var(--r-s); background:color-mix(in srgb, var(--bad) 10%, var(--card)); }
.gdelete-box p { margin:4px 0 8px; }

/* E10: the review of the pictures (one card per obstacle / collectible) */
.rv-grid { display:flex; flex-wrap:wrap; gap:10px; }
.rv-card { margin:0; width:148px; box-sizing:border-box; padding:8px; border:1px solid var(--line, #3b3566); border-radius:12px; background:rgba(255,255,255,.05); display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; }
.rv-card img, .rv-card .rv-emoji, .rv-card .rv-new { width:84px; height:84px; display:flex; align-items:center; justify-content:center; font-size:46px; object-fit:contain; background:rgba(255,255,255,.08); border-radius:10px; }
.rv-card .rv-new { border:2px dashed #f59e0b; }
.rv-card figcaption { display:flex; flex-direction:column; gap:3px; align-items:center; }
.rv-tag { font-size:12px; line-height:1.25; padding:2px 6px; border-radius:8px; background:rgba(255,255,255,.1); }
.rv-new .rv-tag { background:rgba(245,158,11,.25); }
@media (max-width: 480px) { .rv-card { width: calc(50% - 5px); } }

/* many pictures: the grid of the review scrolls inside its box (the Duyệt button stays below it) */
.rv-grid.rv-many { max-height: min(62vh, 560px); overflow-y: auto; padding-right: 4px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }


.kit-picker,.stage-fields { margin-block: 12px; }
.kit-picker summary,.stage-fields summary { cursor:pointer; font-weight:600; }
.kit-picker label,.stage-fields label { display:block; margin-top:8px; }
.kit-picker select,.stage-fields input,.stage-fields select { max-width:100%; margin-left:4px; }
.stage-fields button { margin-top:8px; }

/* Product UI: clear hierarchy and calm controls, scoped away from account pages. */

#app h1, #app h2, #app h3 { line-height:1.3; letter-spacing:-.025em; font-weight:750; overflow-wrap:break-word; }
#app h1 { font-size:clamp(25px,3vw,32px); margin-bottom:12px; }
#app h2 { font-size:21px; }
#app h3 { font-size:17px; }
#app p { line-height:1.6; }
#app button, #app .btn { font-weight:650; line-height:1.35; border-radius:10px; transition:background-color .15s, border-color .15s, box-shadow .15s; }
#app button:hover:not(:disabled) { filter:brightness(1.04); }
#app button:focus-visible, #app input:focus-visible, #app textarea:focus-visible, #app select:focus-visible { outline:3px solid var(--brand); outline-offset:3px; }
#app button.sec { border:1px solid var(--line); background:var(--surface); }
#app button:disabled { opacity:.5; }
#app .card { padding:clamp(16px,2vw,24px); box-shadow:none; }
#app .hero { padding:28px; border-radius:18px; background:linear-gradient(125deg,#5141b1,#7461d9); }
#app .hero h1 { margin:0 0 8px; font-size:clamp(28px,3.4vw,38px); letter-spacing:-.035em; }
#app .hero p { font-size:17px; max-width:60ch; }
#app .steps { gap:12px; margin-top:24px; }
#app .steps li { border:1px solid rgba(255,255,255,.18); background:rgba(255,255,255,.1); border-radius:10px; padding:12px; }
#app .steps b { width:25px; height:25px; font-size:12px; }
#app .sect { margin:28px 0 14px; }
#app .gamecard, #app .gcard { gap:4px; }
#app .gamecard .row { margin-top:auto !important; padding-top:16px; }
#app .gcard-actions { padding-top:14px; }
#app .gamecard h3, #app .gcard h3 { font-size:19px; }
#app .stage { padding:16px; border-left-width:3px; border-radius:14px; gap:14px; }
#app .stage .n { border:0; font-size:14px; width:32px; height:32px; }
#app .stage .grow { min-width:min(220px,100%); }
#app .stage h3 { margin-bottom:5px; }
#app .acts { grid-template-columns:repeat(3,minmax(88px,1fr)); gap:8px; }
#app .acts.acts2 { grid-template-columns:repeat(5,minmax(88px,1fr)); border-top-style:solid; padding-top:12px; }
#app .acts .act { min-height:56px; gap:5px; padding:8px; }
#app .act .al { font-weight:600; line-height:1.3; }
#app .actions-end { margin-top:18px; }
#app .actions-end .primary { box-shadow:none; }
#app .params { padding:16px; border-style:solid; background:color-mix(in srgb,var(--brand) 4%,var(--card)); }
#app .params > p { margin-top:0; margin-bottom:14px; }
#app .pgrid { gap:16px; }
#app .pf { gap:7px; }
#app .pin input { width:100%; min-width:0; max-width:150px; font-variant-numeric:tabular-nums; }
#app .pin { align-items:baseline; }
#app input, #app textarea, #app select { border-width:1px; border-radius:9px; }
#app .wiz li, #app .stepper li { border-radius:9px; }
#app .playbar { gap:12px; margin-bottom:12px; }
#app .playbar h2 { font-size:clamp(16px,2vw,20px); letter-spacing:-.015em; }

/* Preserve the game's artwork while giving instructions and results readable UI. */
#app .how { --ink:#202227; }
#app .how-in { gap:14px; padding:20px 22px 0; }
#app .how-head { gap:7px; }
#app .how-head .how-title, #app .res-end .how-title, #app .res-lose .how-title { color:var(--ink); font-size:clamp(24px,3vw,34px); font-weight:750; line-height:1.25; letter-spacing:-.025em; text-shadow:none; -webkit-text-stroke:0; text-align:center; justify-content:center; }
#app .how-by, #app .how-sub { border-radius:7px; box-shadow:none; font-size:12px; font-weight:600; }
#app .how-stage, #app .how-card, #app .how-strip, #app .how-action, #app .res-hero, #app .res-side, #app .res-next { border-width:1px; border-radius:14px; box-shadow:0 3px 12px rgba(32,29,65,.09); }
#app .how-stage-tx { padding:12px; gap:4px; }
#app .how-stage-tx b, #app .how-tx b, #app .how-strip b, #app .res-lb, #app .res-next b { color:var(--ink); }
#app .how-stage-tx span, #app .how-action b { font-weight:650; }
#app .how-stage-tx small { font-size:12px; line-height:1.4; }
#app .how-action { padding:10px; }
#app .how-start { margin:auto -22px 0; padding:14px 22px 18px; gap:10px; }
#app .how-go, #app .res-btns .how-go { font-size:17px; font-weight:700; min-height:48px; min-width:180px; padding:12px 24px; border:1px solid var(--brand); border-radius:10px; background:var(--brand); color:#fff; text-shadow:none; box-shadow:0 3px 8px rgba(65,48,148,.18); animation:none; letter-spacing:0; }
#app .how-go:active, #app .res-sec:active { transform:translateY(1px); box-shadow:none; }
#app .res-sec, #app .res-btns .res-sec { min-height:48px; padding:11px 20px; font-size:16px; font-weight:650; color:var(--ink); border:1px solid var(--line); border-radius:10px; background:#fff; box-shadow:none; }
#app .res-in { padding-top:24px; gap:18px; }
#app .res-main { gap:16px; }
#app .res-hero, #app .res-side { padding:16px; }
#app .res-num { font-weight:750; font-size:48px; }
#app .res-cheer, #app .res-praise { font-size:16px; font-weight:500; line-height:1.6; padding:12px 16px; border-radius:12px; border:1px solid rgba(255,255,255,.8); box-shadow:none; max-width:62ch; }
#app .res-row { padding:8px 10px; border-width:1px; border-radius:9px; }
#app .res-row.cur { background:#edf2ff; border-color:#9badf3; box-shadow:none; }
#app .res-btns { gap:10px; }
#app .res-error { background:linear-gradient(150deg,#eef0ff,#f9fbff); }
#app .res-error .how-sun, #app .res-error .how-cl, #app .res-error .how-hl { display:none; }
#app .res-error .how-in { width:100%; max-width:720px; margin-inline:auto; justify-content:center; padding-top:28px; }
#app .res-error .how-title { font-size:clamp(24px,3vw,30px); }
#app .res-error .res-cheer { color:#4c4965; background:transparent; border:0; margin:0; padding:0; }
#app .res-error .res-btns { position:static; margin:0; padding:8px 0 28px; background:transparent; }

@media (max-width:760px) {
  #app .card { padding:16px; }
  #app .hero { padding:22px; }
  #app .hero p { font-size:16px; }
  #app .pgrid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #app .stage .grow { min-width:0; }
  #app .acts, #app .acts.acts2 { grid-template-columns:repeat(3,minmax(0,1fr)); }
  #app .how-in { padding:16px 14px 0; gap:12px; }
  #app .how-start { margin:auto -14px 0; padding:12px 14px calc(14px + env(safe-area-inset-bottom)); }
  #app .res-in { padding-top:20px; }
  #app .res-error .how-in { padding:24px 20px 0; }
}
@media (max-width:520px) {
  #app .hero { padding:20px; }
  #app .steps { gap:8px; }
  #app .steps li { padding:10px 8px; font-size:12px; gap:6px; }
  #app .pgrid { grid-template-columns:1fr; }
  #app .pin input { max-width:none; }
  #app .how-go, #app .res-btns .how-go { width:100%; min-width:0; font-size:16px; }
  #app .res-btns { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); margin:0 -14px; }
  #app .res-btns .how-go { grid-column:1 / -1; }
  #app .res-btns .res-sec { width:100%; font-size:14px; padding:10px 8px; }
  #app .res-error .res-btns { width:100%; margin:0; }
}
@media (orientation:landscape) and (max-height:520px) {
  #app .how-in { padding-top:12px; gap:10px; }
  #app .res-error .how-in { padding:18px; gap:12px; }
  #app .res-error .res-btns { padding-bottom:0; }
}

/* Discovery page */
.top, #app[data-view="home"], #app[data-view="newgame1"], #app[data-view="mygames"] {
  width:100%;
  max-width:1920px;
  margin-inline:auto;
  padding-inline:var(--page-inset);
}
.top { border-bottom:1px solid #eceef1; }
main, #app { padding-block:clamp(18px, 2vw, 32px) 48px; padding-inline:var(--page-inset); }
#app .home-page { color:#202227; }
main h1, #app h1 {
  margin:0 0 20px;
  font-size:clamp(30px, 2.5vw, 44px);
  line-height:1.12;
  letter-spacing:-.035em;
}
#app .home-studio {
  padding:clamp(16px, 1.5vw, 24px);
  background:var(--surface);
  border:1px solid #d7d9e0;
  border-radius:10px;
}
#app .home-studio h2 {
  display:flex;
  align-items:center;
  gap:12px;
  margin:0;
  font-size:clamp(16px, 1.15vw, 20px);
  font-weight:650;
}
.home-studio h2 svg { color:#3458ef; flex:none; }
#app .home-studio p { margin:12px 0 16px; color:#515763; }
.home-actions { display:flex; flex-wrap:wrap; gap:9px; }
#app .home-actions button { min-height:44px; padding:9px 15px; font-size:15px; }
#app .home-primary { background:#3458ef; color:#fff; }
#app .home-secondary { background:#e2e3e8; color:#262931; }
#app .home-discovery { margin-top:clamp(24px, 2vw, 36px); }
#app .home-discovery h2 {
  margin:0 0 16px;
  font-size:clamp(21px, 1.65vw, 29px);
  line-height:1.2;
}
.home-grid {
  display:grid;
  grid-template-columns:repeat(5, minmax(0, 1fr));
  gap:28px clamp(12px, 1.25vw, 24px);
}
.home-game { min-width:0; }
#app .home-tile {
  display:block;
  width:100%;
  padding:0;
  text-align:left;
  background:transparent;
  color:inherit;
}
#app .home-tile:hover { filter:none; }
.home-cover {
  position:relative;
  display:block;
  width:100%;
  aspect-ratio:16 / 9;
  overflow:hidden;
  border-radius:10px;
  background:#edeef2;
}
.home-cover img, .home-cover .thumb { display:block; width:100%; height:100%; margin:0; object-fit:cover; }
.home-play {
  position:absolute;
  inset:auto 8px 8px auto;
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:4px 8px;
  border-radius:6px;
  background:#171a20e6;
  color:white;
  font-size:12px;
  line-height:1.35;
  font-weight:600;
}
.home-game-name {
  display:block;
  overflow:hidden;
  margin-top:9px;
  font-size:clamp(16px, 1.15vw, 20px);
  font-weight:700;
  text-overflow:ellipsis;
  white-space:nowrap;
}
#app .home-tile:hover .home-game-name { text-decoration:underline; text-underline-offset:3px; }
.home-game-info { display:flex; flex-wrap:wrap; align-items:center; gap:2px 10px; color:#565c68; font-size:14px; }
#app .home-game-info button {
  min-height:36px;
  padding:0;
  background:transparent;
  color:#344eb0;
  font-size:inherit;
  font-weight:600;
}
#app .home-game-info button:hover { text-decoration:underline; }
#app .home-page button:focus-visible { outline:3px solid #3458ef; outline-offset:3px; }
@media (max-width:1100px) { .home-grid { grid-template-columns:repeat(4,minmax(0,1fr)); } }
@media (max-width:850px) { .home-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media (max-width:620px) {
  .home-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #app .home-game-info button { min-height:44px; }
}
@media (max-width:359px) { .home-grid { grid-template-columns:1fr; } }

/* Studio forms, libraries and stage controls share the discovery page's surfaces. */
.page-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; margin-bottom:20px; }
#app .page-heading h1 { margin:0; }
#app .template-grid { margin-top:24px; }
#app .wiz, #app .stepper { gap:8px; margin-block:12px 20px; }
#app .wiz li, #app .stepper li { background:var(--surface); border:1px solid var(--line); color:var(--muted); }
#app .wiz li:not(.off), #app .stepper li.cur { border-color:#aabafd; color:#223c9c; background:#f0f3ff; }
#app .wiz li.off { opacity:1; }
#app .wiz li.off b, #app .stepper li:not(.cur) b { background:var(--secondary); color:var(--muted); }
#app .head, #app .params, #app .gcard, #app[data-view="newgame"] .top-start > .card,
#app[data-view="setup"] .top-start > .card {
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
}
#app .head { padding:clamp(14px, 2vw, 24px); margin-bottom:20px; }
#app .stage { background:var(--card); border:1px solid var(--line); border-radius:var(--radius); }
#app .stage .n { background:#edf2ff; color:#2948bf; text-shadow:none; }
#app .acts .act { background:var(--surface); color:var(--ink); border:1px solid var(--line); }
#app .acts .act:hover, #app .sec:hover { background:#e9ebf0; }
#app .acts .act .ai { color:var(--brand); }
button.good { background:var(--brand); color:white; }
#app .chip.on, #app .packcard.on { border-color:var(--brand); background:#edf2ff; color:#223c9c; }
button.sec, .btn.sec { background:var(--surface); color:var(--ink); border:1px solid var(--line); }
#app .msg.ai { background:var(--surface); border:1px solid var(--line); }
#app .msg.me { background:#eaf0ff; color:#213775; }
#app .note:not(.err) { background:#f4f6fc; border-color:#d6deef; }
#app .pg-ok { color:var(--okc); }
#app .pg-bad { color:var(--badc); }
#app .how, #app .res-error, #app .ov:has(.how) { background:var(--card); }
#app .how { border:1px solid var(--line); border-radius:var(--radius); }
#app .how > :is(.how-sun,.how-cl,.how-hl), #app .how-spk { display:none; }
#app .how-stage, #app .how-strip, #app .how-action, #app .res-hero, #app .res-side,
#app .res-next, #app .res-row, #app .res-praise, #app .res-cheer {
  border:1px solid var(--line); border-radius:var(--radius); box-shadow:none; color:var(--ink); background:var(--surface);
}
#app .how-stage { background:var(--card); }
#app .how-sub, #app .how-phone, #app .how-stage-tx, #app .how-stage-tx small, #app .how-action small { color:var(--muted); }
#app .how-key, #app .res-no { background:#eaf0ff; color:#263f99; box-shadow:none; }
#app .how-start { background:var(--card); border-top:1px solid var(--line); }
#app .how-stage-no, #app .how-3d { background:#23262cd9; box-shadow:none; }
#app .res-hl, #app .res-x { color:var(--brand); }
#app .res-btns .res-sec { background:var(--surface); }
#app input:not([type="checkbox"]):not([type="radio"]), #app select, #app textarea { color:var(--ink); background-color:var(--card); }
@media (max-width:620px) {
  .page-heading { align-items:flex-start; }
  #app .wiz { flex-wrap:wrap; }
  #app .head .grow { min-width:min(180px,100%); }
  #app .stage, #app .card { min-width:0; }
}

.export-page main { max-width:900px; }
.export-page .note, .export-page .game, .art-library #out > p {
  background:var(--surface); border:1px solid var(--line); padding:16px; border-radius:var(--radius); margin:12px 0;
}
.export-page .meta, .art-library small { color:var(--muted); font-size:14px; }
.export-page .tag { display:inline-block; margin-inline-start:6px; }
.export-page :is(.same,.imported,.msg.ok) { background:#e0f4e8; color:#176135; }
.export-page .tag.new { background:#e8eeff; color:#27469e; }
.export-page .tag.diff { background:#fff0d1; color:#794b00; }
.export-page :is(.tag.error,.msg.bad) { background:#fde2e5; color:#982337; }
.export-page button { margin-top:8px; }
.export-page .msg { margin:10px 0; background:var(--card); }
.export-page a:not(.brand) { color:#344eb0; }
.art-library main { max-width:1600px; }
.art-library .asset-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(145px,100%),1fr)); gap:12px; margin-bottom:24px; }
.art-library .asset-cell { padding:12px; border:1px solid var(--line); border-radius:var(--radius); text-align:center; font-size:13px; overflow-wrap:anywhere; }
.art-library .asset-cell > div:first-child { display:grid; place-items:center; min-height:88px; margin-bottom:8px; border-radius:7px; background:var(--surface); }
.art-library .asset-cell img { max-width:100%; max-height:84px; }
.art-library .asset-missing { color:var(--bad); }
.export-page .game { min-width:0; overflow-wrap:anywhere; }
.toast.info { background:#edf2ff; color:#243e96; border:1px solid #aabafd; box-shadow:0 3px 12px rgba(32,34,39,.12); }

.top .studio-movie-link {display:inline-flex;align-items:center;white-space:nowrap;text-decoration:none;color:var(--ink);font-size:14px;font-weight:650;padding:6px 10px;border-radius:8px;}
.top .studio-movie-link:hover {background:#e9edff;color:#2846bd;}
