:root {
  --bg1: #2a0b4f; --bg2: #7a1fa2; --ink: #fff; --muted: #ecd9ff;
  --yellow: #FFD23F; --pink: #FF4FA3; --mint: #28D7A0; --blue: #3FA9FF; --violet: #A66BFF; --orange: #FF7A3D;
  --paper: #FFF8EA; --paper2: #FBE9CF; --letter: #2d0b45;
  --display: "Lilita One", "Fredoka", system-ui, sans-serif;
  --font: "Fredoka", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: linear-gradient(160deg, #3a0d6b 0%, var(--bg1) 45%, #5c137f 100%);
  background-color: var(--bg1);
  color: var(--ink); font-family: var(--font); overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none;
}
button { font-family: inherit; touch-action: manipulation; cursor: pointer; }

/* ---------------------------------------------------------------- tło */
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: blob 18s ease-in-out infinite alternate; }
.b1 { width: 60vmax; height: 60vmax; left: -20vmax; top: -18vmax; background: #ff4fa3; }
.b2 { width: 55vmax; height: 55vmax; right: -22vmax; top: 20vh; background: #3f6bff; animation-delay: -6s; }
.b3 { width: 50vmax; height: 50vmax; left: 10vw; bottom: -30vmax; background: #28d7a0; opacity: .35; animation-delay: -12s; }
@keyframes blob { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(6vmax, 4vmax) scale(1.15); } }
.floaters span {
  position: absolute; bottom: -80px; font: 400 44px var(--display); color: #fff; opacity: .09;
  animation: floatUp linear infinite;
}
@keyframes floatUp { from { transform: translateY(0) rotate(0); } to { transform: translateY(-120vh) rotate(160deg); } }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

/* ---------------------------------------------------------------- układ */
.app {
  position: relative; z-index: 1; max-width: 480px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.top { display: grid; grid-template-columns: 1fr auto 44px; align-items: center; gap: 10px; height: 52px; flex: none; }
.logo { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bee { width: 36px; height: 36px; flex: none; filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); animation: hover 2.4s ease-in-out infinite; }
@keyframes hover { 50% { transform: translateY(-3px) rotate(-4deg); } }
.logo-txt { display: flex; flex-direction: column; font: 400 21px/1 var(--display); letter-spacing: .02em; text-shadow: 0 3px 0 rgba(0,0,0,.25); white-space: nowrap; }
.logo-txt small { font: 700 10px/1.2 var(--font); letter-spacing: .18em; text-transform: uppercase; color: var(--yellow); text-shadow: none; }
.score-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 92px; height: 44px; padding: 0 14px;
  border-radius: 16px; background: var(--yellow); color: #2a0b3d; box-shadow: 0 4px 0 #c78a00, 0 8px 18px rgba(0,0,0,.25);
}
.score-label { font: 700 9px/1 var(--font); letter-spacing: .16em; opacity: .7; }
.score-val { font: 400 22px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.score-box.bump { animation: bump .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.18) rotate(-3deg); } }
.sound {
  width: 44px; height: 44px; border-radius: 50%; border: 0; font-size: 20px; color: #fff;
  background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22);
}
.stage { position: relative; flex: 1; min-height: 0; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: scale(.97); transition: opacity .3s ease, transform .3s ease, visibility 0s .3s;
}
.screen.active { opacity: 1; visibility: visible; transform: none; transition: opacity .3s ease, transform .3s ease; }

