/* MonzAcademy: the monzworks.com look (dark panels, orange accent, blueprint grid) over a 3D workshop. */
:root {
  --bg: #06080c; --panel: #0b0f15; --panel-2: #0d121a; --line: #1f2a37; --line-2: #2a3646; --line-soft: #1a2330;
  --ink: #e8edf2; --ink-2: #9aa7b5; --ink-3: #6f7d8c;
  --accent: #ff7a2f; --accent-ink: #0a0d12; --cyan: #34d3e0; --lime: #a3e635; --red: #ff5a5f; --gold: #ffc53d;
  --thai: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --display: 'Space Grotesk', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --panel-w: 380px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--thai); line-height: 1.6; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 8px; }
.mono { font-family: var(--mono); }
.dim { color: var(--ink-3); }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 30px; height: 30px; }
[hidden] { display: none !important; }

/* ---------- play layout ---------- */
.play { position: fixed; inset: 0; display: grid; grid-template-columns: 1fr var(--panel-w); grid-template-rows: 1fr; }
.viewport { position: relative; grid-column: 1; grid-row: 1; overflow: hidden; touch-action: none; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(6, 8, 12, .55) 100%); }
.hud { position: absolute; z-index: 5; left: 16px; right: calc(var(--panel-w) + 16px); top: 14px; display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: rgba(13, 18, 26, .78); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.hud-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.hud-title .mono { font-size: 12px; }
.hud-title b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps { display: flex; gap: 6px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.steps li { width: 26px; height: 6px; border-radius: 4px; background: var(--line-2); transition: background .3s; }
.steps li.done { background: var(--lime); }
.steps li.now { background: var(--accent); }
.icon-btn { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; }
.icon-btn:hover { border-color: var(--ink-3); }

.panel { grid-column: 2; grid-row: 1; z-index: 4; background: var(--panel); border-left: 1px solid var(--line); padding: 84px 22px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.kicker { font-size: 12px; color: var(--accent); letter-spacing: .04em; }
.panel h2 { margin: 0; font-size: 22px; line-height: 1.35; font-weight: 700; }
.panel p { margin: 4px 0; color: var(--ink-2); font-size: 15.5px; }
.tip { padding: 8px 12px; border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-radius: 10px; background: var(--panel-2); font-size: 14px; color: var(--ink-2); }
.tip summary { cursor: pointer; color: var(--cyan); font-size: 13px; min-height: 28px; display: flex; align-items: center; }
.tip[open] summary { margin-bottom: 4px; }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.readouts:empty { display: none; }
.ro { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); }
.ro small { display: block; font-size: 12.5px; color: var(--ink-3); }
.ro b { font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.ro b i { font-style: normal; font-size: 13px; color: var(--ink-3); margin-left: 4px; font-weight: 500; }
.ro.big { grid-column: 1 / -1; }
.ro.big b { font-size: 34px; }
.ro.ok { border-color: rgba(163, 230, 53, .45); } .ro.ok b { color: var(--lime); }
.ro.warn { border-color: rgba(255, 197, 61, .5); } .ro.warn b { color: var(--gold); }
.ro.bad { border-color: rgba(255, 90, 95, .5); } .ro.bad b { color: var(--red); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 12px; }
.panel .actions { position: sticky; bottom: -22px; padding-bottom: 4px; background: linear-gradient(transparent, var(--panel) 14px); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 15.5px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; flex: 1 1 auto; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sel { border-color: var(--accent); color: var(--accent); background: rgba(255, 122, 47, .08); }
.btn.small { flex: 0 0 auto; min-width: 48px; padding: 10px 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn-row { display: flex; gap: 8px; width: 100%; }
.btn-row .btn { flex: 1 1 0; }
.seg-label { width: 100%; font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }

.loupe { position: absolute; z-index: 3; left: 16px; top: 80px; width: 240px; height: 160px; border-radius: 14px; border: 2px solid var(--accent); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); pointer-events: none; }
.loupe-tag { position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(6, 8, 12, .75); color: var(--ink-2); }
.loupe-tag b { color: var(--ink); font-weight: 500; }
.meter { position: absolute; z-index: 3; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(440px, calc(100% - 32px)); padding: 10px 14px; border-radius: 14px; background: rgba(13, 18, 26, .85); border: 1px solid var(--line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.meter-label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.meter-track { position: relative; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #1b2532, #2a3646); overflow: hidden; }
.meter-band { position: absolute; top: 0; bottom: 0; background: rgba(163, 230, 53, .35); border-left: 2px solid var(--lime); border-right: 2px solid var(--lime); }
.meter-needle { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--ink); transition: left .08s linear; }
.meter.hot .meter-needle { background: var(--red); }
.toasts { position: absolute; z-index: 6; left: 50%; top: 80px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: rgba(13, 18, 26, .92); border: 1px solid var(--line-2); font-size: 15px; box-shadow: 0 12px 30px rgba(0, 0, 0, .4); animation: toast-in .25s ease-out; }
.toast.warn { border-color: var(--gold); } .toast.warn .ic { color: var(--gold); }
.toast.bad { border-color: var(--red); } .toast.bad .ic { color: var(--red); }
.toast.good { border-color: var(--lime); } .toast.good .ic { color: var(--lime); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- map ---------- */
.map { position: fixed; inset: 0; z-index: 10; overflow-y: auto; background: linear-gradient(180deg, rgba(6, 8, 12, .55), rgba(6, 8, 12, .92) 60%), linear-gradient(rgba(120, 150, 180, .07) 1px, transparent 1px) 0 0 / 48px 48px, linear-gradient(90deg, rgba(120, 150, 180, .07) 1px, transparent 1px) 0 0 / 48px 48px; }
.map-inner { max-width: 1120px; margin: 0 auto; padding: 18px 24px 40px; min-height: 100%; display: flex; flex-direction: column; }
.map-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; background: rgba(13, 18, 26, .82); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 700; font-size: 19px; }
.brand b { color: var(--accent); font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); font-size: 14px; color: var(--ink-2); }
.pill .ic { color: var(--gold); }
.pill b { color: var(--ink); }
.map-hero { padding: 44px 0 28px; }
.eyebrow { font-family: var(--mono); font-size: 12.5px; color: var(--lime); letter-spacing: .04em; }
.map-hero h1 { font-size: clamp(32px, 5vw, 56px); line-height: 1.15; margin: 12px 0 16px; letter-spacing: -.01em; }
.map-hero h1 em { font-style: normal; color: var(--accent); }
.lead { font-size: clamp(15.5px, 1.5vw, 18px); color: var(--ink-2); max-width: 640px; margin: 0; }
.chapters { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.chapter { border: 1px solid var(--line); border-radius: 18px; background: rgba(11, 15, 21, .86); padding: 18px; }
.chapter-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.chapter-head .mono { color: var(--ink-3); font-size: 13px; }
.chapter-head h2 { margin: 0; font-size: 19px; }
.levels { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lvl { position: relative; display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 16px; min-height: 96px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; transition: border-color .2s, transform .2s; }
.lvl:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.lvl:disabled { cursor: not-allowed; opacity: .55; }
.lvl-ic { width: 56px; height: 56px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255, 122, 47, .1); color: var(--accent); border: 1px solid rgba(255, 122, 47, .3); }
.lvl:disabled .lvl-ic { background: var(--panel); color: var(--ink-3); border-color: var(--line); }
.lvl-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.lvl-body .mono { font-size: 12px; color: var(--ink-3); }
.lvl-body b { font-size: 17px; }
.lvl-body small { color: var(--ink-2); font-size: 13.5px; }
.stars { display: inline-flex; gap: 3px; margin-top: 4px; }
.stars .ic { width: 18px; height: 18px; color: var(--line-2); }
.stars .on { color: var(--gold); --icon-fill: var(--gold); }
.lvl .badge { position: absolute; right: 12px; top: 12px; font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.lvl .badge.done { background: rgba(163, 230, 53, .15); color: var(--lime); }
.soon { opacity: .6; }
.soon .lvl { cursor: default; }
.map-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line-soft); font-size: 13.5px; color: var(--ink-3); }
.save-note { display: inline-flex; align-items: center; gap: 6px; }
.foot-links { display: flex; gap: 16px; }
.link { background: none; border: 0; padding: 8px 0; color: var(--ink-2); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(6, 8, 12, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet { width: min(560px, 100%); max-height: calc(100% - 16px); overflow-y: auto; padding: 24px; border-radius: 20px; border: 1px solid var(--line-2); background: var(--panel); box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: sheet-in .3s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.sheet h2 { margin: 6px 0 8px; font-size: 24px; line-height: 1.3; }
.sheet p { color: var(--ink-2); margin: 6px 0; }
.sheet .actions { margin-top: 18px; }
.learn { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.learn li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-size: 15px; }
.learn .ic { color: var(--cyan); margin-top: 2px; }
.prep { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.prep label { display: flex; gap: 12px; align-items: center; padding: 12px; min-height: 56px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line-2); cursor: pointer; }
.prep input { position: absolute; opacity: 0; pointer-events: none; }
.prep .box { width: 26px; height: 26px; flex: none; border-radius: 7px; border: 2px solid var(--line-2); display: grid; place-items: center; }
.prep .box .ic { width: 18px; height: 18px; opacity: 0; color: var(--accent-ink); }
.prep input:checked + .box { background: var(--accent); border-color: var(--accent); }
.prep input:checked + .box .ic { opacity: 1; }
.prep input:focus-visible + .box { outline: 2px solid var(--cyan); outline-offset: 2px; }
.prep .pic { color: var(--ink-2); }
.prep span.t { font-size: 15px; }
.result-stars { display: flex; justify-content: center; gap: 14px; margin: 16px 0 6px; }
.rs { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.rs .ic { width: 56px; height: 56px; color: var(--line-2); stroke-width: 1.2; }
.rs.on .ic { color: var(--gold); --icon-fill: var(--gold); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) both; }
.rs:nth-child(2).on .ic { animation-delay: .15s; } .rs:nth-child(3).on .ic { animation-delay: .3s; }
@keyframes pop { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
.res-lines { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.res-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 14.5px; }
.res-lines li b { font-family: var(--mono); font-weight: 500; text-align: right; }
.res-lines li.ok b { color: var(--lime); } .res-lines li.no b { color: var(--gold); }
.fail-box { padding: 14px; border-radius: 14px; border: 1px solid rgba(255, 90, 95, .5); background: rgba(255, 90, 95, .07); }
.fail-box h3 { margin: 0 0 4px; color: var(--red); display: flex; gap: 8px; align-items: center; font-size: 17px; }
.credits { font-size: 14.5px; color: var(--ink-2); display: grid; gap: 8px; padding-left: 18px; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; background: var(--bg); color: var(--ink-2); font-family: var(--mono); font-size: 13px; transition: opacity .4s; }
.boot.gone { opacity: 0; pointer-events: none; }

/* ---------- phones and portrait tablets ---------- */
@media (max-width: 899px), (orientation: portrait) {
  .play { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .viewport { grid-column: 1; grid-row: 1; }
  .panel { grid-column: 1; grid-row: 2; border-left: 0; border-top: 1px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); max-height: 44vh; gap: 2px; }
  .panel .actions { position: static; background: none; margin-top: 0; padding: 6px 0 0; order: 2; }
  .panel .tip { order: 3; margin-top: 8px; }
  .ro.big b { font-size: 24px; }
  .btn { min-height: 44px; padding: 8px 12px; font-size: 15px; }
  .panel h2 { font-size: 18.5px; }
  .panel p { font-size: 14.5px; margin: 2px 0; }
  .tip { padding: 8px 10px; }
  .readouts { margin: 6px 0 2px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .ro { padding: 6px 10px; }
  .ro b { font-size: 20px; } .ro.big b { font-size: 26px; }
  .actions { padding-top: 8px; }
  .hud { left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); padding: 6px 8px; gap: 8px; }
  .steps li { width: 14px; }
  .loupe { left: 10px; top: auto; bottom: 10px; width: 160px; height: 112px; }
  .toasts { top: 72px; }
  .meter { bottom: 10px; }
  .map-inner { padding: 12px 16px 28px; }
  .map-hero { padding: 28px 0 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.btn-row .btn.small { flex: 0 0 48px; }

/* a small drawing inside the step text */
.panel svg.dwg { display: block; width: 100%; max-width: 360px; height: auto; margin: 8px 0 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
@media (max-width: 899px), (orientation: portrait) { .panel svg.dwg { max-height: 110px; } }
.sheet video.lesson { display: block; width: 100%; max-height: 60vh; margin: 10px 0 4px; border-radius: 12px; background: #000; }
.on-map .panel, .on-map .hud { visibility: hidden; }
