@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Lexend-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/Lexend-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/Lexend-700.ttf') format('truetype');
}

:root {
  --bg: #FFF8E7;
  --ink: #1A140C;
  --muted: #5C5346;
  --accent: #FF6F00;
  --hi: #FFE566;
  --sent: #FFF3B0;
  --card: #FFFEF9;
  --shadow: 0 6px 0 rgba(180, 90, 0, 0.25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Lexend', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100dvh; }

.app {
  min-height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  padding: 8px 12px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar { display: flex; justify-content: flex-start; }
.btn-home {
  font-family: inherit;
  font-weight: 700;
  font-size: 1.05rem;
  background: #fff;
  color: var(--ink);
  border: 3px solid #F0D9A8;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 52px;
  cursor: pointer;
  box-shadow: 0 3px 0 #E0C080;
}
.btn-home:active { transform: translateY(2px); box-shadow: none; }
.app.is-cover .topbar { visibility: hidden; pointer-events: none; }

.art {
  width: min(100%, calc(min(42vh, 420px) * 5 / 3));
  max-width: 100%;
  aspect-ratio: 5 / 3;
  height: auto;
  margin-inline: auto;
  background: #87CEFA;
  border: 4px solid #F0D9A8;
  border-radius: 24px;
  overflow: hidden;
}
.art svg { width: 100%; height: 100%; display: block; }
.story-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 700;
  color: #E65100;
  line-height: 1.25;
}
.story-title[hidden] { display: none !important; }

.read { flex: 0 0 auto; padding: 4px 2px; }
.script {
  margin: 0;
  font-size: clamp(1.55rem, 5.6vw, 2.15rem);
  line-height: 1.55;
  letter-spacing: 0.01em;
  word-spacing: 0.08em;
  font-weight: 600;
  text-align: center;
}
.script .w {
  display: inline;
  border-radius: 8px;
  padding: 0 3px;
  cursor: pointer;
}
.script .w.active {
  background: var(--hi);
  box-shadow: 0 0 0 4px var(--hi);
  font-weight: 700;
}
.script .sent-active { background: var(--sent); border-radius: 10px; }

.btn-again, .btn-tap, .btn-go {
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 24px;
}
.btn-again {
  width: 100%;
  min-height: 72px;
  font-size: 1.5rem;
  background: #FF8A3D;
  color: #fff;
  box-shadow: var(--shadow);
}
.btn-again:active { transform: translateY(3px); box-shadow: none; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 4px solid #F0D9A8;
  border-radius: 22px;
  padding: 10px 8px 14px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 120px;
  box-shadow: 0 5px 0 #E8C98A;
}
.choice:active { transform: translateY(3px); box-shadow: none; }
.choice.selected {
  border-color: var(--accent);
  background: #FFF3E0;
  box-shadow: 0 5px 0 #E65100;
}
.choice .c-art { width: 100%; height: 72px; }
.choice .c-art svg { width: 100%; height: 100%; }
.choice .c-label {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
.choice .go {
  display: none;
  margin-top: 2px;
  width: 90%;
  min-height: 48px;
  font-size: 1.3rem;
  background: #2E7D32;
  color: #fff;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}
.choice.selected .go { display: block; }

.ending { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.ending[hidden], .choices[hidden], .overlay[hidden] { display: none !important; }
.the-end {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: #E65100;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 248, 231, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
}
.btn-tap {
  min-height: 120px;
  width: min(92vw, 520px);
  font-size: 2rem;
  background: #FF6F00;
  color: #fff;
  box-shadow: 0 8px 0 #E65100;
  padding: 20px;
}
.btn-tap:active { transform: translateY(4px); box-shadow: none; }

@media (min-height: 800px) {
  .art { width: min(100%, calc(min(46vh, 460px) * 5 / 3)); }
}
@media (min-width: 700px) {
  .script { font-size: 2.15rem; }
  .choice .c-art { height: 100px; }
  .choice .c-label { font-size: 1.4rem; }
  .choice { min-height: 140px; }
}
body { overflow-y: auto; }
