/* All A Board — palette lifted from the logo: tomato red on warm cream. */
:root {
  --red: #F44337;
  --red-deep: #D62F24;
  --bg: #FBF7F2;
  --surface: #FFFFFF;
  --ink: #241C1A;
  --muted: #837570;
  --line: #E9DED3;
  --tint: #FDECEA;
  --bubble: #F3EDE5;
  --radius: 18px;
  --w: 720px;
  --shadow: 0 1px 2px rgba(70,40,34,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --red: #FF6A5C;
    --red-deep: #F44337;
    --bg: #1A1614;
    --surface: #241E1B;
    --ink: #F5EDE8;
    --muted: #A99A93;
    --line: #382E2A;
    --tint: #33211E;
    --bubble: #2C2421;
    --shadow: 0 1px 2px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Shared width constraint — without it everything stretches on desktop. */
.bar-inner, .inner {
  width: 100%;
  max-width: var(--w);
  margin: 0 auto;
}

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.bar-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo { height: 26px; width: auto; flex: none; display: block; }

.brand-text { min-width: 0; line-height: 1.25; }

.topbar h1 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar p {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  flex: none;
  margin-left: -6px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.back:hover { background: var(--tint); color: var(--red); }
.back[hidden] { display: none; }

/* ---------- Game picker ---------- */
.menu {
  flex: 1;
  overflow-y: auto;
  padding: 36px 18px calc(28px + env(safe-area-inset-bottom));
}

.menu h2 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.02em;
  max-width: 16ch;
}

.menu-hint {
  margin: 0 0 22px;
  max-width: 42ch;
  color: var(--muted);
  font-size: 14.5px;
}

.cards { display: grid; gap: 12px; }

.card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}

.card:hover { border-color: var(--red); }
.card:active { transform: scale(.99); }

.card-icon {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  flex: none;
  border-radius: 14px;
  background: var(--tint);
  color: var(--red);
}

.card-text { flex: 1; min-width: 0; display: block; }

.card-name {
  display: block;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card-sub {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.card-go { flex: none; display: grid; place-items: center; color: var(--muted); }
.card:hover .card-go { color: var(--red); }

/* ---------- Chat ---------- */
.log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.turn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  max-width: var(--w);
  margin: 0 auto;
}

.turn.user { justify-content: flex-end; }

.avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
}

.msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.msg p { margin: 0; }
.msg p + p { margin-top: 10px; }

.msg.bot {
  background: var(--bubble);
  border-top-left-radius: 6px;
}

.msg.user {
  background: var(--red);
  color: #fff;
  border-top-right-radius: 6px;
}

.msg.error {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 14px;
}

.typing { display: flex; gap: 4px; padding: 14px 15px; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; opacity: .5; }
  .card { transition: none; }
}

/* Suggestion chips — aligned with the assistant bubble, not the avatar. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  max-width: var(--w);
  margin: -4px auto 0;
  padding-left: 40px;
}

.chips button {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
}

.chips button:hover { border-color: var(--red); color: var(--red); }
.chips button:active { transform: scale(.97); }

/* ---------- Composer ---------- */
.composer {
  position: sticky;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.composer[hidden] { display: none; }
.composer .bar-inner { gap: 8px; }

.composer input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* keeps iOS Safari from zooming on focus */
}

.composer input::placeholder { color: var(--muted); }
.composer input:focus { outline: 2px solid var(--red); outline-offset: 1px; }

.composer button {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  cursor: pointer;
}

.composer button:hover { background: var(--red-deep); }
.composer button:disabled { opacity: .4; cursor: default; }

/* ---------- Instant FAQ (answered from the bundle, no API call) ---------- */
.faq {
  width: 100%;
  max-width: var(--w);
  margin: -4px auto 0;
  padding-left: 40px;
}

.faq-head {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}

.faq-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.faq-item {
  padding: 12px 15px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}

.faq-item:first-child { border-top: 0; }
.faq-item:hover { background: var(--tint); color: var(--red); }
.faq-item[hidden] { display: none; }

.faq-more {
  margin-top: 8px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.faq-more:hover { border-color: var(--red); color: var(--red); }

/* Category grid inside the FAQ panel */
.topics {
  display: grid;
  gap: 8px;
}

.topic {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.topic:hover { border-color: var(--red); color: var(--red); }
.topic:active { transform: scale(.99); }

.topic-name { font-size: 14.5px; font-weight: 600; }

.topic-count {
  flex: none;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

@media (min-width: 520px) {
  .topics { grid-template-columns: 1fr 1fr; }
}
