/* Dorothy's Journey — e-ink first stylesheet (Onyx Boox Note Air 5C, Kaleido 3).
   Rules: no animation, no shadows, no thin grey lines, solid saturated colours,
   big tap targets, serif body text, page-sized screens (no long scrolling). */

:root {
  --ink: #000;
  --paper: #fff;
  --paper-2: #fff7d6;      /* warm panel tint, visible on colour e-ink */
  --accent: #1f6fd1;       /* saturated blue */
  --accent-2: #f2c200;     /* yellow brick */
  --green: #0f8a3c;
  --red: #d12f2f;
  --border: 3px solid var(--ink);
  --radius: 14px;
  --text-size: 27px;
  --ui-size: 22px;
}

*, *::before, *::after { box-sizing: border-box; transition: none !important; animation: none !important; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: "Literata", "Charter", "Iowan Old Style", Georgia, "Noto Serif", "Times New Roman", serif;
  font-size: var(--ui-size);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(31,111,209,.35);
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus { outline: none; }

#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---------- header ---------- */
#top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: var(--border); background: var(--paper);
}
#crumb { flex: 1; text-align: center; font-weight: 700; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav {
  min-height: 56px; min-width: 56px; padding: 0 16px;
  border: var(--border); border-radius: var(--radius); background: var(--paper);
  font-weight: 700; font-size: 22px;
}
.bag-toggle { display: none; }

/* ---------- layout ---------- */
#main { display: flex; flex: 1; align-items: stretch; }
#reader { flex: 1 1 66%; display: flex; flex-direction: column; min-width: 0; }
#screen { flex: 1; padding: 22px 28px 10px; }
#bag {
  flex: 0 0 34%; max-width: 420px; border-left: var(--border);
  display: flex; flex-direction: column; background: var(--paper-2);
}

/* ---------- pager ---------- */
#pager {
  display: flex; gap: 12px; padding: 12px 20px 18px; border-top: var(--border);
  background: var(--paper);
}
.big {
  flex: 1; min-height: 72px; font-size: 26px; font-weight: 700;
  border: var(--border); border-radius: var(--radius); background: var(--paper);
}
.big.primary { background: var(--accent-2); }
.big.speak { flex: 0 0 auto; padding: 0 22px; background: var(--paper); }
.big[disabled] { opacity: .35; }
.big.hidden { display: none; }

/* ---------- text page ---------- */
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.story-text { font-size: var(--text-size); line-height: 1.75; margin: 0; }
.story-text p { margin: 0 0 .6em; }
.w {
  display: inline; padding: 2px 2px; border-radius: 6px; border-bottom: 3px solid transparent;
}
.w.hit { background: #fff0a8; border-bottom-color: var(--accent); }
.w.active { background: var(--accent-2); border-bottom-color: var(--ink); }
.hint { margin-top: 18px; font-size: 19px; color: #333; border-left: 6px solid var(--accent-2); padding-left: 12px; }

/* ---------- tooltip ---------- */
#tip {
  position: absolute; z-index: 50; max-width: 420px;
  background: var(--paper); border: var(--border); border-radius: var(--radius);
  padding: 10px 16px; text-align: center;
}
#tip[hidden] { display: none; }
#tip::after {
  content: ""; position: absolute; left: 50%; bottom: -16px; margin-left: -12px;
  border: 12px solid transparent; border-top-color: var(--ink); border-bottom: 0;
}
#tip.below::after { bottom: auto; top: -16px; border-top: 0; border-bottom: 12px solid var(--ink); }
.tip-word { font-weight: 700; font-size: 26px; color: var(--accent); }
.tip-ru { font-size: 24px; }

