:root { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: #fffdf7;
  color: #2b2b2b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  cursor: pointer; /* iOS Safari only sends taps on blank space to document listeners if the target looks clickable */
}
#app { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }

.reader { position: relative; }
.reader-top { display: flex; justify-content: space-between; align-items: center; }
.home-btn, .btn {
  min-height: 44px; min-width: 44px;
  font: inherit; font-size: 18px;
  border-radius: 12px; cursor: pointer;
}
.home-btn {
  background: #fffdf7; color: #2b2b2b;
  border: 1px solid #d9d2bf; padding: 0 14px;
}
.btn {
  background: #2f6f4f; color: #ffffff;
  border: 2px solid #2f6f4f; padding: 0 22px; font-weight: 600;
}
.btn.reading { background: #ffffff; color: #2f6f4f; }
.home-btn:focus-visible, .btn:focus-visible, .word:focus-visible, .bubble button:focus-visible {
  outline: 3px solid #2f6f4f; outline-offset: 2px;
}

.title {
  font-family: Georgia, serif; font-size: 30px; line-height: 1.2;
  margin: 12px 0 16px;
}
.title-grade {
  font-family: system-ui, sans-serif; font-size: 0.5em; font-weight: 400; color: #6b6b5a;
  letter-spacing: 0.01em;
}
.notice {
  background: #fff1d6; border: 1px solid #e8cf99; border-radius: 10px;
  padding: 10px 14px; margin: 0 0 16px; font-size: 16px; line-height: 1.4;
}
.actions { margin: 0 0 16px; }

.story {
  list-style: none; margin: 0; padding: 0;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.line {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 4px 8px 6px; margin: 0 0 8px;
  border-radius: 14px; border-left: 6px solid transparent;
}
.line.now { background: #e4f0e8; border-left-color: #2f6f4f; }
.pic {
  flex: none; width: 60px; height: 56px; padding: 0; white-space: nowrap; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: #f3ecd9; border-radius: 14px;
}
.nb { white-space: nowrap; }
.body { flex: 1; min-width: 0; }
.en-btn {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  min-width: 44px; min-height: 44px; padding: 0;
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: 0.04em; cursor: pointer;
  background: #fffdf7; color: #5a5a4a; border: 1px solid #d9d2bf; border-radius: 10px;
}
.en-btn[aria-expanded="true"] { background: #f3ecd9; color: #2b2b2b; }
.en-btn:focus-visible { outline: 3px solid #2f6f4f; outline-offset: 2px; }
.en {
  margin: 0 0 4px; font-size: 18px; line-height: 1.4; color: #4a4a3e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.text {
  font-family: Georgia, serif; font-size: 24px; line-height: 1.6;
  min-width: 0; overflow-wrap: anywhere;
}
.word {
  font: inherit; color: inherit; background: none; border: 0;
  padding: 6px 1px; margin: 0; cursor: pointer;
  text-decoration-line: underline; text-decoration-style: dotted;
  text-decoration-color: #9a8f6e; text-decoration-thickness: 2px; text-underline-offset: 5px;
  border-radius: 4px; min-height: 44px; vertical-align: middle;
}
.word.tapped { background: #ffe9a8; }

.bubble {
  position: absolute; z-index: 5; left: 0; top: 0; white-space: normal;
  display: flex; align-items: center; gap: 8px;
  background: #2b2b2b; color: #ffffff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px; padding: 6px 6px 6px 14px; border-radius: 14px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3); max-width: calc(100% - 8px);
}
.bubble span { min-width: 0; }
.bubble button {
  flex: none; min-width: 44px; min-height: 44px; font-size: 20px;
  background: #ffffff; color: #2b2b2b; border: 0; border-radius: 10px; cursor: pointer;
}

.finish { margin-top: 24px; text-align: center; }

@media (min-width: 700px) {
  #app { padding-top: 24px; }
  .title { font-size: 40px; }
  .text { font-size: 32px; }
  .pic { width: 112px; height: 80px; font-size: 46px; }
  .line { gap: 14px; padding: 8px 10px; }
  .en { font-size: 22px; }
  .line { position: relative; }
  .body { padding-right: 64px; }
  .en-btn { font-size: 16px; min-width: 52px; position: absolute; right: 10px; top: 50%; margin: -22px 0 0; }
  .bubble { font-size: 22px; }
}

/* Home, stories and backup screens */
.screen { text-align: center; padding-top: 16px; }
.screen .notice { text-align: left; }
.grade-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 24px 0 20px; }
.grade { font-size: 22px; color: #5a5a4a; margin: 0; min-width: 120px; letter-spacing: 0.02em; }
.step-btn {
  min-width: 44px; min-height: 44px; font: inherit; font-size: 26px; line-height: 1; cursor: pointer;
  background: #ffffff; color: #2f6f4f; border: 2px solid #2f6f4f; border-radius: 12px; padding: 0;
}
.step-btn:disabled { opacity: 0.35; cursor: default; }
.step-btn:focus-visible { outline: 3px solid #2f6f4f; outline-offset: 2px; }
.gap { height: 16px; }
.btn-outline:focus-visible, .btn-quiet:focus-visible, .link-btn:focus-visible { outline: 3px solid #2f6f4f; outline-offset: 2px; }
.btn.big { min-height: 64px; font-size: 24px; padding: 0 36px; }
.btn-outline, .btn-quiet {
  min-height: 44px; font: inherit; font-size: 18px; cursor: pointer;
  background: #ffffff; color: #2f6f4f; border: 2px solid #2f6f4f; border-radius: 12px; padding: 0 22px;
}
.btn-quiet { color: #2b2b2b; border: 1px solid #d9d2bf; font-family: Georgia, serif; width: 100%; max-width: 360px; }
.link-btn {
  min-height: 44px; font: inherit; font-size: 16px; cursor: pointer;
  background: none; color: #2b2b2b; border: 0; text-decoration: underline; padding: 0 12px;
  display: block; margin: 32px auto 0;
}
.backup h2 { font-size: 18px; margin: 0 0 12px; }
.stories { text-align: left; }
.stories .title { margin-top: 12px; }
.grade-head { font-size: 20px; margin: 28px 0 12px; color: #2f6f4f; }
.story-list { list-style: none; margin: 0; padding: 0; }
.story-list li { margin: 0 0 8px; }
.story-list .btn-quiet { max-width: none; text-align: left; padding: 6px 14px; }
.tick { color: #2f6f4f; font-family: system-ui, sans-serif; font-weight: 700; }
.ladder-note { color: #5a5a4a; font-size: 16px; line-height: 1.4; margin: 16px 0 0; }
.backup { text-align: left; }
.backup .home-btn { margin-bottom: 8px; }
.backup .box {
  display: block; width: 100%; font: inherit; font-size: 16px; padding: 10px;
  background: #ffffff; color: #2b2b2b; border: 1px solid #d9d2bf; border-radius: 10px; margin: 0 0 12px;
}
.backup h2 { margin-top: 32px; }
.backup .error { color: #a02020; min-height: 1.4em; }
.backup .status { min-height: 1.4em; }
