@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,600;1,9..144,500&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
  --paper: #f4eee3;
  --paper-deep: #e8dfd0;
  --card: #fffaf2;
  --ink: #1b2430;
  --soft: #4d5968;
  --mute: #7a8492;
  --line: rgba(27, 36, 48, 0.1);
  --leaf: #5d7f62;
  --leaf-soft: #dce6d6;
  --amber: #c48a3a;
  --amber-soft: #f3e3c4;
  --rose: #c45a3a;
  --rose-soft: #f3d4c6;
  --sky: #5b8fb0;
  --sky-soft: #d5e4ee;
  --slate: #5a6570;
  --slate-soft: #d8dde2;
  --clay: #b56a48;
  --clay-soft: #edd6c8;
  --shadow: 0 16px 40px rgba(70, 52, 28, 0.1);
  --safe-b: env(safe-area-inset-bottom, 14px);
  --safe-t: env(safe-area-inset-top, 14px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  background: #d6cebf;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

#app {
  height: 100%;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background: var(--paper);
  overflow: hidden;
  box-shadow: 0 0 50px rgba(40, 30, 10, 0.12);
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}
.screen.active { display: flex; }
.screen.paper { overflow: auto; -webkit-overflow-scrolling: touch; }

h1, h2, h3, .serif { font-family: Fraunces, Georgia, serif; font-weight: 500; letter-spacing: -0.03em; }
h1 { font-size: 42px; line-height: 0.98; }
h2 { font-size: 28px; line-height: 1.1; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
}
.lede { font-size: 17px; line-height: 1.45; color: var(--soft); }
.fine { color: var(--mute); font-size: 13px; }

