/* Polski — "Warm paper, one indigo". Tokens and screens per DESIGN.md v2. */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1c1b1a;
  --text-2: #6e6a63;
  --line: #e5e1d8;
  --accent: #5b5bd6;
  --accent-soft: #ededfb;
  --ok: #2e7d4f;
  --bad: #c4453c;
  --shadow: 0 2px 8px rgba(28, 27, 26, 0.06), 0 8px 24px rgba(28, 27, 26, 0.05);
  --card-border: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131215;
    --surface: #1e1d21;
    --text: #f2f0ed;
    --text-2: #a29e97;
    --line: #2e2c31;
    --accent: #8b8bf0;
    --accent-soft: #2a2a45;
    --ok: #58c088;
    --bad: #e5736b;
    --shadow: none;
  }
}

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

html { font: -apple-system-body; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#shell {
  position: fixed;
  inset: 0;
  margin-inline: auto;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 20px)
    calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 20px);
}

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; animation: push-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.screen.takeover { animation: rise-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes push-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen, .screen.takeover { animation: fade-in 160ms; }
  .card, .reveal-line, .end-card { animation: fade-in 160ms !important; }
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
}

/* ---- type roles ---- */
.caption { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); }
.sub { font-size: 1.125rem; color: var(--text-2); line-height: 1.35; }
.title-lg { font-size: clamp(1.75rem, 8vw, 2.5rem); font-weight: 700; line-height: 1.15; }

/* ---- header ---- */
.hdr { display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 8px; }
.hdr .mid { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; font-size: 0.9375rem; }
.icon-btn {
  min-width: 44px; min-height: 44px; display: grid; place-items: center;
  background: none; border: none; color: var(--text); font: inherit; font-size: 1.25rem; cursor: pointer; border-radius: 12px;
}
.icon-btn:active { transform: scale(0.94); }
.back-btn { min-height: 44px; display: inline-flex; align-items: center; gap: 2px; background: none; border: none; color: var(--accent); font: inherit; font-size: 1.0625rem; font-weight: 600; cursor: pointer; padding-right: 12px; }

