:root {
  --bg: #eaf3fe; --bg2: #f7faff; --card: #ffffff; --ink: #172033; --muted: #5d6b82; --line: #d6deea;
  --blue: #2f6fd6; --blue-l: #9cc0f0; --blue-xl: #dbe8fb; --yellow: #f5a524; --yellow-l: #fde7bd; --cream: #fff4dc;
  --green: #3ccf7a; --green-d: #1f7a45; --green-l: #c9efd5; --red: #ef4b62; --pink: #ff6b8b;
  --font: "Rubik", 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: radial-gradient(120% 60% at 50% 0%, #ffffff 0%, var(--bg) 55%, #dcebfd 100%); background-color: var(--bg);
  color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none;
}
button, input { font-family: inherit; }
button { touch-action: manipulation; cursor: pointer; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

.app {
  /* najpierw 100% — zapas dla iOS < 15.4 i Chrome < 108, które nie znają dvh i pominęłyby całą deklarację */
  position: relative; z-index: 1; max-width: 460px; height: 100%; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column;
  padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.top { display: flex; align-items: center; justify-content: space-between; height: 46px; flex: none; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--yellow-l); box-shadow: inset 0 0 0 2px var(--yellow); font-size: 18px; }
.logo-txt { display: flex; flex-direction: column; font: 900 19px/1 var(--font); letter-spacing: -.01em; }
.logo-txt small { font: 700 10px/1.3 var(--font); letter-spacing: .14em; text-transform: uppercase; color: var(--blue); }
.sound { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: 0 2px 0 var(--line), inset 0 0 0 2px var(--line); font-size: 18px; }
.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: translateY(8px); transition: opacity .25s, transform .25s, visibility 0s .25s; }
.screen.active { opacity: 1; visibility: visible; transform: none; transition: opacity .25s, transform .25s; }

/* ---------------------------------------------------------------- wspólne */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px; font: 800 17px var(--font); }
.pill-score { background: var(--blue-l); }
.pill-streak { background: var(--yellow-l); }
.pill-score.bump, .pill-streak.bump { animation: bump .4s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.15); } }
.btn { width: 100%; max-width: 340px; min-height: 52px; padding: 0 18px; border-radius: 18px; border: 0; font: 800 18px var(--font); color: var(--ink); }
.btn-blue { background: var(--blue-l); box-shadow: inset 0 0 0 3px var(--blue), 0 4px 0 var(--blue); }
.btn-blue:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--blue), 0 1px 0 var(--blue); }
.btn-next { width: auto; min-height: 44px; margin-top: 8px; padding: 0 22px; border-radius: 99px; background: var(--blue-xl); font-size: 16px; }
.emoji-box { position: relative; display: flex; align-items: center; justify-content: center; min-height: 110px; width: 100%; max-width: 320px; padding: 10px 16px; border-radius: 22px;
  background: var(--yellow-l); box-shadow: inset 0 0 0 3px var(--yellow), 0 4px 0 #e9c27a; font-size: 50px; line-height: 1.1; text-align: center; }
.emoji-box .spark { position: absolute; right: -10px; top: -12px; font-style: normal; font-size: 24px; animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(.7) rotate(20deg); opacity: .6; } }
.emoji-box.small { min-height: 0; max-width: 200px; padding: 6px 14px; font-size: 30px; border-radius: 16px; }

