/* Zero to Hero: manga ink on paper. Red, fire orange, ink black. */
:root {
  --paper: #F4EFE6; --white: #FFFFFF; --ink: #141214; --ink-2: #3A3434; --muted: #6A615B;
  --red: #D7261E; --red-dark: #A81B14; --orange: #E8832A; --yellow: #F6C45A; --night: #22293F;
  --ok: #1F6B3A; --line: #141214;
  --title: "Exo 2", "Arial Black", sans-serif; --label: "Oswald", "Arial Narrow", sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, sans-serif; --talk: "Comic Neue", "Comic Sans MS", sans-serif; --jp: "Noto Sans JP", sans-serif;
  --tone-bw: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,.55) 45%, #fff 95%), repeating-linear-gradient(to bottom, #5E5852 0 1px, transparent 1px 3.5px);
  --tone-fire: repeating-linear-gradient(to bottom, rgba(110,18,10,.4) 0 1px, transparent 1px 3.5px), linear-gradient(to bottom, #B8261A 0%, #E8832A 55%, #F6C45A 100%);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/1.5 var(--body); }
h1, h2, h3 { margin: 0; font-family: var(--title); font-style: italic; font-weight: 900; line-height: 1.05; letter-spacing: -.3px; }
h1 { font-size: clamp(30px, 6vw, 44px); }
h2 { font-size: 24px; }
h3 { font-size: 20px; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.small { font-size: 14px; } .muted { color: var(--muted); }
.lead { max-width: 65ch; }
.t { font-family: var(--title); font-style: italic; font-weight: 900; }
.title-note { font-family: var(--label); font-weight: 500; font-size: 15px; letter-spacing: .5px; color: var(--ink-2); }
.kicker { font-family: var(--label); font-weight: 700; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--red); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--ink); color: var(--paper); display: flex; flex-direction: column; gap: 4px; padding: 20px 12px; }
.brand { display: grid; padding: 4px 8px 18px; }
.brand b { font-family: var(--title); font-style: italic; font-weight: 900; font-size: 26px; color: var(--red); line-height: 1; }
.brand span { font-family: var(--label); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; opacity: .8; }
.tab { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 10px 10px; cursor: pointer; font-family: var(--label); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 15px; color: var(--paper); text-align: left; min-height: 44px; }
.tab svg { width: 22px; height: 22px; flex: none; }
.tab[aria-current="page"] { background: var(--red); box-shadow: 4px 4px 0 var(--orange); }
.tab:hover:not([aria-current]) { background: #2A2628; }
.main { min-width: 0; }
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 28px 60px; display: grid; gap: 20px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 20; inset: auto 0 0 0; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 0; border-top: 3px solid var(--red); }
  .brand { display: none; }
  .tab { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 10.5px; letter-spacing: .5px; flex: 1; justify-content: center; text-align: center; min-height: 50px; }
  .tab svg { width: 22px; height: 22px; }
  .tab[aria-current="page"] { box-shadow: none; }
  .wrap { padding: 16px 16px 100px; gap: 16px; }
}

