/* Twenty Questions: warm, plain, roomy enough for a family phone (390 px first) or a tablet on the kitchen table. */

:root {
  --bg: #faf3e7;
  --ink: #33302a;
  --muted: #7d7466;
  --card: #fffdf8;
  --line: #e8dcc6;
  --accent: #2c6e63;
  --accent-soft: #e7f1ee;
  --accent-ink: #fffdf8;
  --bad: #b3442f;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }      /* the attribute must beat any author display rule (the ask form is a flex form) */
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
main { max-width: 560px; margin: 0 auto; padding: 8px 12px 56px; }

.top { max-width: 560px; margin: 0 auto; padding: 10px 12px 0; display: flex; justify-content: flex-end; }
.langswitch { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.langswitch select { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); padding: 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(90, 70, 40, .06);
}

h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin-bottom: 0; }
.note { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.note.warn { color: var(--bad); }
.note a { color: var(--accent); }

button, input, select { font: inherit; }
button, a.btn { border-radius: 12px; min-height: 48px; padding: 0 18px; border: 1px solid transparent; cursor: pointer; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
input[type="text"] { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: #fff; color: var(--ink); }
.select { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); padding: 0 10px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* the lobby */
.players { display: grid; gap: 8px; }
.player-row { display: flex; gap: 8px; }
.player-row input { flex: 1; }
.player-row .x { width: 48px; flex: 0 0 48px; padding: 0; background: transparent; border-color: var(--line); color: var(--muted); font-size: 22px; }
#addPlayer { margin-top: 8px; }
#category { margin-bottom: 4px; }
#startGame { width: 100%; margin-top: 16px; }

/* the board */
.statusline { display: flex; align-items: center; gap: 10px; }
#counterBar { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
#counterFill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--accent); transition: width .3s; }
#counterText { font-size: 14px; color: var(--muted); white-space: nowrap; }

.players-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.player-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.player-chip.current { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.player-chip.satout { opacity: .55; }
.player-chip .wrong { color: var(--bad); font-size: 13px; }
.player-chip .satout-note { font-size: 13px; color: var(--muted); font-style: italic; }

.turn { min-height: 1.5em; margin: 6px 0; color: var(--accent); font-weight: 600; }

.qa, .guesses { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; }
/* a grid, not wrapped flex: the answer chip must keep its place at the right edge even when the question wraps
   (centered, so it reads as the row's status and not as a word of the sentence) */
.qa-line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 8px; padding: 8px 10px; background: #f6efe0; border-radius: 10px; }
.guess-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 8px; padding: 8px 10px; background: #f6efe0; border-radius: 10px; }
.qa-n { color: var(--muted); font-size: 13px; min-width: 38px; }
.qa-text { overflow-wrap: anywhere; }
.answer { border-radius: 999px; padding: 2px 12px; font-size: 14px; white-space: nowrap; }
.answer-yes { background: #ddefe5; color: #1d5c46; }
.answer-no { background: #f7e0d4; color: #8c3c1d; }
.answer-sometimes { background: #f3ecd2; color: #7a5c14; }
.answer-unclear { background: #e8e4da; color: #6b6558; }
.qa-line .flag { width: auto; height: 32px; min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; align-self: center; }

.thinking { color: var(--accent); font-style: italic; margin: 10px 0 0; }
#askForm, .guessrow { display: flex; gap: 8px; margin: 0; }
#askForm input, .guessrow input { flex: 1; }
#askForm .primary, .guessrow .ghost { margin: 0; white-space: nowrap; }
#guessWrap { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }

/* the end of a game */
.end h2 { font-size: 22px; margin: 0; }
.secret-was { color: var(--muted); margin: 14px 0 0; }
.reveal-name { font-size: 30px; font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.reveal-desc { margin: 4px 0 10px; }
#revealCardBox summary { cursor: pointer; color: var(--muted); font-size: 14px; }
#revealCard { margin: 8px 0 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; color: var(--ink); }
.row { display: flex; gap: 10px; margin-top: 16px; }
.restart { margin-top: 14px; }
.restart-ask p { margin: 0 0 4px; font-weight: 600; }
.row .primary, .row .ghost { flex: 1; }

/* the wallet panel: a full card in the lobby, a strip in the game */
.wallet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.wallet-head h2 { margin: 0; font-size: 18px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--muted); }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.chip.on { color: var(--ink); }
.chip.on .dot { background: #2f9e63; }
.chip.bad .dot { background: var(--bad); }
.walletpanel .primary, .walletpanel .ghost { margin-top: 12px; }
.walletpanel:not(.compact) .primary, .walletpanel:not(.compact) .ghost { width: 100%; }
.walletpanel.compact { padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.walletpanel.compact .wallet-head { flex: 1 1 auto; }
.walletpanel.compact button { min-height: 40px; margin-top: 0; }
.walletpanel.compact .note { margin: 0; flex-basis: 100%; }

/* the toast */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  max-width: 92vw; background: #33302a; color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-size: 15px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); z-index: 10;
}

@media (min-width: 700px) {
  main, .top { max-width: 640px; }
  h1 { font-size: 32px; }
}
#invite { margin-top: 12px; }

/* «Agent wallet» in the header: connected / not connected, one click to disconnect (the same on every BYOA site) */
.top { align-items: center; gap: 8px; }
.walletchip { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 5px 0 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 14px; white-space: nowrap; }
.walletchip[hidden] { display: none; }
.wc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.walletchip[data-state="on"] .wc-dot { background: #2f9e63; box-shadow: 0 0 0 3px rgba(47, 158, 99, .18); }
.walletchip[data-state="wait"] .wc-dot { background: #d9a13b; }
.walletchip[data-state="bad"] .wc-dot { background: var(--bad); }
.wc-name { font-weight: 700; }
.wc-state { color: var(--muted); }
.walletchip[data-state="on"] .wc-state { color: #2f7d52; }
.walletchip[data-state="bad"] .wc-state { color: var(--bad); }
.wc-btn { min-height: 30px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; }
.wc-btn:hover { background: var(--accent-soft); }
@media (max-width: 520px) { .wc-name { display: none; } .walletchip { padding-left: 9px; } }