/* ---------------------------------------------------------------- ekran powitalny */
.hero { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: -8vh; }
.hero-tiles { display: grid; grid-template-columns: repeat(4, auto); gap: 8px; justify-content: center; }
.hero-tiles b {
  width: 64px; height: 64px; display: grid; place-items: center; border-radius: 18px; font: 400 42px var(--display);
  color: #fff; background: var(--c); box-shadow: 0 6px 0 rgba(0,0,0,.25), inset 0 -6px 0 rgba(0,0,0,.12);
  text-shadow: 0 3px 0 rgba(0,0,0,.2); animation: wobble 2.8s ease-in-out infinite; animation-delay: var(--d);
}
@keyframes wobble { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-8px) rotate(-5deg); } 50% { transform: translateY(0) rotate(3deg); } }
.hero-sub { margin: 4px 0 0; text-align: center; font: 700 17px var(--font); letter-spacing: .2em; text-transform: uppercase; color: var(--yellow); text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.demo { position: relative; display: grid; grid-template-columns: repeat(5, 44px); gap: 0; padding: 10px; border-radius: 22px; background: var(--paper); box-shadow: 0 8px 0 #d9a6e8, 0 18px 40px rgba(0,0,0,.35); transform: rotate(-3deg); }
.demo i { height: 44px; display: grid; place-items: center; font: 700 24px var(--font); font-style: normal; color: var(--letter); }
.demo .hl { position: absolute; height: 34px; border-radius: 99px; background: var(--pink); opacity: .5; mix-blend-mode: multiply; transform-origin: left center; animation: hlDraw 3s ease-in-out infinite; }
@keyframes hlDraw { 0%, 15% { transform: scaleX(0); } 45%, 85% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }

/* ---------------------------------------------------------------- poziomy */
.big-title { margin: 0; text-align: center; font: 400 32px/1 var(--display); letter-spacing: .02em; text-shadow: 0 4px 0 rgba(0,0,0,.25); color: var(--yellow); }
.lead { margin: 10px 0 16px; text-align: center; color: var(--muted); font: 500 16px/1.4 var(--font); }
.lead b { color: #fff; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 400px; }
.lv {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 118px; padding: 14px 14px 12px;
  border: 0; border-radius: 22px; color: #fff; text-align: left;
  background: linear-gradient(160deg, var(--c), var(--cd)); box-shadow: 0 6px 0 var(--cd), 0 12px 24px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.lv:active, .lv.picked { transform: translateY(5px); box-shadow: 0 1px 0 var(--cd), 0 4px 10px rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.3); }
.lv.picked { animation: picked .6s ease; }
@keyframes picked { 30% { filter: brightness(1.4); } }
.lv-code { font: 400 34px/1 var(--display); text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.lv-name { font: 700 17px/1.1 var(--font); }
.lv-desc { font: 500 12.5px/1.25 var(--font); opacity: .9; }
.lv-grid { position: absolute; right: 12px; top: 12px; font: 700 12px var(--font); padding: 3px 8px; border-radius: 99px; background: rgba(0,0,0,.22); }
.lv.last::after {
  content: attr(data-last); position: absolute; right: 10px; bottom: -9px; padding: 3px 8px; border-radius: 99px;
  font: 700 10px var(--font); letter-spacing: .1em; background: var(--yellow); color: #2a0b3d; box-shadow: 0 2px 0 #c78a00;
}
.lv[data-level="B2"] { background: linear-gradient(160deg, #3b2a63, #14102a); }
.lv[data-level="B2"] .lv-code { color: var(--yellow); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 20px; }
.rules span { padding: 6px 10px; border-radius: 99px; background: rgba(255,255,255,.12); font: 600 12.5px var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- rozgrywka */
#s-play { justify-content: flex-start; gap: 8px; padding-top: 2px; }
.hud { display: flex; align-items: center; gap: 8px; width: 100%; height: 46px; flex: none; }
.clock {
  --p: 1; position: relative; width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--tc, var(--mint)) calc(var(--p) * 360deg), rgba(255,255,255,.18) 0);
}
.clock::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: #2d0b52; }
.clock span { position: relative; font: 400 20px var(--display); font-variant-numeric: tabular-nums; }
.clock.warn { --tc: var(--yellow); }
.clock.danger { --tc: #ff4d6a; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.1); } }
.timebar { flex: 1; height: 16px; border-radius: 99px; background: rgba(255,255,255,.16); overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.25); }
.timebar i {
  display: block; height: 100%; width: 100%; border-radius: 99px; transform-origin: left center;
  background: linear-gradient(90deg, #28D7A0, #7BE33A);
}
.timebar.warn i { background: linear-gradient(90deg, #FFD23F, #FF9F1A); }
.timebar.danger i { background: linear-gradient(90deg, #FF7A3D, #ff3d6a); }
.combo {
  position: relative; width: 72px; height: 46px; flex: none; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); overflow: hidden; opacity: .55; transition: opacity .2s, background .2s;
}
.combo-x { font: 400 22px/1 var(--display); }
.combo-label { font: 700 9px/1 var(--font); letter-spacing: .14em; opacity: .8; margin-top: 2px; }
.combo-drain { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--yellow); transform-origin: left center; transform: scaleX(0); }
.combo.on { opacity: 1; background: linear-gradient(160deg, #ff7a3d, #ff3d7f); box-shadow: 0 0 18px rgba(255,90,90,.55); }
.combo.on.pop { animation: bump .4s cubic-bezier(.3,1.8,.5,1); }
.theme-row { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 30px; flex: none; }
.theme { padding: 5px 12px; border-radius: 99px; background: rgba(255,255,255,.14); font: 700 15px var(--font); white-space: nowrap; }
.theme.pop { animation: bump .5s cubic-bezier(.3,1.8,.5,1); }
.progress { font: 700 14px var(--font); color: var(--muted); }

.board-wrap { position: relative; flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.board {
  --n: 6; --bs: 300px; --pad: 8px; position: relative; width: var(--bs); height: var(--bs); padding: var(--pad); border-radius: 22px;
  background: radial-gradient(circle at 30% 20%, #fffdf7, var(--paper) 55%, var(--paper2));
  box-shadow: 0 7px 0 #d9a6e8, 0 18px 40px rgba(0,0,0,.35); touch-action: none; cursor: pointer;
}
.cells { display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); width: 100%; height: 100%; }
.cell {
  display: flex; align-items: center; justify-content: center; font: 700 var(--fs, 24px)/1 var(--font); color: var(--letter);
  transition: transform .12s ease, color .12s ease; position: relative;
}
.cell.blank { color: transparent; }
.cell.in { animation: cellIn .35s cubic-bezier(.3,1.6,.5,1) both; animation-delay: var(--d, 0s); }
@keyframes cellIn { from { transform: scale(0) rotate(-30deg); opacity: 0; } }
.cell.out { animation: cellOut .3s ease-in both; animation-delay: var(--d, 0s); }
@keyframes cellOut { to { transform: scale(0) rotate(30deg); opacity: 0; } }
.cell.sel { transform: scale(1.22); color: #b0005a; }
.cell.anchor::before, .cell.hint::before {
  content: ''; position: absolute; inset: 8%; border-radius: 50%; border: 3px solid var(--pink); animation: ring 1s ease-in-out infinite;
}
.cell.hint::before { border-color: #ff9f1a; border-style: dashed; }
@keyframes ring { 50% { transform: scale(1.15); opacity: .5; } }
.cell.hop { animation: hop .45s cubic-bezier(.3,1.8,.5,1); animation-delay: var(--d, 0s); }
@keyframes hop { 40% { transform: translateY(-22%) scale(1.25); } }
.marks { position: absolute; left: var(--pad); top: var(--pad); width: calc(100% - var(--pad) * 2); height: calc(100% - var(--pad) * 2); pointer-events: none; mix-blend-mode: multiply; overflow: visible; }
.marks line { stroke-linecap: round; fill: none; }
.marks .mk { stroke-width: .74; opacity: .5; }
.marks .mk.draw { animation: draw .38s ease-out both; }
@keyframes draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.marks .mk.missed { stroke: #ff4d6a; opacity: .28; stroke-dasharray: .18 .14; animation: none; }
#sel { stroke: var(--pink); stroke-width: .8; opacity: 0; }
#sel.on { opacity: .38; }
.board.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.board.dim .cells { filter: blur(6px); opacity: .4; }

.praise, .countdown, .banner { position: absolute; left: 0; right: 0; pointer-events: none; text-align: center; }
.praise { top: 50%; transform: translateY(-50%); z-index: 3; opacity: 0; }
.praise.go { animation: praise 1.1s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes praise { 0% { opacity: 0; transform: translateY(-50%) scale(.3) rotate(-8deg); } 18% { opacity: 1; transform: translateY(-50%) scale(1.12) rotate(3deg); } 30% { transform: translateY(-50%) scale(1) rotate(0); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-80%) scale(1); } }
.praise .p-big, .countdown b, .banner b {
  display: block; font: 400 clamp(34px, 11vw, 52px)/1 var(--display); color: #fff; letter-spacing: .02em;
  -webkit-text-stroke: 7px var(--pc, #ff3d7f); paint-order: stroke fill; text-shadow: 0 6px 0 rgba(0,0,0,.25);
}
.praise .p-sub { display: inline-block; max-width: 92%; margin-top: 8px; padding: 4px 12px; line-height: 1.25; border-radius: 99px; background: #2d0b52; color: var(--yellow); font: 700 17px var(--font); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.praise .p-sub em { font-style: normal; color: #fff; font-weight: 500; }
.countdown { top: 50%; transform: translateY(-50%); z-index: 4; }
.countdown b { font-size: clamp(80px, 30vw, 130px); -webkit-text-stroke-width: 10px; --pc: #7a1fa2; animation: cd .8s cubic-bezier(.2,1.6,.4,1) both; }
.countdown b.go-word { font-size: clamp(46px, 15vw, 72px); --pc: #ff3d7f; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
.banner { top: 50%; transform: translateY(-50%); z-index: 4; opacity: 0; }
.banner.go { animation: banner 1.5s ease both; }
.banner b { --pc: #1fa36a; font-size: clamp(32px, 10vw, 46px); }
.banner span { display: inline-block; margin-top: 8px; padding: 4px 14px; border-radius: 99px; background: var(--yellow); color: #2a0b3d; font: 700 18px var(--font); }
.banner.bad b { --pc: #e0143c; }
@keyframes banner { 0% { opacity: 0; transform: translateY(-50%) scale(.4); } 15% { opacity: 1; transform: translateY(-50%) scale(1.1); } 25% { transform: translateY(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

.words { --cols: 3; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; flex: none; padding-bottom: 2px; }
.chip {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 42px; min-width: 0; padding: 0 6px;
  flex: 0 0 calc((100% - (var(--cols) - 1) * 6px) / var(--cols));
  border-radius: 14px; border: 2px solid rgba(255,255,255,.22); background: rgba(255,255,255,.12); color: #fff; transition: background .25s, border-color .25s, color .25s;
}
.chip .en { font: 700 var(--cfs, 15px)/1.05 var(--font); letter-spacing: .05em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .pl { font: 500 11px/1.2 var(--font); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0; height: 0; transition: opacity .25s; }
.chip.found { background: var(--c); border-color: rgba(255,255,255,.55); color: #2a0b3d; }
.chip.found .en { text-decoration: line-through; text-decoration-thickness: 2.5px; text-decoration-color: rgba(42,11,61,.75); }
.chip.found .pl { opacity: 1; height: auto; }
.chip.found.fresh { animation: bump .5s cubic-bezier(.3,1.8,.5,1); }
.chip.missed { border-style: dashed; border-color: #ff6b85; background: rgba(255,77,106,.18); }
.chip.missed .pl { opacity: 1; height: auto; }
.chip.in { animation: chipIn .35s cubic-bezier(.3,1.6,.5,1) both; animation-delay: var(--d, 0s); }
@keyframes chipIn { from { transform: translateY(12px) scale(.6); opacity: 0; } }
/* Interfejs w języku nauki (en): zamiast tłumaczenia krótka definicja — do dwóch linijek. */
.words.defs .chip .pl {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  white-space: normal; text-overflow: clip; text-align: center; font-size: 9px; line-height: 1.05;
}

.floats { position: fixed; inset: 0; pointer-events: none; z-index: 31; }
.float {
  position: absolute; transform: translate(-50%, -50%); font: 400 26px var(--display); color: var(--yellow); white-space: nowrap;
  -webkit-text-stroke: 5px #2d0b52; paint-order: stroke fill; animation: floatPts 1s ease-out both;
}
@keyframes floatPts { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

/* ---------------------------------------------------------------- finał */
#s-final { gap: 12px; text-align: center; overflow: hidden; }
.final-burst {
  position: absolute; left: 50%; top: 42%; width: 900px; height: 900px; margin: -450px 0 0 -450px; border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(rgba(255,210,63,.14) 0 10deg, transparent 10deg 20deg);
  animation: spin 30s linear infinite; mask-image: radial-gradient(circle, #000 20%, transparent 65%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 65%);
}
@keyframes spin { to { transform: rotate(360deg); } }
.final-kicker { position: relative; padding: 6px 14px; border-radius: 99px; background: rgba(255,255,255,.14); font: 700 14px var(--font); letter-spacing: .16em; }
.final-title { position: relative; font: 400 clamp(38px, 12vw, 56px)/1 var(--display); color: #fff; -webkit-text-stroke: 8px #ff3d7f; paint-order: stroke fill; text-shadow: 0 6px 0 rgba(0,0,0,.25); animation: praise-in .7s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes praise-in { from { transform: scale(.3) rotate(-10deg); opacity: 0; } }
.final-score-box { position: relative; display: flex; flex-direction: column; padding: 12px 36px 10px; border-radius: 24px; background: var(--paper); color: var(--letter); box-shadow: 0 7px 0 #d9a6e8, 0 18px 40px rgba(0,0,0,.35); }
.final-score-label { font: 700 12px var(--font); letter-spacing: .18em; color: #8a4fb0; }
.final-score { font: 400 60px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.final-stars { position: relative; font-size: 40px; letter-spacing: 4px; }
.final-stars span { display: inline-block; color: rgba(255,255,255,.2); animation: star .5s cubic-bezier(.3,1.8,.5,1) both; }
.final-stars span.on { color: var(--yellow); text-shadow: 0 0 18px rgba(255,210,63,.8); }
@keyframes star { from { transform: scale(0) rotate(-90deg); } }
.final-stats { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.final-stats span { padding: 6px 12px; border-radius: 99px; background: rgba(255,255,255,.14); font: 700 15px var(--font); }

/* ---------------------------------------------------------------- pauza */
.pause { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(28,6,52,.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.pause-card { text-align: center; padding: 24px; }
.pause-title { font: 400 48px var(--display); color: var(--yellow); text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.pause-card p { color: var(--muted); font: 500 17px var(--font); }
.btn { min-height: 52px; padding: 0 28px; border: 0; border-radius: 99px; background: var(--yellow); color: #2a0b3d; font: 400 22px var(--display); box-shadow: 0 5px 0 #c78a00; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c78a00; }

/* ---------------------------------------------------------------- małe i niskie ekrany */
@media (max-height: 640px) {
  .top { height: 46px; }
  .hud { height: 40px; }
  .clock { width: 40px; height: 40px; }
  .combo { height: 40px; }
  .lv { min-height: 100px; padding: 12px; }
  .lead { margin: 6px 0 12px; font-size: 15px; }
  .chip { height: 38px; }
  .words.defs .chip .pl { font-size: 8.5px; }
}
@media (max-width: 350px) {
  .logo-txt { font-size: 18px; }
  .score-box { min-width: 80px; }
  .hero-tiles b { width: 54px; height: 54px; font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .floaters span, .bee, .hero-tiles b, .final-burst, .clock.danger, .demo .hl { animation: none !important; }
  .cell.in, .cell.out, .cell.hop, .chip.in, .board.shake { animation-duration: .01s !important; }
}