/* ---------- comic page ---------- */
.comic { display: flex; flex-direction: column; gap: 14px; }
.comic-head { font-size: 20px; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: .04em; }
.panel {
  border: 4px solid var(--ink); border-radius: 8px; background: #fff; overflow: hidden;
  width: 100%;
}
.panel img { display: block; width: 100%; height: auto; max-height: 58vh; object-fit: cover; }
.panel svg { display: block; width: 100%; height: auto; max-height: 58vh; }
.panel .placeholder {
  min-height: 300px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 30px; background: repeating-linear-gradient(45deg, #fff, #fff 14px, #fff2b0 14px, #fff2b0 28px);
  font-size: 22px; font-weight: 700;
}
.bubbles { display: flex; flex-wrap: wrap; gap: 14px; }
.bubble {
  flex: 1 1 260px; position: relative; background: var(--paper); border: var(--border); border-radius: 22px;
  padding: 14px 18px 14px; font-size: 24px; line-height: 1.5;
}
.bubble::before {
  content: ""; position: absolute; top: -22px; left: 36px;
  border: 11px solid transparent; border-bottom-color: var(--ink); border-top: 0;
}
.bubble::after {
  content: ""; position: absolute; top: -16px; left: 39px;
  border: 8px solid transparent; border-bottom-color: var(--paper); border-top: 0;
}
.bubble .who {
  display: inline-block; font-size: 18px; font-weight: 700; color: #fff; padding: 2px 12px; border-radius: 10px;
  margin: -26px 0 8px -4px; position: relative; text-transform: uppercase; letter-spacing: .05em;
}
.bubble.toto { font-style: italic; }

/* ---------- contents ---------- */
.cover { text-align: center; padding: 10px 0 6px; }
.cover h1 { font-size: 44px; margin: 0; line-height: 1.1; }
.cover .ru { font-size: 24px; color: #333; margin: 6px 0 2px; }
.cover .sub { font-size: 20px; color: #333; }
.toc { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toc li { }
.toc button {
  width: 100%; text-align: left; min-height: 70px; padding: 8px 14px;
  border: var(--border); border-radius: var(--radius); background: var(--paper);
  display: flex; align-items: center; gap: 12px;
}
.toc .num { font-size: 28px; font-weight: 700; color: var(--accent); min-width: 40px; }
.toc .t { font-weight: 700; font-size: 22px; line-height: 1.2; }
.toc .r { font-size: 18px; color: #333; }
.toc .done { margin-left: auto; font-size: 26px; color: var(--green); }
.toc button.current { background: var(--paper-2); border-color: var(--accent); }
.howto { margin-top: 16px; font-size: 19px; border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px 14px; background: var(--paper-2); }

/* ---------- story end ---------- */
.end { text-align: center; padding: 30px 10px; }
.end h2 { font-size: 36px; margin: 0 0 10px; }
.end .big-emoji { font-size: 80px; line-height: 1; }
.end p { font-size: 24px; }

/* ---------- bag ---------- */
.bag-head { padding: 14px 16px 6px; border-bottom: var(--border); }
.bag-head h2 { margin: 0; font-size: 26px; }
.bag-sub { font-size: 18px; color: #333; }
.bag-score { padding: 10px 16px; border-bottom: var(--border); background: var(--paper); }
.score-num { font-size: 28px; font-weight: 700; }
.stars { font-size: 24px; letter-spacing: 2px; min-height: 30px; word-break: break-all; }
.stars.none { font-size: 18px; letter-spacing: 0; color: #333; word-break: normal; }
.level { font-size: 18px; color: #333; }
#bag-list { list-style: none; margin: 0; padding: 8px 10px; flex: 1; overflow-y: auto; }
#bag-list li { margin: 0 0 8px; }
#bag-list button {
  width: 100%; text-align: left; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper);
  padding: 8px 12px; display: flex; flex-direction: column; min-height: 56px;
}
#bag-list .bw { font-weight: 700; font-size: 22px; color: var(--accent); }
#bag-list .br { font-size: 18px; color: #222; line-height: 1.3; }
#bag-list .bn { font-size: 15px; color: #555; }
#bag-list li.empty { font-size: 18px; color: #333; padding: 12px; text-align: center; }
.bag-foot { padding: 10px 12px; border-top: var(--border); }
.small { width: 100%; min-height: 52px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); font-size: 18px; font-weight: 700; }
.small.danger { background: var(--red); color: #fff; }

/* ---------- narrow screens (phone / portrait tablet) ---------- */
@media (max-width: 860px) {
  :root { --text-size: 25px; }
  .bag-toggle { display: inline-block; }
  #main { flex-direction: column; }
  #bag { flex: 0 0 auto; max-width: none; border-left: 0; border-top: var(--border); display: none; }
  #app.show-bag #bag { display: flex; }
  #app.show-bag #reader { display: none; }
  #bag-list { max-height: 60vh; }
  .toc { grid-template-columns: 1fr; }
  #screen { padding: 16px 16px 8px; }
  #pager { padding: 10px 12px 14px; }
  .big { min-height: 64px; font-size: 22px; }
}
@media (max-width: 480px) {
  .nav { padding: 0 10px; font-size: 18px; }
  .big.speak { padding: 0 12px; }
}
