:root {
  color-scheme: light;
  --cream: #fbf4e8;
  --cream-2: #f2e8d8;
  --ink: #443a35;
  --muted: #7b6f68;
  --sage: #8fa58d;
  --sage-deep: #556b58;
  --sage-soft: #dbe5d6;
  --rose: #c9969f;
  --rose-soft: #eed9dc;
  --plum: #6e4f68;
  --gold: #d4ae67;
  --gold-deep: #a77d38;
  --white: #fffdf9;
  --line: rgba(68, 58, 53, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background: linear-gradient(180deg, #efe7dc 0%, #e4ded2 100%);
  color: var(--ink);
  padding: max(10px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  overscroll-behavior: none;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid rgba(110,79,104,.35); outline-offset: 3px; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { width: min(100%, 480px); margin: 0 auto; position: relative; }
.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
}
.brand-kicker, .eyebrow, .level-label {
  display: block;
  color: var(--plum);
  font-size: .63rem;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}
.topbar h1 {
  margin: 1px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.62rem;
  line-height: 1;
  color: #483f3b;
}
.light-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 70px;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,253,249,.82);
  border: 1px solid rgba(212,174,103,.28);
  box-shadow: 0 5px 18px rgba(80,63,51,.08);
  color: var(--gold-deep);
}
.light-pill span { color: var(--gold); }

.game-card {
  border-radius: 30px;
  overflow: hidden;
  background: var(--white);
  border: 1px solid rgba(255,255,255,.76);
  box-shadow: 0 24px 60px rgba(83,70,60,.16);
}
.scene {
  height: 176px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #c9d9d8 0%, #efe1c2 73%, #dcc89c 100%);
}
.sun {
  position: absolute;
  width: 70px;
  height: 70px;
  right: 40px;
  top: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7d7 0 24%, #efd28d 55%, rgba(239,210,141,.25) 70%, transparent 72%);
}
.hill { position: absolute; left: -10%; width: 120%; border-radius: 50% 50% 0 0; }
.hill-back { height: 95px; bottom: -35px; background: #b6c2a5; transform: rotate(-2deg); }
.hill-front { height: 78px; bottom: -42px; background: #81947c; transform: rotate(3deg); }
.scene-copy { position: absolute; left: 22px; top: 24px; max-width: 260px; }
.scene-copy h2 {
  margin: 4px 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  line-height: 1;
  color: #4c4940;
}
.scene-copy p { margin: 0; font-size: .82rem; color: #67635c; }

.puzzle-panel { padding: 12px 14px 16px; background: linear-gradient(180deg, #fffdf9 0%, #fbf4e8 100%); }
.puzzle-toolbar {
  min-height: 38px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}
.puzzle-toolbar > :last-child { justify-self: end; }
.soft-button, .round-action, .primary-button, .secondary-button, .level-button, .letter-btn {
  border: 0;
  cursor: pointer;
  color: inherit;
}
.soft-button {
  background: var(--cream-2);
  color: #6c625b;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: .72rem;
  font-weight: 850;
}

.crossword {
  --cell: 34px;
  min-height: 220px;
  display: grid;
  justify-content: center;
  align-content: center;
  gap: 4px;
  padding: 8px 0 4px;
  overflow: visible;
}
.cross-cell {
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e8dfd2;
  box-shadow: inset 0 -2px 0 rgba(97,77,64,.08);
  color: #554b45;
  font-weight: 900;
  font-size: 1rem;
  text-transform: uppercase;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}
.cross-cell.revealed { background: var(--white); border: 1px solid rgba(143,165,141,.36); color: var(--sage-deep); box-shadow: 0 3px 10px rgba(91,105,86,.08); }
.cross-cell.hint { animation: hintPop 420ms ease; background: var(--rose-soft); color: var(--plum); }
@keyframes hintPop { 0%{transform:scale(.65)} 60%{transform:scale(1.12)} 100%{transform:scale(1)} }

.word-readout-wrap { min-height: 54px; display: grid; place-items: center; align-content: center; }
.word-readout {
  min-height: 26px;
  color: var(--plum);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.word-readout.idle { color: #9b918a; font-family: inherit; font-size: .76rem; letter-spacing: 0; font-weight: 700; text-transform: none; }
.message { min-height: 17px; color: var(--sage-deep); font-size: .71rem; font-weight: 800; }
.message.bad { color: #a36d72; }

.letter-wheel {
  width: 260px;
  height: 260px;
  margin: 0 auto;
  position: relative;
  border-radius: 50%;
  background: radial-gradient(circle, #faf5ed 0 28%, #f1e9dd 29% 64%, #e9dfd0 100%);
  border: 1px solid rgba(98,82,70,.08);
  box-shadow: inset 0 0 0 9px rgba(255,255,255,.34), 0 10px 24px rgba(95,77,64,.10);
  touch-action: none;
  user-select: none;
}
.wheel-center {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--white);
  color: var(--gold);
  box-shadow: 0 4px 12px rgba(70,56,47,.09);
  pointer-events: none;
}
.letter-btn {
  position: absolute;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fffdf9;
  color: #554b45;
  box-shadow: 0 7px 15px rgba(78,62,52,.13), inset 0 -3px 0 rgba(121,94,73,.08);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  font-size: 1.45rem;
  z-index: 3;
  transition: transform 90ms ease, background 90ms ease, color 90ms ease;
}
.letter-btn.active { background: var(--plum); color: white; transform: scale(1.08); }
.trace-svg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.trace-svg polyline { fill: none; stroke: rgba(110,79,104,.48); stroke-width: 17; stroke-linecap: round; stroke-linejoin: round; }

.bottom-actions {
  min-height: 54px;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
  align-items: center;
  color: #8a7e76;
  text-align: center;
  font-size: .67rem;
  font-weight: 700;
}
.round-action {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #efe5d7;
  color: #675d56;
  font-size: 1.1rem;
}

.overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(63,52,47,.36);
  backdrop-filter: blur(8px);
}
.overlay.visible { display: flex; }
.modal-card {
  width: min(100%, 350px);
  border-radius: 28px;
  padding: 28px 24px;
  background: linear-gradient(180deg, #fffdf9, #f7eee2);
  border: 1px solid rgba(255,255,255,.82);
  box-shadow: 0 28px 80px rgba(64,49,42,.28);
  text-align: center;
}
.modal-card h2 {
  margin: 9px 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.3rem;
  line-height: 1.02;
  color: #4d423d;
}
.modal-card p { color: var(--muted); font-size: .9rem; line-height: 1.55; }
.primary-button, .secondary-button {
  width: 100%; min-height: 52px; border-radius: 16px; font-weight: 900;
}
.primary-button {
  margin-top: 12px;
  background: linear-gradient(180deg, #b2c4ae, #8fa58d);
  color: #fff;
  box-shadow: 0 6px 0 #6e836d;
}
.primary-button:active { transform: translateY(2px); box-shadow: 0 4px 0 #6e836d; }
.secondary-button { margin-top: 10px; background: #eee4d8; color: #6d625b; }
.microcopy { display: block; margin-top: 14px; color: #9a8f87; font-size: .7rem; }
.complete-mark { width: 58px; height: 58px; margin: 12px auto 4px; border-radius: 50%; display: grid; place-items: center; background: #f4e8c9; color: var(--gold-deep); font-size: 1.7rem; }
.verse-card blockquote { margin: 16px 0 7px; font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.5; color: #5f544c; }
.verse-card cite { font-style: normal; color: var(--plum); font-weight: 900; font-size: .75rem; letter-spacing: .08em; }
.reward-line { margin-top: 20px; padding: 11px 14px; border-radius: 14px; background: #f5ead5; color: var(--gold-deep); font-size: .8rem; font-weight: 850; }

.level-drawer {
  position: fixed;
  z-index: 40;
  left: 50%; bottom: 0;
  width: min(100%, 500px);
  max-height: 78dvh;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: #fbf4e8;
  box-shadow: 0 -25px 70px rgba(58,46,40,.24);
  transform: translate(-50%, 110%);
  transition: transform 220ms ease;
}
.level-drawer.open { transform: translate(-50%, 0); }
.drawer-header { display: flex; justify-content: space-between; align-items: start; }
.drawer-header h2 { margin: 5px 0 18px; font-family: Georgia, "Times New Roman", serif; font-size: 1.9rem; }
.level-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; overflow-y: auto; }
.level-button {
  min-height: 86px;
  border-radius: 18px;
  background: #fffdf9;
  border: 1px solid var(--line);
  color: #5e544e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 5px 14px rgba(74,59,50,.06);
}
.level-button strong { font-size: 1.2rem; }
.level-button span { font-family: Georgia, "Times New Roman", serif; font-size: .72rem; color: var(--plum); }
.level-button small { color: #9b918a; font-size: .6rem; }
.level-button.locked { opacity: .42; }
.level-button.current { border-color: rgba(110,79,104,.48); box-shadow: inset 0 0 0 1px rgba(110,79,104,.28); }

@media (max-height: 780px) {
  .scene { height: 145px; }
  .crossword { --cell: 31px; min-height: 180px; }
  .letter-wheel { width: 232px; height: 232px; }
  .letter-btn { width: 52px; height: 52px; margin: -26px 0 0 -26px; font-size: 1.3rem; }
  .bottom-actions { min-height: 46px; }
}

@media (min-width: 700px) {
  body { padding-top: 22px; }
  .app-shell { width: 430px; }
}
