:root {
  --bg: #f3eee6;
  --ink: #221c17;
  --muted: #5e564e;
  --card: #fffdf8;
  --line: #e4d8c8;
  --sage: #1d6b56;
  --sage-soft: #e5f0eb;
  --clay: #d4652f;
  --clay-soft: #f8e6da;
  --good: #1d6b56;
  --shadow: 0 18px 40px rgba(70, 46, 24, 0.08);
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(900px 420px at 0% -10%, #efe2d0, transparent 55%),
    radial-gradient(700px 480px at 100% 0%, #e4efe8, transparent 50%),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible {
  outline: 3px solid var(--clay);
  outline-offset: 2px;
}
img { max-width: 100%; display: block; }

#app { min-height: 100vh; }
main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 calc(28px + env(safe-area-inset-bottom));
}
.narrow { width: min(720px, calc(100% - 32px)); }

.top {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-side { width: 44px; flex: none; }
.brand {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.15;
}
.icon-btn, .seg button, .text-btn, .quiet-link, .choice, .speak, .row-card, .scene-card, .tile, .pair, .pic, .word-choice, .pin {
  border: 0;
  background: transparent;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
}
.seg {
  display: flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
}
.seg button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
}
.seg button[aria-pressed="true"] {
  background: var(--sage);
  color: #f4faf7;
}

.home h1, .narrow h1 {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 18px;
}
.eyebrow {
  margin: 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--sage);
}
.lead, .sheet-note, .notes, .quiet, .bad-note, .progress-line {
  color: var(--muted);
  line-height: 1.45;
}
.lead { margin-top: 0; font-size: 1.05rem; }

.tiles, .scene-grid, .list, .group-grid, .pic-grid {
  display: grid;
  gap: 12px;
}
.tiles { margin-top: 8px; }
.tile {
  text-align: left;
  min-height: 168px;
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}
.tile-scene {
  background:
    linear-gradient(180deg, rgba(243, 238, 230, 0.05), rgba(255, 253, 248, 0.94) 58%),
    url("../img/cocina.jpg") center/cover;
}
.tile-phrase { background: linear-gradient(160deg, #f7fbf8, #dceae3); }
.tile-group { background: linear-gradient(160deg, #fffdf8, #f3e2d4); }
.tile-match { background: linear-gradient(160deg, #fff8f3, #f6d9c8); }
.kicker { color: var(--sage); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }
.tile-title { font-family: var(--serif); font-size: 2rem; }
.tile-copy { color: var(--muted); max-width: 28ch; }

.scene-grid { grid-template-columns: 1fr 1fr; }
.scene-card {
  padding: 0;
  text-align: left;
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}
.scene-card img { aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.scene-card span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px 12px; }
.scene-card em, .row-card em { font-style: normal; color: var(--muted); }

.list { grid-template-columns: 1fr; }
.row-card, .pair, .hint-card, .word-block, .sheet-box {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.row-card {
  min-height: 64px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.row-card strong { font-size: 1.05rem; }

.scene-layout { display: grid; gap: 14px; }
.stage {
  position: relative;
  aspect-ratio: 16/9;
  border-radius: 24px;
  overflow: hidden;
  background: #efe6da;
  box-shadow: var(--shadow);
}
.stage img { width: 100%; height: 100%; object-fit: cover; }
.pin {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid var(--sage);
  box-shadow: 0 8px 18px rgba(40, 30, 20, 0.18);
  display: grid;
  place-items: center;
  padding: 0;
}
.stage .pin { position: absolute; transform: translate(-50%, -50%); }
.pin svg { width: 30px; height: 30px; }
.pin[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--clay), 0 8px 18px rgba(40, 30, 20, 0.2); }
.loose h2 { font-family: var(--serif); font-size: 1.4rem; margin: 18px 0 8px; }
.loose-row { display: flex; flex-wrap: wrap; gap: 10px; }

.word-block, .hint-card { padding: 18px; }
.learn-word {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.08;
  margin: 0;
  overflow-wrap: anywhere;
}
.word-block.large .learn-word { font-size: clamp(2.2rem, 7vw, 3.8rem); }
.learn-word.long { font-size: clamp(1.45rem, 4vw, 2.15rem); }
.more-notes { margin-top: 10px; color: var(--muted); }
.more-notes summary { cursor: pointer; }
.phonetic { margin: 8px 0; color: var(--clay); font-size: 1.05rem; }
.other-word { margin: 8px 0 0; font-size: 1.15rem; }
.other-word span {
  display: inline-block;
  margin-right: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.notes { margin-bottom: 0; }
.speak, .primary-block, .choice, .text-btn {
  min-height: 52px;
  border-radius: 999px;
  padding: 0 18px;
}
.speak {
  margin-top: 14px;
  background: var(--sage);
  color: #f4faf7;
}
.primary-block { width: 100%; background: var(--sage); color: #f4faf7; }
.text-btn { background: transparent; color: var(--sage); }
.quiet-link {
  display: block;
  margin: 22px auto 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.hint-card p { margin: 0 0 6px; font-size: 1.2rem; }
.stack { display: grid; gap: 8px; }
.progress-line { margin-top: 0; }
.phrase-main { padding-bottom: 12px; }
.dock {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding: 14px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 28%);
}
.choice.good { background: var(--sage); color: #f4faf7; }
.choice.again { background: var(--clay-soft); color: #6a3216; }

.group-grid { grid-template-columns: 1fr; }
.pair {
  text-align: left;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.pair .learn-word { font-size: clamp(1.7rem, 4vw, 2.3rem); }
.pair .phonetic { margin: 0; }
.pair .other-word { margin: 0; color: var(--muted); }

.match-tools { display: flex; justify-content: space-between; gap: 12px; align-items: end; flex-wrap: wrap; }
.match-tools .lead { margin: 0; flex: 1; }
.match-board { display: grid; gap: 14px; margin-top: 12px; }
.pic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pic, .word-choice {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.pic {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.pic-art {
  width: 100%;
  aspect-ratio: 1.15;
  border-radius: 14px;
  background: var(--sage-soft);
  display: grid;
  place-items: center;
}
.pic svg { width: 64%; height: 64%; }
.pic-word { font-family: var(--serif); font-size: 1.15rem; }
.pic.picked, .word-choice.picked { box-shadow: 0 0 0 3px var(--clay), var(--shadow); }
.pic.solved { opacity: 0.55; }
.word-col { display: grid; gap: 8px; align-content: start; }
.word-choice {
  min-height: 54px;
  text-align: left;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 1.35rem;
}
.bad-note { color: #8a3b28; margin: 8px 0 0; }

.sheet-box { margin-top: 28px; padding: 12px 14px 14px; }
.sheet-box summary { cursor: pointer; color: var(--muted); }
.sheet-box p { color: var(--muted); font-size: 0.92rem; }
.sheet-box label { display: grid; gap: 6px; font-size: 0.92rem; }
.sheet-box input {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
}
.sheet-note { font-size: 0.92rem; }
.empty { font-size: 1.2rem; }

@media (min-width: 800px) {
  .tiles, .list, .group-grid { grid-template-columns: 1fr 1fr; }
  .scene-grid { grid-template-columns: repeat(3, 1fr); }
  .tile { min-height: 230px; }
  .scene-layout { grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.7fr); align-items: start; }
  .detail { position: sticky; top: 12px; }
  .pin { width: 54px; height: 54px; }
  .pic-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .match-board { grid-template-columns: minmax(0, 1.3fr) minmax(240px, 0.7fr); }
}

@media (max-width: 380px) {
  .seg button { padding: 0 8px; }
  .tile-title { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
