/* ═══ Słówka — Editorial Forest ═══ */
:root {
  --cream: #F2EDE4;
  --cream-2: #EAE3D6;
  --ink: #2F3336;
  --forest: #3E5C50;
  --sage: #8FA98F;
  --terracotta: #C97A56;
  --rust: #A4714A;
  --sand: #E5D9C5;
  --white: #FFFFFF;
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --hair: 2px solid var(--ink);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--serif);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── screens ── */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 18px calc(env(safe-area-inset-bottom, 0px) + 14px);
  max-width: 520px; margin: 0 auto;
  overflow-y: auto;
}
.screen.active { display: flex; }
.screen.dark { background: var(--ink); max-width: none; }

/* ── shared chrome ── */
.bar { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.bar h2 { font-size: 20px; font-weight: 600; flex: 1; text-align: center; }
.bar-spacer { width: 40px; }
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  border: var(--hair); border-radius: 50%;
  background: var(--white); color: var(--ink);
  font-size: 17px; font-family: var(--mono);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { transform: scale(0.93); }
.icon-btn.off { opacity: 0.35; }
.coins-badge {
  display: inline-flex; align-items: center; gap: 7px;
  border: var(--hair); border-radius: 999px;
  background: var(--white); padding: 7px 14px 7px 9px;
  font-family: var(--mono); font-weight: 700; font-size: 15px;
}
.coins-badge.small { padding: 4px 10px 4px 6px; font-size: 13px; }
.coin-ico {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--terracotta); border: 2px solid var(--ink);
  display: inline-block; position: relative;
}
.coins-badge.small .coin-ico { width: 16px; height: 16px; }
.coin-ico::after {
  content: ''; position: absolute; inset: 4px;
  border-radius: 50%; border: 2px solid rgba(47,51,54,0.45);
}
.btn {
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  letter-spacing: 0.02em;
  border: var(--hair); border-radius: 999px;
  background: var(--white); color: var(--ink);
  padding: 14px 22px; cursor: pointer;
}
.btn.primary { background: var(--forest); color: var(--cream); border-color: var(--forest); }
.btn:active { transform: scale(0.97); }

/* ── home ── */
.home-top { display: flex; justify-content: space-between; align-items: center; }
.top-actions { display: flex; gap: 8px; }
.home-hero { text-align: center; padding: 4vh 0 3vh; }
.monogram {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border: var(--hair); border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 600; font-size: 26px;
  background: var(--white);
}
.monogram.small { width: 44px; height: 44px; font-size: 21px; margin-bottom: 10px; }
.logo { font-size: 44px; font-weight: 600; letter-spacing: -0.01em; }
.tagline {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em;
  margin-top: 8px; color: var(--rust);
}
.cat-grid { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.cat-card {
  display: flex; align-items: center; gap: 14px;
  border: var(--hair); border-radius: 18px;
  background: var(--white); padding: 14px 16px;
  cursor: pointer; text-align: left; font-family: inherit; color: inherit;
}
.cat-card:active { transform: scale(0.98); }
.cat-icon { width: 44px; height: 44px; flex: 0 0 auto; }
.cat-icon svg { width: 100%; height: 100%; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-size: 19px; font-weight: 600; }
.cat-meta { font-family: var(--mono); font-size: 11px; color: var(--rust); margin-top: 3px; letter-spacing: 0.06em; }
.cat-arrow { font-family: var(--mono); font-size: 16px; color: var(--forest); }
.home-foot {
  margin-top: auto; text-align: center; padding-top: 16px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--rust); text-transform: uppercase;
}

/* ── level select ── */
.level-list { display: flex; flex-direction: column; gap: 14px; padding-top: 3vh; }
.level-card {
  border: var(--hair); border-radius: 18px; background: var(--white);
  padding: 18px; cursor: pointer; font-family: inherit; color: inherit; text-align: left;
}
.level-card:active { transform: scale(0.98); }
.level-row { display: flex; align-items: baseline; justify-content: space-between; }
.level-name { font-size: 24px; font-weight: 600; }
.level-desc { font-family: var(--mono); font-size: 11px; color: var(--rust); letter-spacing: 0.06em; }
.level-progress {
  margin-top: 12px; height: 8px; border-radius: 99px;
  background: var(--sand); overflow: hidden; border: 1.5px solid var(--ink);
}
.level-progress > i { display: block; height: 100%; background: var(--forest); border-radius: 99px; }
.level-count { font-family: var(--mono); font-size: 11px; margin-top: 8px; color: var(--ink); opacity: 0.7; }

