@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-ExtraBold.ttf") format("truetype"); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --bg1: #FBF7F0;
  --bg2: #EEE6F7;
  --ink: #271F3D;
  --muted: #7D7594;
  --faint: #B3ABC6;
  --primary: #5136D6;
  --primary-dark: #3622A3;
  --primary-soft: #E9E3FF;
  --gold: #F7BC3F;
  --gold-dark: #C98A12;
  --flame: #FF7A2F;
  --success: #2EAE6A;
  --success-dark: #1E8550;
  --error: #E5534B;
  --error-soft: #FDE3E1;
  --card: #FFFFFF;
  --card-edge: #E4DCF2;
  --tile-empty: #F4F0FB;
  --key-edge: #D8CFEA;
  --key-accent: #F1ECFF;
  --radius: 22px;
  --tile: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%) fixed;
  background-color: var(--bg1);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 1.2em; height: 1.2em; flex-shrink: 0; }
[hidden] { display: none !important; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
}

/* ---------- Pasek górny ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  padding-top: max(12px, env(safe-area-inset-top));
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand img { border-radius: 11px; }
.brand span { font-weight: 800; font-size: 24px; letter-spacing: -0.3px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px 0 10px;
  background: var(--card); border-radius: 20px;
  border-bottom: 3px solid var(--card-edge);
  font-size: 18px;
}
.streak svg { color: var(--flame); width: 22px; height: 22px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 13px;
  background: var(--card); border-bottom: 3px solid var(--card-edge);
  display: grid; place-items: center; color: var(--primary);
}
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Treść ---------- */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.date { margin: 6px 4px 10px; font-weight: 800; color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 0.6px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border-bottom: 4px solid var(--card-edge);
  padding: 18px 20px 20px;
}
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  font-weight: 800; font-size: 13px;
  padding: 4px 12px; border-radius: 14px;
  background: var(--tile-empty); color: var(--muted);
}
.chip-primary { background: var(--primary-soft); color: var(--primary); }
.chip:empty { display: none; }
.stars { margin-left: auto; color: var(--gold); letter-spacing: 2px; font-size: 16px; }
.stars .off { color: var(--card-edge); }
.definition { font-weight: 800; font-size: 21px; line-height: 1.3; margin: 14px 0 0; }
.example { border-top: 2px solid var(--tile-empty); margin-top: 16px; padding-top: 12px; }
.example-label { margin: 0 0 4px; font-weight: 800; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.6px; }
.example-text { margin: 0; font-style: italic; color: var(--muted); font-size: 17px; line-height: 1.4; }
.example-text b { font-style: normal; color: var(--primary); }

