/* First Words LIVE: cozy folk valley at blue hour. Palette from the Babel key art
   (client/shell.html): blue-hour sky, deep dusk, lantern cream, lantern amber, the
   visitor's teal glow. Rounded, warm, big touch targets, kid-legible. */
@font-face { font-family: Fraunces; src: url(art/fraunces-extrabold.woff2) format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: Fraunces; src: url(art/fraunces-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --sky: #13263a;
  --dusk: #0a121e;
  --card: #1c3350;
  --card2: #24405f;
  --cream: #fff1d6;
  --muted: rgba(255, 241, 214, .72);
  --lantern: #ffc46b;
  --lantern-deep: #f0a640;
  --glow: #9ff0e0;
  --line: rgba(255, 241, 214, .16);
  --chip: #2c4a6c;
  --chip-native: #2f5a4a;
  --live: #6fe39a;
  --off: #9aa4b2;
  --meadow: #7fae5b;
  --meadow2: #5f8c45;
  --plaza: #d9bf86;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; color: var(--cream); font: 16px/1.45 var(--font);
  background: radial-gradient(ellipse 120% 60% at 50% 0%, #1f3d5c 0%, var(--sky) 45%, var(--dusk) 100%) fixed; min-height: 100%; }
body { max-width: 900px; margin: 0 auto; padding-bottom: max(24px, env(safe-area-inset-bottom)); overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { min-height: 44px; background: var(--chip); border: 0; border-radius: 16px; padding: 10px 16px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .28); transition: transform .08s; font-weight: 700; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: linear-gradient(180deg, var(--lantern), var(--lantern-deep)); color: #3a2410; }
button.small { min-height: 40px; min-width: 40px; padding: 6px 12px; border-radius: 14px; }
input, select { min-height: 44px; background: var(--dusk); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--lantern); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 800; letter-spacing: .2px; }

header#top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; padding: 12px 16px 8px; }
.brand h1 { margin: 0; font-size: 24px; white-space: nowrap; color: var(--cream); text-shadow: 0 2px 10px rgba(255, 196, 107, .35); }
.dayline { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 6px 12px; font-size: 12.5px;
  font-weight: 700; white-space: nowrap; background: rgba(10, 18, 30, .6); }
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.pill.on { color: var(--live); box-shadow: inset 0 0 0 2px rgba(111, 227, 154, .45); }
.pill.on .dot { background: var(--live); animation: pulse 2s infinite; }
.pill.off { color: var(--off); box-shadow: inset 0 0 0 2px rgba(154, 164, 178, .3); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(111, 227, 154, .6); } 70% { box-shadow: 0 0 0 8px rgba(111, 227, 154, 0); } 100% { box-shadow: 0 0 0 0 rgba(111, 227, 154, 0); } }

#mapwrap { position: relative; margin: 0 16px; border-radius: 22px; overflow: hidden; background: var(--meadow2);
  box-shadow: 0 0 0 3px rgba(255, 196, 107, .35), 0 8px 24px rgba(0, 0, 0, .45); }
#map { display: block; width: 100%; height: 46vh; min-height: 260px; max-height: 540px; touch-action: manipulation; }
#mapbtns { position: absolute; right: 10px; top: 10px; display: flex; gap: 8px; }
#mapbtns button { background: rgba(10, 18, 30, .72); color: var(--cream); }
.toast { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(10, 18, 30, .9); color: var(--cream);
  padding: 8px 14px; border-radius: 16px; font-size: 14px; font-weight: 700; max-width: 90%; text-align: center; box-shadow: 0 0 0 2px var(--lantern); }

.ctx { margin: 10px 16px 0; padding: 10px 12px; background: var(--card); border-radius: 20px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.ctx .what { flex: 1 1 100%; font-weight: 800; font-size: 17px; }
.statusbar { margin: 10px 16px 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; min-height: 22px; }
.statusbar b { color: var(--cream); }

nav#tabs { display: flex; gap: 6px; margin: 12px 16px 0; overflow-x: auto; scrollbar-width: none; }
nav#tabs button { flex: 1 1 0; min-width: 0; padding: 10px 4px; background: rgba(10, 18, 30, .45); color: var(--muted); box-shadow: none; border-radius: 16px 16px 0 0; }
nav#tabs button.on { background: var(--card); color: var(--lantern); }
.panel { margin: 0 16px 24px; padding: 12px; background: var(--card); border-radius: 0 0 22px 22px; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); }

.feed { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 10px; }
.entry { font-size: 15px; background: rgba(10, 18, 30, .35); border-radius: 16px; padding: 6px 10px; }
.entry .who { font-weight: 800; margin-right: 4px; }
.entry.sys { background: none; color: var(--muted); font-size: 14px; padding: 0 10px; }
.w { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; margin: 2px 2px; padding: 4px 10px;
  border-radius: 14px; background: var(--chip); cursor: pointer; line-height: 1.15; vertical-align: middle; font-weight: 700; }
.w .g { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.w.native { background: var(--chip-native); }
.w.native .g { color: var(--glow); }
.w.guess .g { font-style: italic; color: var(--lantern); }

.composer { padding-top: 10px; margin-top: 4px; border-top: 2px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
.sentence { min-height: 52px; padding: 6px; background: rgba(10, 18, 30, .45); border-radius: 18px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.sentence .hint { color: var(--muted); font-size: 14px; padding: 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row label { font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.row label.q { min-height: 44px; }
.row label.q input { width: 22px; height: 22px; min-height: 0; }
.row input[type=search] { flex: 1 1 200px; }
.row #say { margin-left: auto; min-width: 96px; }
.chip { border-radius: 999px; font-size: 14px; }
.chip.ghost { background: rgba(159, 240, 224, .14); color: var(--glow); box-shadow: none; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cats button { min-height: 40px; padding: 6px 14px; border-radius: 999px; white-space: nowrap; box-shadow: none; background: rgba(10, 18, 30, .45); }
.cats button.on { background: var(--glow); color: #0d2b2a; }
.words { display: flex; flex-wrap: wrap; gap: 4px; max-height: 32vh; overflow-y: auto; }
.coin { background: rgba(10, 18, 30, .35); border-radius: 16px; padding: 10px 12px; }
.coin summary { cursor: pointer; font-weight: 800; color: var(--lantern); min-height: 28px; }
.coin p { font-size: 14px; margin: 6px 0; }

.grid3 { display: grid; grid-template-columns: repeat(3, 76px); gap: 8px; margin: 10px 0; }
.cell { width: 76px; height: 76px; border-radius: 18px; background: rgba(10, 18, 30, .5); display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: 12px; font-weight: 700; padding: 4px; cursor: pointer; }
.cell.on { background: var(--glow); box-shadow: 0 0 14px rgba(159, 240, 224, .6); }
.cell.fill { background: var(--card2); flex-direction: column; gap: 3px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .3); display: inline-block; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
.pcard { border-radius: 20px; padding: 12px; background: var(--card2); box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.pcard h3 { margin: 0 0 2px; font-size: 20px; }
.pcard .sub { font-size: 13px; color: var(--muted); }
.pcard button { margin-top: 10px; width: 100%; }
.events { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.events li { font-size: 14.5px; background: rgba(10, 18, 30, .35); border-radius: 16px; padding: 8px 12px; border-left: 6px solid var(--line); }
.events li.k-sound { border-color: #e0a04a; }
.events li.k-loan { border-color: #6fb8ff; }
.events li.k-coin { border-color: var(--live); }
.events li.k-grant { border-color: var(--glow); }
.events li .when { font-size: 12px; color: var(--muted); display: block; }
.events li button { margin-left: 6px; }
.dict { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; font-size: 14px; margin-top: 8px; }
.dict > div { background: rgba(10, 18, 30, .35); border-radius: 16px; padding: 8px; }
.dict table { width: 100%; border-collapse: collapse; }
.dict td { padding: 2px 4px; border-bottom: 1px solid var(--line); }
.dict td.old { color: var(--muted); text-decoration: line-through; font-size: 12px; }
details > summary { cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.stat { display: block; background: rgba(10, 18, 30, .4); border-radius: 16px; padding: 8px 12px; min-width: 92px; font-size: 13px; color: var(--muted); }
.stat b { font-size: 22px; display: block; color: var(--lantern); font-family: Fraunces, Georgia, serif; }
h2 { font-size: 20px; margin: 14px 0 8px; color: var(--lantern); }
h2:first-child { margin-top: 2px; }

.modal { position: fixed; inset: 0; background: rgba(10, 18, 30, .7); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.card { background: var(--card); border-radius: 26px; padding: 20px; max-width: 520px; width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 0 0 3px rgba(255, 196, 107, .35), 0 12px 40px rgba(0, 0, 0, .5); }
.card.hero { background: linear-gradient(180deg, rgba(10, 18, 30, .2) 0%, rgba(10, 18, 30, .55) 40%, rgba(10, 18, 30, .92) 75%),
  url(art/splash-art-tall.jpg) center 70%/cover no-repeat; min-height: min(640px, 88vh); display: flex; flex-direction: column; justify-content: flex-end; }
.card.hero h2 { font-size: 40px; color: var(--cream); margin: 0 0 6px; text-shadow: 0 2px 14px rgba(8, 16, 30, .9); }
.card.hero p { text-shadow: 0 1px 6px rgba(8, 16, 30, .95); }
.card h2 { margin-top: 0; }
.card .row { margin-top: 10px; }
.card input { flex: 1; }
.tagline { font-family: Fraunces, Georgia, serif; font-style: italic; color: var(--lantern); font-size: 18px; margin: 0 0 8px; }

@media (min-width: 760px) {
  #map { height: 52vh; }
}
