/* NaturalRoo — stylesheet (dark theme, adapted from the DittoRoo/Webroo design language) */

:root {
  --bg:        #101418;
  --surface:   #1a2027;
  --surface2:  #242c35;
  --border:    #333d48;
  --text:      #e8ecf0;
  --text-dim:  #8b98a5;
  --accent:    #4f9cf9;   /* NaturalRoo blue */
  --accent-2:  #7db8ff;
  --danger:    #d64541;
  --success:   #2eae60;
  --warn:      #f0c674;
  --link:      #5aa9e6;
  --radius:    10px;
  --radius-sm: 5px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; min-height: 100vh; }

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .5rem 1.25rem; border-radius: var(--radius-sm); border: none;
  font-size: .9rem; font-weight: 600; cursor: pointer; transition: opacity .15s;
  color: var(--text); background: var(--surface2);
}
.btn:hover:not(:disabled) { opacity: .85; }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); color: #071523; }
.btn--ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn--danger  { background: var(--danger); color: #fff; }
.btn--sm      { padding: .35rem .75rem; font-size: .8rem; }
.btn--full    { width: 100%; }
.btn--big     { padding: .85rem 1.25rem; font-size: 1rem; }

/* ── Flash messages ──────────────────────────────────────────────────────── */

.flash-container { position: fixed; top: 1rem; right: 1rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .9rem; max-width: 320px; }
.flash--error   { background: var(--danger);  color: #fff; }
.flash--success { background: var(--success); color: #fff; }
.flash--info    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ── Landing / auth ──────────────────────────────────────────────────────── */

body.landing { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.landing__wrap { width: 100%; padding: 1rem; }
.landing__card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; margin: 0 auto;
}
.landing__logo { display: flex; align-items: center; gap: .5rem; justify-content: center; margin-bottom: .5rem; }
.landing__logo-mark { font-size: 2rem; }
.landing__logo-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.landing__tagline { text-align: center; color: var(--text-dim); font-size: .85rem; margin-bottom: 1.5rem; }
.landing__tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.landing__tab { flex: 1; text-align: center; padding: .6rem; font-size: .9rem; color: var(--text-dim); }
.landing__tab--active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -1px; }
.landing__divider { display: flex; align-items: center; text-align: center; color: var(--text-dim); font-size: .8rem; margin: 1.25rem 0; gap: .75rem; }
.landing__divider::before, .landing__divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ── Form fields ─────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-size: .85rem; color: var(--text-dim); }
.field__input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .75rem; color: var(--text);
  font-size: 1rem; width: 100%;
}
.field__input:focus { outline: none; border-color: var(--accent); }
.field__error { font-size: .8rem; color: var(--danger); }
.field--inline { flex-direction: row; align-items: center; gap: .5rem; }

/* ── Account page ────────────────────────────────────────────────────────── */