/* ── game ── */
.progress-track { flex: 1; display: flex; gap: 5px; align-items: center; padding: 0 4px; }
.progress-track i {
  flex: 1; height: 6px; border-radius: 99px; background: var(--sand);
  border: 1.5px solid rgba(47,51,54,0.35);
}
.progress-track i.done { background: var(--forest); border-color: var(--forest); }
.progress-track i.now { background: var(--terracotta); border-color: var(--ink); }
.game-area { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3vh; padding-top: 1vh; }
.word-card {
  position: relative;
  width: min(62vw, 46vh, 300px); aspect-ratio: 1;
  border: var(--hair); border-radius: 24px;
  background: var(--white);
  display: grid; place-items: center;
}
.word-svg { width: 82%; height: 82%; }
.word-svg svg { width: 100%; height: 100%; }
.word-level {
  position: absolute; top: 10px; right: 12px;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em; color: var(--rust);
}
.blanks { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; min-height: 46px; }
.blank {
  width: 38px; height: 46px;
  border-bottom: 3px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 26px; font-weight: 700;
  color: var(--forest);
  border-radius: 6px 6px 0 0;
  transition: background 0.15s;
}
.blank.target { background: var(--sand); }
.blank.filled { border-bottom-color: var(--forest); }
.blank.hinted { color: var(--terracotta); }
.blank.shake { animation: shake 0.4s; background: rgba(201,122,86,0.25); }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
.letter-pool {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  max-width: 360px; padding-bottom: 8px;
}
.tile {
  width: 48px; height: 52px;
  border: var(--hair); border-radius: 12px;
  background: var(--white);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 24px; font-weight: 700;
  cursor: grab; touch-action: none;
  box-shadow: 0 2px 0 var(--ink);
}
.tile.used { visibility: hidden; }
.tile.dragging { opacity: 0.25; }
.tile-ghost {
  position: fixed; z-index: 50; pointer-events: none;
  width: 52px; height: 56px;
  border: var(--hair); border-radius: 12px;
  background: var(--terracotta); color: var(--cream);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 26px; font-weight: 700;
  transform: translate(-50%, -60%) scale(1.1);
}
.game-foot { display: flex; justify-content: center; padding-top: 8px; }
.hint-btn {
  font-family: var(--mono); font-size: 13px;
  border: var(--hair); border-radius: 999px;
  background: var(--white); padding: 10px 18px; cursor: pointer; color: var(--ink);
}
.hint-btn:disabled { opacity: 0.35; }
.hint-cost { color: var(--rust); font-weight: 700; }

/* word-complete flash */
.word-done {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(242,237,228,0.92);
  animation: fadein 0.2s;
}
.word-done[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } }
.word-done-inner { text-align: center; }
.word-done-word { font-size: 42px; font-weight: 600; letter-spacing: 0.04em; }
.word-done-pl { font-family: var(--mono); font-size: 14px; color: var(--rust); margin-top: 6px; }
.word-done-pts { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--forest); margin-top: 14px; }

/* ── ad ── */
.ad-wrap { position: relative; flex: 1; display: grid; place-items: center; }
#ad-video { max-height: 100%; max-width: 100%; height: 100%; object-fit: contain; }
.ad-tag {
  position: absolute; top: 14px; left: 14px; z-index: 2;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  color: var(--cream); background: rgba(47,51,54,0.7);
  border: 1px solid var(--cream); border-radius: 4px; padding: 4px 8px;
}
.ad-mute {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--cream); background: rgba(47,51,54,0.7);
  font-size: 16px; cursor: pointer;
}
.ad-skip {
  position: absolute; bottom: 90px; right: 14px; z-index: 2;
  font-family: var(--mono); font-size: 13px;
  border: 1px solid var(--cream); border-radius: 999px;
  background: rgba(47,51,54,0.75); color: var(--cream);
  padding: 10px 18px; cursor: pointer;
}
.ad-skip:disabled { opacity: 0.6; }
.ad-cta {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); left: 50%; transform: translateX(-50%);
  z-index: 2; white-space: nowrap;
  font-family: var(--mono); font-size: 14px; font-weight: 700; text-decoration: none;
  background: var(--terracotta); color: var(--cream);
  border: 2px solid var(--cream); border-radius: 999px;
  padding: 14px 26px;
}

/* ── results ── */
.results { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; }
.results h2 { font-size: 34px; font-weight: 600; }
.res-stats { display: flex; gap: 14px; }
.res-stat {
  border: var(--hair); border-radius: 18px; background: var(--white);
  padding: 16px 18px; min-width: 92px;
  display: flex; flex-direction: column; gap: 6px;
}
.res-num { font-family: var(--mono); font-size: 24px; font-weight: 700; }
.res-num.gold { color: var(--terracotta); }
.res-lab { font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em; color: var(--rust); }
.res-actions { display: flex; flex-direction: column; gap: 10px; width: min(280px, 80vw); }
.res-actions .btn { width: 100%; }

@media (min-width: 700px) {
  .logo { font-size: 52px; }
}