/* ---------- Kafelki ---------- */
.tiles {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px; margin: 22px 0 18px;
}
.tiles .tile { border-bottom-width: max(3px, calc(var(--tile) * 0.1)); }
.tile {
  width: var(--tile); height: calc(var(--tile) * 1.18);
  border-radius: calc(var(--tile) * 0.22);
  border: 2px solid var(--tile-empty);
  border-bottom-width: 5px; border-bottom-color: var(--key-edge);
  background: var(--tile-empty);
  display: grid; place-items: center;
  font-weight: 800; font-size: calc(var(--tile) * 0.58);
  padding: 0; color: var(--ink);
  transition: transform 0.12s;
}
.tile.typed { background: var(--card); border-color: var(--card); border-bottom-color: var(--key-edge); }
.tile.cursor { background: var(--card); border-color: var(--primary); border-bottom-color: var(--primary); }
.tile.locked { background: var(--primary); border-color: var(--primary); border-bottom-color: var(--primary-dark); color: #fff; }
.tile.wrong { background: var(--error-soft); border-color: var(--error); border-bottom-color: var(--error); color: var(--error); }
.tile.correct { background: var(--success); border-color: var(--success); border-bottom-color: var(--success-dark); color: #fff; }
.tile.pop { animation: pop 0.2s ease; }
.tile.flip { animation: flip 0.4s ease both; }
.tiles.shake { animation: shake 0.45s ease; }
@keyframes pop { 50% { transform: scale(1.14); } }
@keyframes flip { 0% { transform: scaleY(1); } 45% { transform: scaleY(0); } 100% { transform: scaleY(1); } }
@keyframes shake { 15%, 55% { transform: translateX(-10px); } 35%, 75% { transform: translateX(10px); } 90% { transform: translateX(-3px); } }

/* ---------- Podpowiedzi ---------- */
.hints { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hint {
  border: 0; border-radius: 18px;
  background: var(--card); border-bottom: 4px solid var(--card-edge);
  padding: 10px 6px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.hint:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; margin-top: 2px; }
.hint-title { display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 800; font-size: 15px; white-space: nowrap; }
.hint-title svg { color: var(--primary); width: 22px; height: 22px; }
.hint-left { font-size: 13px; color: var(--muted); font-weight: 800; }
.hint:disabled { opacity: 0.45; cursor: default; }
.give-up {
  display: block; margin: 14px auto 6px; padding: 8px 18px;
  background: none; border: 0; color: var(--muted); font-weight: 800; font-size: 15px;
}

/* ---------- Wynik ---------- */
.result {
  background: var(--card); border-radius: var(--radius);
  border-bottom: 4px solid var(--card-edge);
  padding: 22px 20px; text-align: center;
}
.result-title { margin: 0; font-size: 28px; font-weight: 800; }
.result-word { margin: 6px 0 0; font-size: 34px; font-weight: 800; color: var(--primary); letter-spacing: 0.5px; word-break: break-word; }
.result-def { margin: 8px 0 0; font-size: 17px; font-weight: 800; }
.result-example { margin: 8px 0 0; font-style: italic; color: var(--muted); font-size: 16px; }
.result-example b { font-style: normal; color: var(--primary); }
.result-example:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 20px 0 18px; }
.stats b { display: block; font-size: 30px; font-weight: 800; }
.stats span { font-size: 13px; color: var(--muted); }
.countdown { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.countdown b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Przyciski ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 54px; border: 0; border-radius: 17px;
  font-weight: 800; font-size: 18px; text-decoration: none;
}
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--primary); border-bottom: 5px solid var(--primary-dark); color: #fff; }
.btn-gold { background: var(--gold); border-bottom: 5px solid var(--gold-dark); color: var(--ink); }
.btn-danger { background: var(--error); border-bottom: 5px solid #B23A33; color: #fff; }
.btn-ghost { background: var(--tile-empty); border-bottom: 4px solid var(--card-edge); color: var(--ink); margin-top: 10px; }

/* ---------- Promocja aplikacji ---------- */
.promo {
  display: grid; grid-template-columns: 56px 1fr; gap: 12px 14px; align-items: center;
  margin-top: 22px; padding: 16px;
  background: var(--primary-soft); border-radius: var(--radius);
}
.promo img { border-radius: 14px; }
.promo-text b { display: block; font-size: 17px; }
.promo-text span { font-size: 14px; color: var(--muted); line-height: 1.35; }
.promo .btn { grid-column: 1 / -1; height: 50px; font-size: 17px; }

.footer { display: flex; justify-content: center; gap: 8px; margin: 22px 0 6px; font-size: 13px; color: var(--faint); }
.footer a { color: var(--muted); }

/* ---------- Klawiatura ---------- */
.keyboard {
  flex-shrink: 0;
  padding: 8px 6px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
  background: linear-gradient(180deg, rgba(238, 230, 247, 0) 0%, var(--bg2) 18%);
  user-select: none; -webkit-user-select: none;
}
.kb-row { display: flex; justify-content: center; gap: 5px; }
.key {
  flex: 1 1 0; max-width: 50px; height: 50px; min-width: 0;
  border: 0; border-radius: 10px;
  background: var(--card); border-bottom: 4px solid var(--key-edge);
  font-weight: 800; font-size: 20px; padding: 0;
  touch-action: manipulation;
}
.key.accent { background: var(--key-accent); }
.key.wide { flex-grow: 1.7; max-width: 86px; color: var(--primary); background: var(--key-accent); display: grid; place-items: center; }
.key.wide svg { width: 26px; height: 26px; }
.key:active { transform: translateY(2px); border-bottom-width: 2px; }

/* ---------- Komunikaty i okna ---------- */
.toast {
  position: fixed; left: 50%; top: 76px; transform: translate(-50%, -20px);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 15px;
  padding: 11px 18px; border-radius: 14px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 30;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal-dim { position: absolute; inset: 0; background: rgba(26, 18, 51, 0.55); }
.modal-panel {
  position: relative; width: 100%; max-width: 440px;
  background: var(--card); border-radius: 26px; border-bottom: 5px solid var(--card-edge);
  padding: 24px 22px 22px; animation: rise 0.25s ease;
}
.modal-panel h2 { margin: 0 0 12px; font-size: 26px; text-align: center; }
.modal-note { color: var(--muted); text-align: center; margin: 4px 0 18px; line-height: 1.4; }
.steps { margin: 0 0 14px; padding-left: 22px; line-height: 1.45; }
.steps li { margin-bottom: 8px; }
@keyframes rise { from { transform: translateY(16px) scale(0.97); opacity: 0; } }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.noscript { text-align: center; padding: 40px 16px; }

@media (min-width: 600px) {
  .definition { font-size: 23px; }
  .main { padding-top: 10px; }
}
@media (max-height: 640px) {
  .key { height: 44px; }
  .tiles { margin: 14px 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tile.pop, .tile.flip, .tiles.shake, .modal-panel { animation: none; }
}