.account-page { max-width: 560px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.account-page__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.account-page__back { color: var(--text-dim); font-size: .9rem; }
.account-page__back:hover { color: var(--text); }
.account-page__logo { display: flex; align-items: center; gap: .4rem; font-weight: 700; }
.account-page__title { font-size: 1.5rem; margin-bottom: 1.5rem; }
.account-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.account-section__title { font-size: 1.05rem; margin-bottom: .35rem; }
.account-section__desc { font-size: .85rem; color: var(--text-dim); margin-bottom: 1rem; }
.account-section__empty { font-size: .9rem; color: var(--text-dim); margin-bottom: 1rem; }
.account-section__status { margin-top: .75rem; font-size: .85rem; }
.account-section__status--ok { color: var(--success); }
.account-section__status--error { color: var(--danger); }
.passkey-list { list-style: none; margin-bottom: 1rem; }
.passkey-item { display: flex; align-items: center; justify-content: space-between; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.passkey-item:last-child { border-bottom: none; }
.passkey-item__info { display: flex; flex-direction: column; }
.passkey-item__name { font-weight: 600; }
.passkey-item__meta { font-size: .75rem; color: var(--text-dim); }
.state-form { display: flex; gap: .5rem; }
.state-form__select { flex: 1; }

/* ── Shared page chrome ──────────────────────────────────────────────────── */

.page { max-width: 640px; margin: 0 auto; padding: 0 1rem 3rem; }
.page__title { font-size: 1.35rem; margin: 1.25rem 0 1rem; }

.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 0; position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.topbar__brand { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: 1.15rem; flex: 1; }
.topbar__brand--small { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__back { color: var(--text-dim); font-size: 1.3rem; line-height: 1; padding: .2rem .4rem; }
.topbar__back:hover { color: var(--text); }
.topbar__account {
  color: var(--text-dim); font-size: 1.25rem; line-height: 1; padding: .2rem;
  background: none; border: none; cursor: pointer;
}
.topbar__account:hover { color: var(--text); }

.hint {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .85rem; color: var(--text-dim);
  margin-top: .5rem;
}
.hint a { color: var(--link); text-decoration: underline; }

.badge {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  background: var(--surface2); color: var(--accent-2);
  border: 1px solid var(--border); border-radius: 999px; padding: .15rem .55rem;
  white-space: nowrap;
}

/* ── Home: deck list & import ────────────────────────────────────────────── */

.deck-list { display: flex; flex-direction: column; gap: .75rem; }
.deck-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; transition: border-color .15s;
}
.deck-card:hover { border-color: var(--accent); }
.deck-card__top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.deck-card__name { font-weight: 700; font-size: 1.05rem; }
.deck-card__desc { font-size: .82rem; color: var(--text-dim); margin-top: .3rem; }
.deck-card__meta { font-size: .78rem; color: var(--accent-2); margin-top: .45rem; }

.import { margin-top: 1.5rem; }
.import__summary { cursor: pointer; color: var(--text-dim); font-size: .95rem; padding: .5rem 0; }
.import__summary:hover { color: var(--text); }
.import__form { margin-top: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.import__text { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.import__help { font-size: .78rem; color: var(--text-dim); margin-bottom: 1rem; }
.import__help code { background: var(--surface2); padding: .05rem .3rem; border-radius: 3px; }

/* ── Deck page ───────────────────────────────────────────────────────────── */

.deck-desc { color: var(--text-dim); font-size: .88rem; margin-top: .5rem; }
.deck-count { color: var(--accent-2); font-size: .82rem; margin: .4rem 0 1rem; }
.action-row { display: flex; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.action-row .btn { flex: 1; min-width: 150px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.25rem; }
.panel__title { font-size: 1rem; margin-bottom: .8rem; }
.panel__empty { color: var(--text-dim); font-size: .88rem; }

.test-form__row { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; font-size: .9rem; }
.test-form__row label { color: var(--text-dim); }
.test-form__num { width: 5.5rem; text-align: center; }
.test-form__of { color: var(--text-dim); font-size: .82rem; }
.test-form__check { display: flex; align-items: center; gap: .45rem; color: var(--text-dim); cursor: pointer; }

.history { list-style: none; }
.history__item { display: flex; align-items: center; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.history li:last-child .history__item { border-bottom: none; }
.history__go { margin-left: auto; color: var(--link); font-size: .8rem; white-space: nowrap; }
.history__item:hover .history__go { text-decoration: underline; }
.history__score { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.5rem; }
.history__item--pass .history__score { color: var(--success); }
.history__item--fail .history__score { color: var(--danger); }
.history__meta { color: var(--text-dim); font-size: .8rem; }

.deck-delete { margin-top: .5rem; text-align: right; }

/* ── Browse ──────────────────────────────────────────────────────────────── */

.qa-list { list-style: none; counter-reset: qa; }
.qa {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem .9rem 3rem; margin-bottom: .6rem; position: relative; counter-increment: qa;
}
.qa::before {
  content: counter(qa); position: absolute; left: .95rem; top: .95rem;
  color: var(--text-dim); font-size: .8rem; font-variant-numeric: tabular-nums;
}
.qa__q { font-weight: 600; }
.qa__req { font-size: .74rem; color: var(--accent-2); text-transform: uppercase; letter-spacing: .04em; margin-top: .3rem; }
.qa__answers { list-style: none; margin-top: .5rem; }
.qa__answers li { font-size: .9rem; color: var(--text-dim); padding: .12rem 0 .12rem 1rem; position: relative; }
.qa__answers li::before { content: "•"; position: absolute; left: .2rem; color: var(--accent); }
.qa__note { font-size: .76rem; color: var(--warn); margin-top: .4rem; }

/* ── Flash cards ─────────────────────────────────────────────────────────── */

body.flashcards { overflow: hidden; }
.fc { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; padding: 0 1rem; }
.topbar--overlay { flex-shrink: 0; }

.fc__stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  perspective: 1200px; touch-action: none; min-height: 0; padding: .5rem 0 1rem;
}
.fc__card {
  position: relative; width: 100%; max-width: 480px; height: 100%; max-height: 440px;
  transform-style: preserve-3d; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.fc__face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem; text-align: center; overflow: hidden;
  transition: transform .35s cubic-bezier(.2,.7,.3,1);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.fc__face--front { transform: rotateY(0deg); }
.fc__face--back  { transform: rotateY(180deg); background: var(--surface2); }
.fc__card--flipped .fc__face--front { transform: rotateY(-180deg); }
.fc__card--flipped .fc__face--back  { transform: rotateY(0deg); }

.fc__hint { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-dim); margin-bottom: .8rem; }
.fc__hint--bottom { position: absolute; bottom: .9rem; left: 0; right: 0; margin: 0; }
.fc__text { font-size: 1.25rem; font-weight: 600; line-height: 1.45; }
.fc__req { font-size: .78rem; color: var(--accent-2); margin-top: .7rem; }
.fc__answers { list-style: none; overflow-y: auto; max-height: 100%; padding: 0 .5rem; }
.fc__answers li { font-size: 1.05rem; line-height: 1.5; padding: .15rem 0; }
.fc__answers--many li { font-size: .85rem; line-height: 1.35; }
.fc__note { font-size: .74rem; color: var(--warn); margin-top: .6rem; }

.fc__bar { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 0 max(1rem, env(safe-area-inset-bottom)); }
.fc__counter { color: var(--text-dim); font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ── Test mode ───────────────────────────────────────────────────────────── */

.page--test { display: flex; flex-direction: column; }
.test-progress { color: var(--text-dim); font-size: .9rem; font-variant-numeric: tabular-nums; }

.timerbar { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; margin-bottom: 1rem; }
.timerbar__fill { height: 100%; width: 100%; background: var(--accent); transition: width .1s linear; }
.timerbar__fill--low { background: var(--danger); }

.test-q { font-size: 1.2rem; font-weight: 600; line-height: 1.45; margin-top: .75rem; }
.test-req { font-size: .82rem; color: var(--accent-2); margin-top: .4rem; }

.test-answer { margin-top: 1.1rem; }
.test-answer__input { font-size: 1.05rem; margin-bottom: .75rem; resize: vertical; }

.test-result { margin-top: 1.1rem; }
.test-result__verdict { font-size: 1.15rem; font-weight: 700; margin-bottom: .7rem; }
.test-result__verdict--pass { color: var(--success); }
.test-result__verdict--fail { color: var(--danger); }
.test-result__verdict--warn { color: var(--warn); }

.test-result__echo {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .8rem .9rem; font-size: 1rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word;
  margin-bottom: .8rem;
}
.test-result__blank { color: var(--text-dim); font-style: italic; }
mark.mk-good { background: rgba(46,174,96,.28); color: #7ee2a8; border-radius: 3px; padding: 0 .15rem; }
mark.mk-bad  { background: rgba(214,69,65,.25); color: #ff9b98; border-radius: 3px; padding: 0 .15rem; text-decoration: line-through; }

.test-result__note { font-size: .78rem; color: var(--warn); margin-bottom: .8rem; }

.test-result__answers { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; margin-bottom: 1rem; }
.test-result__answers-title { font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.test-result__answers-title.toggle { cursor: pointer; color: var(--link); text-transform: none; letter-spacing: 0; font-size: .88rem; }
.test-result__answers-list { list-style: none; margin-top: .5rem; max-height: 40vh; overflow-y: auto; }
.test-result__answers-list li { font-size: .92rem; padding: .12rem 0 .12rem 1rem; position: relative; color: var(--text-dim); }
.test-result__answers-list li::before { content: "•"; position: absolute; left: .2rem; color: var(--accent); }
.test-result__answers-list li.hit { color: #7ee2a8; }
.test-result__answers-list li.hit::before { content: "✓"; color: var(--success); }

/* ── Summary ─────────────────────────────────────────────────────────────── */

.summary { text-align: center; padding-top: 2rem; }
.summary__score { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary__label { margin: .5rem 0 1.5rem; font-size: .95rem; }
.summary__label--pass { color: var(--success); }
.summary__label--fail { color: var(--danger); }
.summary__list { list-style: none; text-align: left; margin-bottom: 1.5rem; }
.summary__list li { padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.summary__list li:last-child { border-bottom: none; }
.summary__list li.ok { color: var(--text-dim); }
.summary__list li.no { color: #ff9b98; }
.summary__list summary { cursor: pointer; padding: .1rem 0; }
.summary__list details > *:not(summary) { margin-top: .6rem; }
.summary__list .test-result__echo { color: var(--text); font-size: .92rem; }
.summary--attempt { padding-top: 1.5rem; margin-bottom: 1.5rem; }

.review-answers summary { font-size: .82rem; color: var(--text-dim); cursor: pointer; }
.review-answers { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem; }

.drill-label { color: var(--warn); }
.test-form__select { width: auto; }

.photo-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.photo-row__status { font-size: .8rem; color: var(--text-dim); }
.label-hint { color: var(--text-dim); font-weight: 400; font-size: .78rem; }

.test-q-row { display: flex; align-items: flex-start; gap: .6rem; margin-top: .75rem; }
.test-q-row .test-q { margin-top: 0; flex: 1; }
.iconbtn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 1rem; padding: .3rem .55rem; cursor: pointer; flex-shrink: 0;
}
.iconbtn:hover { border-color: var(--accent); }
.test-answer__row { display: flex; gap: .6rem; }
.test-answer__row .btn--primary { flex: 1; }

.share-link { font-size: .82rem; font-family: ui-monospace, Consolas, monospace; }

/* ── Multiplayer games ───────────────────────────────────────────────────── */

.joinbar { display: flex; gap: .5rem; margin-top: .75rem; }
.joinbar__code { max-width: 10rem; text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }

.game-lobby { text-align: center; padding-top: 1.5rem; }
.game-lobby__label { color: var(--text-dim); font-size: .85rem; }
.game-lobby__code {
  font-size: 2.6rem; font-weight: 800; letter-spacing: .3em; margin: .5rem 0 1.25rem;
  color: var(--accent-2); font-family: ui-monospace, Consolas, monospace;
}

.buzzbtn {
  display: block; margin: 1.5rem auto; width: min(60vw, 220px); height: min(60vw, 220px);
  border-radius: 50%; border: 4px solid var(--accent); background: var(--surface);
  color: var(--text); font-size: 1.6rem; font-weight: 800; letter-spacing: .05em;
  cursor: pointer; transition: transform .08s, background .15s;
  box-shadow: 0 8px 30px rgba(79,156,249,.25);
}
.buzzbtn:active:not(:disabled) { transform: scale(.94); background: var(--accent); color: #071523; }
.buzzbtn:disabled { opacity: .45; border-color: var(--border); box-shadow: none; cursor: default; }

.game-scores { list-style: none; margin-top: 1.25rem; border-top: 1px solid var(--border); }
.game-scores--final { border-top: none; text-align: left; margin-bottom: 1.5rem; }
.gp { display: flex; align-items: center; justify-content: space-between; padding: .5rem .2rem; border-bottom: 1px solid var(--border); }
.gp__name { font-size: .95rem; }
.gp__meta { color: var(--text-dim); font-size: .78rem; margin-left: .35rem; }
.gp__score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent-2); }
.gp--winner .gp__name { color: var(--warn); font-weight: 700; }

.game-flash { padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .9rem; margin: .75rem 0; }
.game-flash--info { background: var(--surface2); color: var(--text-dim); }
.game-flash--good { background: rgba(46,174,96,.15); color: #7ee2a8; }
.game-flash--bad  { background: rgba(214,69,65,.15); color: #ff9b98; }

.game-typed-hint { font-size: .82rem; color: var(--text-dim); margin: .5rem 0 .4rem; }
.game-skip { margin-top: 1rem; }
.game-worth { text-align: center; color: var(--warn); font-size: .9rem; margin: .35rem 0 .5rem; }
.game-worth b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.race-answer { color: var(--text-dim); margin-top: .5rem; }
.page--game .test-answer__input { margin-top: .75rem; }
.page--game .timerbar { margin-top: .75rem; margin-bottom: 0; }

/* Hands-free auto-submit countdown (shrinks right-to-left over 4 s) */
.autosubmit { height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.autosubmit__fill { height: 100%; width: 100%; background: var(--warn); }
.btn--warn { background: var(--warn); color: #241c05; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  html { font-size: 15px; }
  .action-row { flex-direction: column; }
  .action-row .btn { min-width: 0; }
  .fc__text { font-size: 1.1rem; }
  .state-form { flex-direction: column; }
}