.hero { position: relative; flex: 1; min-height: 0; }
.hero.short { flex: 0 0 36%; min-height: 190px; }
.hero.mid { flex: 0 0 58%; min-height: 280px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(27,36,48,.06) 0%, rgba(27,36,48,.16) 42%, rgba(27,36,48,.58) 100%);
}
.hero-copy {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 22px calc(22px + var(--safe-b));
  color: #fffaf2;
}
.hero-copy .eyebrow { color: #f3d7a6; }
.hero-copy h1 { margin: 8px 0 10px; }
.hero-copy .lede { color: rgba(255,250,242,.88); }

.topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(var(--safe-t) + 8px) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 3;
}
.topbar.light .bar-title { color: #fffaf2; font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 500; }
.mark {
  width: 36px; height: 36px; border-radius: 10px; object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.ghost-label {
  min-width: 72px; text-align: center;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,250,242,.86); font-weight: 600;
}
.ghost-btn {
  min-width: 64px; height: 34px; padding: 0 12px; border-radius: 999px;
  background: rgba(255,250,241,.92); color: var(--ink); font-size: 13px; font-weight: 600;
}
.ghost-btn.ink { background: var(--card); border: 1px solid var(--line); }

.btn {
  display: block; width: 100%; padding: 16px 18px; border-radius: 16px;
  font-size: 16px; font-weight: 600; background: var(--ink); color: var(--card);
}
.btn.wide { margin-top: 10px; }
.btn.ghost {
  background: rgba(255,250,242,.16); color: #fffaf2;
  border: 1px solid rgba(255,250,242,.28);
}
.sheet .btn.ghost, .play-dock .btn.ghost, .paper .btn.ghost {
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
}

.page-head { padding: calc(var(--safe-t) + 16px) 22px 8px; }
.page-head.split { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.pad-lead { padding: 4px 22px 16px; color: var(--soft); font-size: 16px; line-height: 1.4; }

.sheet { padding: 8px 22px calc(28px + var(--safe-b)); }
.sheet.tight { padding: 18px 22px calc(22px + var(--safe-b)); }
.sheet h2 { margin: 8px 0 12px; }
.sheet p { color: var(--soft); font-size: 16px; line-height: 1.5; }
.why { list-style: none; margin: 18px 0 22px; display: grid; gap: 14px; }
.why li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; font-size: 15px; line-height: 1.45; color: var(--soft); }
.why strong { color: var(--ink); display: block; margin-bottom: 2px; }

.light-chip, .moves {
  min-width: 44px; height: 44px; border-radius: 14px;
  background: var(--amber-soft); color: var(--ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  border: 1px solid rgba(196,138,58,.25);
}
.moves { background: var(--card); }

.rooms { padding: 0 16px calc(28px + var(--safe-b)); display: grid; gap: 12px; }
.room-card {
  display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px;
  text-align: left;
}
.room-card img { width: 92px; height: 92px; object-fit: cover; border-radius: 12px; }
.room-card h3 { font-size: 20px; }
.room-card p { color: var(--mute); font-size: 13px; margin-top: 3px; }
.room-card .state { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--leaf); padding-right: 8px; }
.room-card.locked .state { color: var(--mute); }
.room-card.done { outline: 2px solid rgba(93,127,98,.35); }

.letter-body { padding: 18px 22px calc(22px + var(--safe-b)); }
.story { font-size: 17px; line-height: 1.55; color: var(--soft); margin: 8px 0 16px; }
.goals { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.goal-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 12px; font-size: 14px; font-weight: 600;
}

.play-screen { background: var(--paper); }
.play-bar {
  padding: calc(var(--safe-t) + 8px) 14px 8px;
  display: flex; align-items: center; gap: 10px;
}
.play-meta { flex: 1; min-width: 0; }
.kit-title { font-family: Fraunces, Georgia, serif; font-size: 18px; }
.kit-sub { font-size: 13px; color: var(--mute); }
.goal-row {
  display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto;
}
.goal-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.goal-chip.met { background: var(--leaf-soft); border-color: transparent; }

.board-wrap { flex: 1; min-height: 0; padding: 0 10px; display: flex; align-items: center; }
.board {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  aspect-ratio: 6 / 7;
}
.cell {
  position: relative;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700;
  user-select: none; -webkit-user-select: none;
  transition: transform .12s ease, box-shadow .12s ease, opacity .15s ease;
}
.cell.sel { transform: scale(1.06); box-shadow: 0 0 0 3px var(--ink); z-index: 2; }
.cell.hint { box-shadow: 0 0 0 3px var(--amber); }
.cell.pop { transform: scale(.2); opacity: 0; }
.cell.dust::after {
  content: "";
  position: absolute; inset: 3px; border-radius: 11px;
  background: repeating-linear-gradient(-32deg, rgba(27,36,48,.16) 0 6px, transparent 6px 12px);
  pointer-events: none;
}
.cell.t-lemon { background: var(--amber-soft); color: #8a5a16; }
.cell.t-leaf { background: var(--leaf-soft); color: #2f4a34; }
.cell.t-ribbon { background: var(--rose-soft); color: #7a2e1c; }
.cell.t-book { background: var(--sky-soft); color: #2a4d66; }
.cell.t-tile { background: var(--slate-soft); color: #3a424a; }
.cell.t-spool { background: var(--clay-soft); color: #6a3a24; }

.play-dock { padding: 8px 16px calc(12px + var(--safe-b)); }
.hint { font-size: 14px; color: var(--soft); margin-bottom: 8px; min-height: 20px; }
.dock-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

@media (max-height: 700px) {
  h1 { font-size: 36px; }
  .board { gap: 4px; }
  .cell { border-radius: 11px; font-size: 18px; }
}

/* Web additions */
.studio-line { margin-top: 14px; font-size: 12px; color: var(--mute, #7a7468); text-align: center; }
.studio-line a { color: inherit; }
.studio-line.light { color: rgba(255,250,242,.8); }
.soft-pay { margin-top: 14px; padding: 14px; border-radius: 16px; background: rgba(255,250,242,.14); border: 1px solid rgba(255,250,242,.35); backdrop-filter: blur(6px); }
.soft-pay strong { display: block; color: #fffaf2; font-size: 15px; }
.soft-pay span { display: block; color: rgba(255,250,242,.88); font-size: 13.5px; margin-top: 4px; line-height: 1.4; }
.soft-pay .btn { margin-top: 10px; }
.soft-note { display: block; font-style: normal; font-size: 12px; margin-top: 8px; color: rgba(255,250,242,.85); }

.hero img.mark, .topbar img.mark { width: 36px; height: 36px; flex: 0 0 36px; }
.cell svg { width: 72%; height: 72%; pointer-events: none; }
.goal-chip .gi { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; }
.goal-chip .gi svg { width: 100%; height: 100%; }
@media (min-width: 700px) { body { background: #e9e1d2; } #app { box-shadow: 0 30px 80px rgba(60,50,30,.18); } }