/* ---- segmented control + chips ---- */
.seg { display: inline-flex; background: var(--accent-soft); border-radius: 999px; padding: 2px; }
.seg button {
  border: none; background: none; font: inherit; font-size: 0.8125rem; font-weight: 600;
  color: var(--text-2); padding: 5px 12px; border-radius: 999px; cursor: pointer; min-height: 30px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.chip-row { display: flex; gap: 8px; justify-content: center; min-height: 32px; margin: 4px 0 8px; }
.chip {
  border: 1px solid var(--line); background: none; color: var(--text-2); font: inherit; font-size: 0.8125rem;
  font-weight: 600; padding: 4px 14px; border-radius: 999px; cursor: pointer; min-height: 30px;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---- cards ---- */
.slots { display: flex; flex-direction: column; gap: 12px; justify-content: center; flex: 1; min-height: 0; }
.card {
  position: relative; background: var(--surface); border: var(--card-border); border-radius: 20px;
  box-shadow: var(--shadow); padding: 24px; min-height: 96px;
  display: grid; place-items: center; text-align: center;
  animation: deal 280ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.card:nth-child(2) { animation-delay: 60ms; }
.card:nth-child(3) { animation-delay: 120ms; }
@keyframes deal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.card.swap { animation: swap-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes swap-in { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
.card .word { font-size: clamp(1.75rem, 8vw, 2.5rem); font-weight: 700; line-height: 1.15; overflow-wrap: break-word; max-width: 100%; }
.card .word.small { font-size: clamp(1.125rem, 4.5vw, 1.375rem); font-weight: 600; line-height: 1.45; }
.card.ghost { border-color: color-mix(in srgb, var(--line) 40%, transparent); background: none; box-shadow: none; }
.card.ghost .word { color: var(--line); }
.qty-chip {
  position: absolute; top: 12px; left: 12px; background: var(--accent-soft); color: var(--accent);
  font-size: 0.8125rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.num-display { font-size: clamp(1.5rem, 6.5vw, 2rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

/* ---- reveal box ---- */
.reveal { min-height: 180px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; justify-content: center; text-align: center; padding: 8px 4px; }
.reveal .placeholder { color: var(--text-2); font-size: 1.0625rem; }
.reveal .q-line { font-size: 1.125rem; color: var(--text-2); line-height: 1.35; user-select: text; -webkit-user-select: text; animation: reveal-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal .a-line { font-size: clamp(1.25rem, 5.5vw, 1.625rem); font-weight: 500; line-height: 1.35; user-select: text; -webkit-user-select: text; animation: reveal-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal .a-line .hl { color: var(--accent); font-weight: 600; }
.reveal .hint { font-size: 0.875rem; color: var(--text-2); line-height: 1.4; animation: reveal-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.reveal .entry { font-size: clamp(1.25rem, 5.5vw, 1.625rem); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.reveal .verdict-ok { color: var(--ok); font-weight: 600; }
.reveal .verdict-bad { color: var(--bad); font-weight: 600; }
@keyframes reveal-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- buttons ---- */
.btn-zone { display: flex; gap: 12px; padding-top: 12px; }
.pill {
  flex: 1; min-height: 56px; border-radius: 16px; border: none; font: inherit; font-size: 1.0625rem; font-weight: 600;
  cursor: pointer; background: var(--accent); color: #fff; transition: transform 120ms;
}
@media (prefers-color-scheme: dark) { .pill { color: #131215; } }
.pill:active { transform: scale(0.97); }
.pill.ghost-btn { background: none; border: 1px solid var(--line); color: var(--text); }
.pill:disabled { opacity: 0.45; }

/* ---- keypad (E3 write mode) ---- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 12px; flex: 1; }
.keypad button {
  min-height: 52px; border-radius: 14px; border: var(--card-border); background: var(--surface); box-shadow: var(--shadow);
  font: inherit; font-size: 1.375rem; font-weight: 600; color: var(--text); cursor: pointer;
}
.keypad button:active { transform: scale(0.95); }

/* ---- home ---- */
.home-list { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding: 12px 0; }
.hero {
  background: var(--surface); border: var(--card-border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 24px; text-align: left; cursor: pointer; font: inherit; color: var(--text); width: 100%;
}
.hero:active { transform: scale(0.98); }
.hero h2 { font-size: 1.375rem; font-weight: 700; margin: 6px 0 4px; }
.row-btn {
  display: flex; align-items: center; gap: 14px; min-height: 64px; width: 100%;
  background: var(--surface); border: var(--card-border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 12px 18px; font: inherit; color: var(--text); cursor: pointer; text-align: left;
}
.row-btn:active { transform: scale(0.98); }
.row-btn .glyph { font-size: 1.375rem; }
.row-btn .grow { flex: 1; }
.row-btn .t { font-size: 1.0625rem; font-weight: 600; }
.row-btn .chev { color: var(--text-2); }
.wordmark { font-size: 1.0625rem; font-weight: 700; letter-spacing: 0.02em; }
.wordmark i { font-style: normal; color: var(--accent); }

/* ---- end-of-round ---- */
.end-card {
  background: var(--surface); border: var(--card-border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 24px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center;
  animation: reveal-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.end-card .big { font-size: clamp(1.75rem, 8vw, 2.25rem); font-weight: 700; }
.end-card .trick { font-size: 1.125rem; font-weight: 500; user-select: text; -webkit-user-select: text; }

/* ---- settings & word list ---- */
.panel { background: var(--surface); border: var(--card-border); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.panel .prow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  min-height: 56px; padding: 10px 18px; border: none; background: none; font: inherit; color: var(--text);
  cursor: pointer; text-align: left; font-size: 1.0625rem;
}
.panel .prow + .prow { border-top: 1px solid var(--line); }
.panel .prow .d { font-size: 0.8125rem; color: var(--text-2); }
.panel .prow.accent-row { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.panel .prow.bad-row { color: var(--bad); cursor: default; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; padding: 12px 0 24px; display: flex; flex-direction: column; gap: 16px; }
.wl-group { display: flex; flex-direction: column; gap: 0; }
.wl-row { border: none; background: none; font: inherit; color: var(--text); text-align: left; padding: 10px 4px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 1.0625rem; }
.wl-row .g { color: var(--text-2); }
.wl-row .badge { color: var(--accent); font-weight: 700; margin-left: 6px; }
.wl-forms { font-size: 0.9375rem; color: var(--text-2); padding: 2px 4px 10px; border-bottom: 1px solid var(--line); user-select: text; -webkit-user-select: text; }
.foot { text-align: center; color: var(--text-2); font-size: 0.875rem; line-height: 1.6; padding-top: 16px; }

/* ---- update pill ---- */
#update-pill {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: var(--accent-soft); color: var(--accent); border: none; font: inherit; font-weight: 600; font-size: 0.9375rem;
  padding: 12px 20px; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow); z-index: 10;
  animation: reveal-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ---- empty state ---- */
.empty { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: center; flex: 1; }