/* ---------------------------------------------------------------- powitanie */
.hero { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: -6vh; }
.hero-box { display: flex; align-items: center; gap: 14px; padding: 16px 28px; border-radius: 26px; background: var(--yellow-l); box-shadow: inset 0 0 0 3px var(--yellow), 0 5px 0 #e9c27a; font-size: 60px; }
.hero-box b { font: 900 40px var(--font); color: var(--ink); }
.hero-tiles { display: flex; gap: 6px; }
.hero-tiles i { width: 40px; height: 46px; display: grid; place-items: center; border-radius: 10px; font: 900 22px var(--font); font-style: normal; background: var(--blue-l); box-shadow: inset 0 0 0 3px var(--blue), 0 4px 0 var(--blue); animation: hop 2.4s ease-in-out infinite; }
.hero-tiles i:nth-child(2) { animation-delay: .1s; } .hero-tiles i:nth-child(3) { animation-delay: .2s; } .hero-tiles i:nth-child(4) { animation-delay: .3s; }
.hero-tiles i:nth-child(5) { animation-delay: .4s; } .hero-tiles i:nth-child(6) { animation-delay: .5s; } .hero-tiles i:nth-child(7) { animation-delay: .6s; }
@keyframes hop { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-8px); } }
.hero-sub { margin: 0; font: 700 16px var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- menu */
#s-menu { gap: 10px; justify-content: flex-start; overflow-y: auto; padding: 6px 0 10px; }
#s-menu::before, #s-menu::after { content: ''; flex: 1 1 0; } /* wyśrodkowanie, a przy braku miejsca — przewijanie */
.title { margin: 0; font: 900 34px/1 var(--font); letter-spacing: -.02em; -webkit-text-stroke: 1px var(--ink); }
.lead { margin: 0 0 4px; max-width: 360px; text-align: center; font: 500 15px/1.4 var(--font); color: var(--muted); }
.lead b { color: var(--ink); }
.mode { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 360px; min-height: 70px; padding: 10px 16px; border-radius: 20px; border: 0; text-align: left; color: var(--ink);
  background: var(--blue-l); box-shadow: inset 0 0 0 3px var(--blue), 0 5px 0 var(--blue); }
.mode:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--blue), 0 2px 0 var(--blue); }
.mode.daily { background: var(--green-l); box-shadow: inset 0 0 0 3px var(--green), 0 5px 0 var(--green-d); }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,.7); font-size: 22px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 900 19px/1.15 var(--font); }
.m-txt small { font: 600 13px/1.3 var(--font); color: #34445c; }
.name-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 360px; padding: 8px 12px; border-radius: 16px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font: 700 13px var(--font); color: var(--muted); }
.name-row span { flex: none; }
.name-row input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border-radius: 10px; border: 2px solid var(--line); font: 700 15px var(--font); color: var(--ink); outline: none; }
.name-row input:focus { border-color: var(--blue); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rules span { padding: 5px 10px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font: 700 12px var(--font); color: var(--muted); }
.duel-invite { width: 100%; max-width: 360px; padding: 12px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 3px var(--green), 0 5px 0 var(--green-d); display: flex; flex-direction: column; gap: 10px; animation: bump .5s ease; }
.di-top { display: flex; align-items: center; gap: 12px; }
.di-ava { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--green-l); box-shadow: inset 0 0 0 3px var(--green); font-size: 28px; }
.di-top b { display: block; font: 900 17px/1.2 var(--font); }
.di-top span { font: 600 13px/1.3 var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- gra */
#s-play { justify-content: flex-start; gap: 10px; padding-top: 2px; }
.hud { display: flex; align-items: center; justify-content: space-between; width: 100%; flex: none; }
.hearts { font-size: 20px; letter-spacing: 2px; }
.hearts i { font-style: normal; display: inline-block; }
.hearts i.lost { filter: grayscale(1); opacity: .35; }
.hearts i.pop { animation: heartLost .6s ease; }
@keyframes heartLost { 40% { transform: scale(1.6) rotate(-15deg); } }
.meta { display: flex; justify-content: space-between; width: 100%; max-width: 360px; font: 700 12px var(--font); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; flex: none; }
.kind { padding: 3px 10px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }
.emoji-box.pop { animation: bump .45s cubic-bezier(.3,1.6,.5,1); }
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; width: 100%; flex: none; min-height: 48px; }
.slots .word { display: flex; gap: 4px; }
.slot { width: var(--ss, 38px); height: calc(var(--ss, 38px) * 1.15); display: grid; place-items: center; border-radius: 10px; font: 900 calc(var(--ss, 38px) * .52) var(--font); color: var(--ink);
  background: rgba(255,255,255,.6); box-shadow: inset 0 0 0 2px #c3cedd; border: 0; padding: 0; outline: none; }
.slot:not(.filled) { box-shadow: none; border: 2px dashed #c3cedd; }
.slot.filled { background: var(--blue-l); box-shadow: inset 0 0 0 3px var(--blue), 0 3px 0 var(--blue); animation: drop .2s ease-out; }
.slot.locked { background: var(--yellow-l); box-shadow: inset 0 0 0 3px var(--yellow), 0 3px 0 #d9901c; }
@keyframes drop { from { transform: translateY(-8px) scale(.85); } }
.slots.shake { animation: shake .45s ease; }
.slots.shake .slot.filled { background: #ffd5dc; box-shadow: inset 0 0 0 3px var(--red), 0 3px 0 var(--red); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.slots.win .slot { background: var(--green-l); box-shadow: inset 0 0 0 3px var(--green), 0 3px 0 var(--green-d); }
.tiles { display: grid; grid-template-columns: repeat(var(--cols, 4), var(--ts, 58px)); gap: 10px; justify-content: center; flex: 1; min-height: 0; align-content: center; }
.tile { width: var(--ts, 58px); height: var(--ts, 58px); display: grid; place-items: center; padding: 0; border: 0; border-radius: 14px; font: 900 calc(var(--ts, 58px) * .42) var(--font); color: var(--ink);
  background: var(--blue-l); box-shadow: inset 0 0 0 3px var(--blue), 0 5px 0 var(--blue); transition: transform .08s; }
.tile:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--blue), 0 2px 0 var(--blue); }
.tile.used { visibility: hidden; }
.tile.in { animation: tileIn .3s cubic-bezier(.3,1.6,.5,1) both; animation-delay: var(--d, 0s); }
@keyframes tileIn { from { transform: scale(0); } }
.bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; flex: none; }
.hint { height: 38px; padding: 0 16px; border: 0; border-radius: 99px; background: var(--yellow-l); font: 700 15px var(--font); color: var(--ink); }
.hint:disabled { opacity: .45; }
.timebar { width: 100%; max-width: 340px; height: 14px; border-radius: 99px; background: #e2e8f1; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; border-radius: 99px; background: var(--yellow); transform-origin: left center; }
.timebar.danger i { background: var(--red); }
.time { font: 700 15px var(--font); font-variant-numeric: tabular-nums; }
.time.danger { color: var(--red); }

/* po rozwiązaniu */
.solved { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 4px;
  background: radial-gradient(120% 70% at 50% 20%, #ffffff, var(--bg) 70%); animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.pill-plus { background: var(--blue-l); }
.big-word { max-width: 100%; text-align: center; font: 900 clamp(30px, 10.5vw, 48px)/1.05 var(--font); letter-spacing: .01em; color: var(--ink);
  -webkit-text-stroke: 2px #fff; paint-order: stroke fill; text-shadow: 0 4px 0 rgba(23,32,51,.12); overflow-wrap: anywhere; animation: bump .5s cubic-bezier(.3,1.6,.5,1); }
.solved.missed .big-word { color: var(--red); }
.parts { padding: 6px 16px; border-radius: 99px; background: var(--green-l); color: var(--green-d); font: 700 16px var(--font); text-align: center; }
.solved.missed .parts { background: #ffe2e7; color: #a0213a; }
.dict { width: 100%; max-width: 340px; padding: 10px 14px; border-radius: 14px; background: var(--blue-xl); box-shadow: inset 5px 0 0 var(--blue); }
.dict-label { font: 700 12px var(--font); color: var(--blue); letter-spacing: .04em; }
.dict p { margin: 4px 0 0; font: 500 16px/1.35 var(--font); text-align: center; }
.floats { position: fixed; inset: 0; pointer-events: none; z-index: 31; }
.float { position: absolute; transform: translate(-50%, -50%); font: 900 24px var(--font); color: var(--blue); -webkit-text-stroke: 4px #fff; paint-order: stroke fill; animation: floatUp 1s ease-out both; }
.float.bad { color: var(--red); }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -180%); } }

/* ---------------------------------------------------------------- finał */
#s-final { gap: 14px; text-align: center; }
.duel { width: 100%; max-width: 360px; padding: 14px; border-radius: 24px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 5px 0 var(--line); }
.duel-head { margin: -14px -14px 12px; padding: 12px; border-radius: 24px 24px 0 0; background: var(--blue-xl); font: 900 20px var(--font); }
.duel-row { display: flex; align-items: center; justify-content: space-around; }
.duel-p { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.duel-p .ava { width: 82px; height: 82px; display: grid; place-items: center; border-radius: 50%; font-size: 46px; background: var(--blue-l); box-shadow: inset 0 0 0 4px var(--blue); }
.duel-p.them .ava { background: var(--green-l); box-shadow: inset 0 0 0 4px var(--green); }
.duel-p b { font: 600 15px var(--font); color: var(--muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-p strong { font: 900 30px var(--font); font-variant-numeric: tabular-nums; }
.crown { position: absolute; top: -18px; font-size: 26px; visibility: hidden; }
.crown.on { visibility: visible; animation: bump .6s ease; }
.vs { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); font: 900 15px var(--font); margin-top: -40px; }
.duel-out { display: inline-block; margin-top: 12px; padding: 8px 18px; border-radius: 99px; background: var(--green-l); font: 800 17px var(--font); }
.duel-out.lose { background: #ffe2e7; }
.final-solo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.final-ico { font-size: 64px; animation: bump .6s ease; }
.final-title { font: 900 30px/1.1 var(--font); }
.final-score { display: flex; flex-direction: column; padding: 8px 28px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 5px 0 var(--line); }
.final-score span { font: 700 12px var(--font); color: var(--muted); letter-spacing: .12em; }
.final-score b { font: 900 48px/1.1 var(--font); font-variant-numeric: tabular-nums; }
.final-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.final-stats span { padding: 6px 12px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font: 700 14px var(--font); }
.grid-daily { font-size: 28px; letter-spacing: 4px; }

.pause { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(234,243,254,.92); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.pause-card { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; }
.pause-title { font-size: 48px; }
.pause-card p { margin: 0; font: 600 17px var(--font); color: var(--muted); }

@media (max-height: 680px) {
  .emoji-box { min-height: 92px; font-size: 42px; }
  .top { height: 42px; }
  #s-play { gap: 8px; }
  .lead { font-size: 14px; }
  .mode { min-height: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-tiles i, .emoji-box .spark { animation: none !important; }
}