/* ---------- buttons ---------- */
.btn { border: 3px solid var(--ink); background: var(--white); padding: 10px 16px; font-family: var(--label); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 15px; cursor: pointer; min-height: 46px; box-shadow: 4px 4px 0 var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn.primary { background: var(--red); color: var(--paper); }
.btn.light { background: var(--paper); }
.btn.big { font-family: var(--title); font-style: italic; font-weight: 900; font-size: 20px; letter-spacing: 0; text-transform: uppercase; width: 100%; min-height: 54px; }
.btn.danger { background: var(--red-dark); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; transform: none; }
.link { border: 0; background: none; padding: 4px 0; cursor: pointer; font-family: var(--label); font-weight: 700; letter-spacing: .5px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.back { justify-self: start; }
.play { width: 44px; height: 44px; flex: none; border: 3px solid var(--ink); background: var(--white); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); padding: 0; }
.play svg { width: 22px; height: 22px; }
.play.big { width: auto; padding: 0 16px; gap: 8px; font-family: var(--label); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.play:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

/* ---------- manga panels ---------- */
.panel { position: relative; border: 4px solid var(--ink); overflow: hidden; height: 250px; background-color: var(--white); background-image: var(--tone-bw); }
.panel.color { background-color: var(--orange); background-image: var(--tone-fire); }
.panel .fig { position: absolute; z-index: 2; bottom: 0; left: 50%; transform: translateX(-58%); height: 112%; width: auto; max-width: none; top: 0; object-fit: cover; object-position: top; pointer-events: none; user-select: none; }
.panel .balloon { position: absolute; z-index: 1; top: 10px; right: 10px; width: 112px; min-height: 140px; }
.panel .sfx { position: absolute; z-index: 3; top: 6px; left: 10px; writing-mode: vertical-rl; font-family: var(--jp); font-weight: 900; font-size: 44px; line-height: 1; color: var(--red); -webkit-text-stroke: 2px var(--ink); transform: rotate(-6deg); pointer-events: none; }
.panel.color .sfx { color: var(--paper); }
.balloon { background: var(--white); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%; display: flex; align-items: center; justify-content: center; text-align: center; padding: 14px 10px; font-family: var(--talk); font-weight: 700; font-size: 13.5px; line-height: 1.15; text-transform: uppercase; }
.panel.gallery { height: 300px; box-shadow: 6px 6px 0 var(--ink); }
.panel.gallery .fig { transform: translateX(-50%); }
.panel.intro { height: 200px; margin-bottom: 4px; }
.panel.page-panel, .panel.unit-panel { height: 240px; box-shadow: 6px 6px 0 var(--ink); }
.panel.endpanel { width: min(100%, 420px); height: 300px; box-shadow: 6px 6px 0 var(--ink); }

/* home hero */
.hero-card { border: 4px solid var(--ink); background-color: var(--orange); background-image: var(--tone-fire); display: grid; grid-template-columns: minmax(130px, 200px) 1fr; align-items: end; gap: 10px; padding: 12px 14px 0; box-shadow: 6px 6px 0 var(--ink); position: relative; overflow: hidden; }
.hero-fig { position: relative; align-self: end; height: 230px; }
.hero-fig .fig { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 100%; width: auto; max-width: none; }
.hero-fig .sfx { position: absolute; top: 4px; left: -2px; writing-mode: vertical-rl; font-family: var(--jp); font-weight: 900; font-size: 32px; color: var(--red); -webkit-text-stroke: 1.5px var(--ink); z-index: 2; }
.hero-talk { display: grid; gap: 12px; padding-bottom: 14px; }
.hero-talk .btn.big { font-size: 18px; white-space: nowrap; padding: 10px 8px; }
.hero-talk .balloon { border-radius: 50% / 40%; min-height: 96px; font-size: 15px; padding: 16px 14px; }
@media (min-width: 761px) { .hero-card { grid-template-columns: 260px minmax(0, 380px); } .hero-fig { height: 300px; } .hero-talk { align-self: center; padding-bottom: 0; } .hero-talk .balloon { font-size: 17px; min-height: 150px; padding: 22px 26px; } }

/* ---------- stats, meters, cards ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { border: 3px solid var(--ink); background: var(--white); padding: 8px 10px; display: grid; gap: 2px; }
.stat b { font-family: var(--title); font-style: italic; font-weight: 900; font-size: 24px; line-height: 1; }
.stat span { font-family: var(--label); font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-2); }
.meter { height: 12px; border: 2.5px solid var(--ink); background: var(--paper); }
.meter i { display: block; height: 100%; background: var(--red); }
.card { border: 3px solid var(--ink); background: var(--white); padding: 18px; display: grid; gap: 12px; box-shadow: 5px 5px 0 var(--ink); }
.level-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; }
.blist { display: grid; gap: 14px; }
.lcard, .ucard { display: flex; align-items: stretch; text-align: left; border: 4px solid var(--ink); background: var(--white); box-shadow: 5px 5px 0 var(--ink); cursor: pointer; padding: 0; min-height: 84px; }
.lcard:active, .ucard:active { transform: translate(2px, 2px); box-shadow: 3px 3px 0 var(--ink); }
.lid { width: 74px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--ink); color: var(--paper); border-right: 4px solid var(--ink); font-family: var(--title); font-style: italic; font-weight: 900; font-size: 24px; }
.lcard.now .lid, .lcard.open .lid { background: var(--red); }
.lcard.done .lid { background: var(--orange); color: var(--ink); }
.lcard.lock, .ucard.lock { opacity: .6; }
.lbody2 { flex: 1; min-width: 0; padding: 10px 14px; display: grid; gap: 4px; }
.lbody2 b.t { font-size: 20px; line-height: 1.1; }
.ufig { width: 84px; flex: none; position: relative; overflow: hidden; border-right: 4px solid var(--ink); background-color: var(--white); background-image: var(--tone-bw); }
.ufig .fig { position: absolute; left: 50%; top: 0; transform: translateX(-50%); height: 170%; width: auto; max-width: none; }
.unote { font-family: var(--label); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--red); }
.ustate { display: flex; align-items: center; padding: 0 14px; font-family: var(--title); font-style: italic; font-weight: 900; }
.ustate svg { width: 26px; height: 26px; color: var(--ok); }
.ucard.now { outline: 4px solid var(--red); outline-offset: 3px; }

/* route of lessons */
.route { display: grid; gap: 12px; }
.stop { display: flex; align-items: center; gap: 14px; border: 3px solid var(--ink); background: var(--white); padding: 10px 14px; text-align: left; cursor: pointer; box-shadow: 4px 4px 0 var(--ink); min-height: 64px; }
.stop:disabled { cursor: default; opacity: .55; box-shadow: none; }
.stop .dot { width: 40px; height: 40px; flex: none; border: 3px solid var(--ink); display: flex; align-items: center; justify-content: center; font-family: var(--title); font-style: italic; font-weight: 900; background: var(--paper); }
.stop .dot svg { width: 20px; height: 20px; }
.stop.now { background: var(--red); color: var(--paper); }
.stop.now .muted { color: #FCE3D8; }
.stop.now .dot { background: var(--paper); color: var(--red); }
.stop.done .dot { background: var(--ink); color: var(--paper); }
.stop.exam .dot { background: var(--orange); width: 54px; }
.stop .lbl { display: grid; gap: 2px; }
.stop .lbl b { font-family: var(--title); font-style: italic; font-weight: 900; font-size: 18px; }
.pager { display: flex; justify-content: space-between; gap: 10px; }

/* ---------- lesson overlay ---------- */
.lesson { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding-top: env(safe-area-inset-top); }
.lhead { display: flex; align-items: center; gap: 12px; padding: 14px 16px 8px; max-width: 760px; width: 100%; margin: 0 auto; }
.lhead .meter { flex: 1; height: 18px; border-width: 3px; background: var(--white); }
.x { width: 44px; height: 44px; border: 3px solid var(--ink); background: var(--white); cursor: pointer; font-family: var(--label); font-weight: 700; font-size: 18px; }
.xpc { font-family: var(--title); font-style: italic; font-weight: 900; font-size: 18px; min-width: 52px; text-align: right; }
.lbody { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.linner { max-width: 760px; margin: 0 auto; padding: 12px 20px 24px; display: grid; gap: 16px; align-content: start; }
.linner.center { justify-items: center; text-align: center; }
.linner h2 { font-size: clamp(24px, 5vw, 32px); }
.linner h2.quote { font-size: clamp(24px, 5.5vw, 34px); }
.rows { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; border: 3px solid var(--ink); background: var(--white); padding: 10px 12px; }
.en { font-weight: 700; font-size: 19px; }
.opts { display: grid; gap: 10px; }
.opts.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.match { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.opt { border: 3px solid var(--ink); background: var(--white); padding: 12px; min-height: 54px; font-weight: 700; font-size: 17px; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); text-align: center; }
.opt.en { font-size: 18px; }
.opt.sel { background: var(--ink); color: var(--paper); }
.opt.right { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--orange); }
.opt.wrong { background: #FBE3E1; color: #8E1712; border-color: var(--red); text-decoration: line-through; }
.opt:disabled { cursor: default; }
.opt:disabled:not(.right):not(.wrong) { opacity: .6; }
.answer { min-height: 62px; border-bottom: 3px solid var(--ink); display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding-bottom: 10px; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.tile { border: 3px solid var(--ink); background: var(--white); box-shadow: 3px 3px 0 var(--ink); padding: 8px 12px; font-weight: 700; font-size: 18px; cursor: pointer; min-height: 46px; }
.tiles .tile:disabled { background: #E8E2D6; color: #9A928A; border-color: #9A928A; box-shadow: none; }
.cloze { font-family: var(--title); font-style: italic; font-weight: 900; font-size: clamp(24px, 5.5vw, 32px); line-height: 1.25; }
.gap { display: inline-block; min-width: 3.5em; border-bottom: 4px solid var(--red); color: var(--red); }
.gap.right { color: var(--ink); border-color: var(--ink); }
.gap.wrong { color: var(--red); }
.input { width: 100%; font-size: 20px; padding: 12px 14px; border: 3px solid var(--ink); background: var(--white); font-family: var(--body); }
.input:focus { outline: 3px solid var(--red); outline-offset: 2px; }
.lfoot { border-top: 4px solid var(--ink); background: var(--paper); padding-bottom: env(safe-area-inset-bottom); }
.lfoot-bar { max-width: 760px; margin: 0 auto; padding: 12px 16px 16px; display: grid; gap: 10px; }
.lfoot.ok, .lfoot.no { background: var(--ink); color: var(--paper); border-top: 0; }
.lfoot .panel.react { border: 0; border-top: 4px solid var(--ink); border-bottom: 4px solid var(--ink); height: min(250px, 30vh); max-width: 760px; margin: 0 auto; }
.lfoot .msg { font-family: var(--label); font-weight: 500; font-size: 16px; letter-spacing: .3px; }
.lfoot .msg b { color: var(--orange); }
.end .linner { gap: 18px; }
.end .stats { width: 100%; max-width: 460px; }
.item { border: 3px solid var(--ink); background: var(--white); padding: 12px; display: grid; gap: 4px; justify-items: center; text-align: center; }
.item svg { width: 64px; height: 64px; }
.item.off { opacity: .4; filter: grayscale(1); }

/* ---------- review ---------- */
.review { max-width: 560px; width: 100%; margin: 0 auto; display: grid; gap: 14px; }
.flash { border: 4px solid var(--ink); background-color: var(--white); background-image: var(--tone-bw); box-shadow: 6px 6px 0 var(--ink); padding: 30px 18px; display: grid; gap: 12px; justify-items: center; text-align: center; min-height: 220px; align-content: center; }
.flash .big { font-family: var(--title); font-style: italic; font-weight: 900; font-size: clamp(28px, 7vw, 40px); }
.flash .mean { font-size: 20px; font-weight: 700; }
.srs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.srs .btn { flex-direction: column; padding: 8px 4px; font-size: 13px; }
.srs small { font-family: var(--body); text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12px; }

/* ---------- trophies, plan, heroes, options ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal i { aspect-ratio: 1; border: 2.5px solid var(--ink); background: var(--white); display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 11px; font-family: var(--label); }
.cal i.y { background: var(--red); }
.cal i.p { background: var(--orange); }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.badge { border: 3px solid var(--ink); padding: 10px 12px; display: grid; gap: 4px; background: var(--paper); }
.badge .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.badge .top b { font-family: var(--title); font-style: italic; font-weight: 900; }
.pill { font-family: var(--label); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; border: 2px solid var(--ink); padding: 1px 6px; white-space: nowrap; }
.badge.on { background: var(--white); }
.badge.on .pill { background: var(--red); color: var(--paper); border-color: var(--red); }
.tablewrap { overflow-x: auto; border: 3px solid var(--ink); background: var(--white); }
table { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 15px; }
th, td { padding: 10px 12px; border-bottom: 2px solid #D9D2C7; text-align: left; vertical-align: top; }
th { background: var(--ink); color: var(--paper); font-family: var(--label); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: 13px; }
td.num { white-space: nowrap; }
.heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.herocard { box-shadow: none; border: 0; background: none; padding: 0; }
.herocard h2 { font-size: 34px; color: var(--red); -webkit-text-stroke: 1px var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2.5px solid var(--ink); background: var(--white); padding: 6px 12px; font-family: var(--label); font-weight: 700; letter-spacing: .5px; text-transform: uppercase; font-size: 13px; cursor: pointer; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.field { display: grid; gap: 8px; }
.field input { font-size: 17px; padding: 10px 12px; border: 3px solid var(--ink); background: var(--white); }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.status { font-size: 14px; font-family: var(--label); }
.status.ok { color: var(--ok); } .status.bad { color: var(--red-dark); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
@media (max-width: 420px) { .stat b { font-size: 20px; } .lid { width: 60px; font-size: 20px; } .ufig { width: 70px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
