:root {
  --ink: #fff; --deep: #2a0f4f; --muted: #e9d8ff; --card: rgba(42,15,79,.94); --line: rgba(255,255,255,.22);
  --yellow: #ffd23f; --pink: #ff4fa3; --green: #2ed47a; --green-d: #13914c; --red: #ff4d5e; --red-d: #b3192a; --cyan: #3ee0ff;
  --font: "Baloo 2", system-ui, -apple-system, "Segoe 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: #3b1670; color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
button, input { font-family: inherit; }
button { touch-action: manipulation; cursor: pointer; }

/* najpierw 100% — zapas dla iOS < 15.4 i Chrome < 108, które nie znają dvh i pominęłyby całą deklarację */
.app { position: relative; max-width: 480px; height: 100%; height: 100dvh; margin: 0 auto; overflow: hidden; touch-action: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sound { position: absolute; z-index: 6; top: max(8px, env(safe-area-inset-top)); right: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); box-shadow: inset 0 0 0 2px var(--line); color: #fff; font-size: 17px; }
.stage { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.screen { position: absolute; top: max(8px, env(safe-area-inset-top)); bottom: max(8px, env(safe-area-inset-bottom)); left: 12px; right: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }
.screen.active { opacity: 1; visibility: visible; transition: opacity .25s; }
.screen button, .screen input, .panel, .over { pointer-events: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; max-width: 330px; min-height: 50px; padding: 0 18px; border-radius: 99px; border: 0; font: 800 19px var(--font); color: #fff; }
.btn-go { background: linear-gradient(180deg, #ff7cc0, var(--pink)); box-shadow: 0 4px 0 #b3166a; }
.btn-go:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3166a; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 14px; border-radius: 99px; font: 800 20px var(--font); white-space: nowrap; background: rgba(42,15,79,.75); box-shadow: inset 0 0 0 2px var(--yellow); color: #fff; }
.pill.bump { animation: bump .3s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.15); } }
.pill-time { box-shadow: inset 0 0 0 2px var(--cyan); }
.pill-time.low { background: var(--red); box-shadow: inset 0 0 0 2px #fff; }

/* ---------------------------------------------------------------- powitanie i menu */
.hero-title { margin: -22vh 0 0; font: 800 62px/1 var(--font); color: var(--yellow); text-shadow: 0 5px 0 #c2410c, 0 0 24px rgba(255,210,63,.6); transform: rotate(-4deg); }
.hero-sub { margin: 10px 0 0; font: 700 20px var(--font); }
#s-menu { justify-content: flex-start; overflow-y: auto; overflow-x: hidden; padding: 54px 0 14px; }
#s-menu::before, #s-menu::after { content: ''; flex: 1 1 0; }
.panel { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 14px; border-radius: 26px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 10px 40px rgba(20,0,50,.45); flex: none; }
.title { margin: 0; font: 800 34px/1 var(--font); color: var(--yellow); }
.demo { display: flex; gap: 6px; align-items: center; }
.demo span { width: 40px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: #fff3d6; color: var(--deep); font: 800 26px var(--font); box-shadow: 0 3px 0 #c9a96b; }
.demo span:nth-child(2) { transform: rotate(-6deg); } .demo span:nth-child(3) { transform: rotate(5deg); }
.demo i { margin-left: 6px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--green); font: 800 24px var(--font); font-style: normal; box-shadow: 0 3px 0 var(--green-d); }
.lead { margin: 0; text-align: center; font: 600 16px/1.4 var(--font); color: var(--muted); }
.lead b { color: #fff; }
.mode { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px; padding: 8px 16px; border-radius: 18px; border: 0; text-align: left; color: #fff;
  background: linear-gradient(180deg, #ff7cc0, var(--pink)); box-shadow: 0 4px 0 #b3166a; }
.mode:active { transform: translateY(3px); box-shadow: 0 1px 0 #b3166a; }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.2); font-size: 22px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 800 22px/1.1 var(--font); }
.m-txt small { font: 600 14px/1.3 var(--font); color: #ffe3f2; }
.best { margin: 0; font: 700 16px var(--font); color: var(--yellow); }
.name-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 14px; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 2px var(--line); font: 700 14px var(--font); color: var(--muted); }
.name-row span { flex: none; max-width: 48%; }
.name-row input { flex: 1; min-width: 0; height: 34px; padding: 0 10px; border-radius: 10px; border: 2px solid var(--line); background: rgba(0,0,0,.25); font: 700 16px var(--font); color: #fff; outline: none; user-select: text; -webkit-user-select: text; }
.name-row input:focus { border-color: var(--yellow); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rules span { padding: 2px 10px; border-radius: 99px; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px var(--line); font: 700 13px var(--font); color: var(--muted); }
.duel-invite { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px; border-radius: 18px; background: rgba(255,79,163,.15); box-shadow: inset 0 0 0 2px var(--pink); text-align: center; }
.duel-invite b { font: 800 18px/1.2 var(--font); }
.duel-invite span { font: 600 14px/1.3 var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- gra */
#s-play { justify-content: flex-start; }
.hud { display: flex; align-items: center; gap: 8px; width: 100%; padding-right: 48px; flex: none; }
.combo { margin-top: 8px; width: 100%; display: flex; align-items: center; gap: 8px; flex: none; }
.combo b { flex: none; font: 800 16px var(--font); letter-spacing: .5px; color: var(--yellow); text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.combo b i { font-style: normal; color: #fff; }
.combo .bar { flex: 1; height: 12px; border-radius: 99px; background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 2px var(--line); overflow: hidden; }
.combo .bar span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--yellow), #ff8a3d, var(--pink)); transition: width .15s linear; }
.combo.hot b i { color: var(--yellow); animation: bump .4s ease; }
.praise { position: absolute; left: 0; right: 0; top: 26%; text-align: center; font: 800 46px/1 var(--font); color: var(--yellow); text-shadow: 0 4px 0 #c2410c, 0 0 26px rgba(255,210,63,.7); pointer-events: none; animation: praise .9s ease both; }
@keyframes praise { 0% { transform: scale(.4) rotate(-8deg); opacity: 0; } 25% { transform: scale(1.15) rotate(-4deg); opacity: 1; } 70% { transform: scale(1) rotate(-4deg); opacity: 1; } 100% { transform: scale(1) translateY(-20px) rotate(-4deg); opacity: 0; } }
.feedback { position: absolute; left: 0; right: 0; bottom: calc(var(--act-h, 72px) + var(--bask-h, 120px)); margin: 0 auto; width: max-content; max-width: 100%; padding: 6px 14px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 2px var(--red); font: 700 16px/1.25 var(--font); text-align: center; pointer-events: none; animation: pop2 .25s ease both; }
@keyframes pop2 { from { transform: scale(.8); opacity: 0; } }
.drag-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--act-h, 72px) + var(--bask-h, 120px)); margin: 0; text-align: center; font: 700 17px var(--font); pointer-events: none; text-shadow: 0 2px 0 rgba(0,0,0,.3); animation: hintb 1.4s ease-in-out infinite; }
@keyframes hintb { 50% { transform: translateX(10px); } }
.actions { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; }
.act { flex: 1; height: 62px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 20px; color: #fff; font: 800 20px var(--font); }
.act span { font-size: 30px; line-height: 1; }
.act-ok { background: linear-gradient(180deg, #52e897, var(--green)); box-shadow: 0 5px 0 var(--green-d); }
.act-del { background: linear-gradient(180deg, #ff7a86, var(--red)); box-shadow: 0 5px 0 var(--red-d); flex: .8; }
.act:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.act:disabled { filter: grayscale(.6) brightness(.85); }
.act-ok.ready { animation: ready 1s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 5px 0 var(--green-d), 0 0 0 6px rgba(46,212,122,.35); } }

.over { position: absolute; inset: 84px 0 6px; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 14px 12px; border-radius: 26px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); text-align: center; animation: pop2 .35s ease both; }
.o-title { font: 800 34px var(--font); color: var(--yellow); }
.o-score { font: 800 48px/1 var(--font); }
.o-stats { font: 700 16px var(--font); color: var(--muted); }
.o-rank { padding: 4px 18px; border-radius: 99px; background: linear-gradient(90deg, var(--pink), #a855f7); font: 800 18px var(--font); }
.o-words { width: 100%; max-width: 360px; padding: 10px 12px; border-radius: 18px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); }
.o-words b { font: 800 16px var(--font); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; max-height: 24vh; overflow-y: auto; }
.chips button { border: 0; padding: 2px 10px; border-radius: 99px; background: #fff3d6; color: var(--deep); font: 800 15px var(--font); text-transform: uppercase; letter-spacing: .5px; }
.chips p { margin: 0; font: 600 15px var(--font); color: var(--muted); }
.duel { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 14px; background: rgba(255,255,255,.08); font: 700 16px var(--font); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(20,5,40,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { width: 100%; max-width: 330px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 20px 16px; border-radius: 22px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); text-align: center; }
.modal-title { font: 800 26px var(--font); }
.modal-card p { margin: 0 0 6px; font: 600 17px/1.4 var(--font); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
