:root {
  --sky: #8fc3f2; --ink: #1f2547; --muted: #4c5a86; --card: rgba(255,255,255,.92);
  --gold: #f4c64f; --gold-d: #b98a1c; --gold-l: #fde9a8; --violet: #8a90e8; --violet-d: #4b4fb4; --violet-l: #c9ccf6;
  --blue: #3f74d6; --green: #3fbf55; --red: #e2483f;
  --font: "Fredoka", 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: #6fb0ea; 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; }

/* 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,.75); box-shadow: 0 2px 0 rgba(0,0,0,.12); font-size: 17px; }
.stage { position: absolute; inset: 0; z-index: 2; }
.screen { position: absolute; top: max(8px, env(safe-area-inset-top)); bottom: max(10px, 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; }

/* ---------------------------------------------------------------- wspólne */
.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: 700 18px var(--font); color: var(--ink); }
.btn-gold { background: var(--gold); box-shadow: inset 0 0 0 3px var(--gold-d), 0 4px 0 var(--gold-d); }
.btn-gold:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--gold-d), 0 1px 0 var(--gold-d); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px; border-radius: 99px; font: 700 18px var(--font); white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.pill-gates { background: var(--gold-l); }
.pill-best { background: var(--violet-l); }
.pill-mode { background: var(--violet); color: #fff; font-size: 15px; }
.pill.bump { animation: bump .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.18); } }

/* ---------------------------------------------------------------- powitanie i menu */
.hero-title { margin: 0; font: 700 52px/1 var(--font); color: #fff; text-shadow: 0 4px 0 var(--gold-d), 0 0 2px var(--gold-d); -webkit-text-stroke: 2px #6b4d0c; margin-top: -24vh; }
.hero-sub { margin: 10px 0 0; font: 600 18px var(--font); color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.25); }
#s-menu { justify-content: flex-start; overflow-y: auto; overflow-x: hidden; padding: 84px 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: 0 10px 30px rgba(31,37,71,.18); flex: none; }
.title { margin: 0; font: 700 34px/1 var(--font); letter-spacing: .02em; color: var(--ink); }
.lead { margin: 0; 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%; min-height: 64px; padding: 8px 16px; border-radius: 20px; border: 0; text-align: left; color: var(--ink);
  background: var(--gold-l); box-shadow: inset 0 0 0 3px var(--gold), 0 5px 0 var(--gold-d); }
.mode:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--gold), 0 2px 0 var(--gold-d); }
.mode.voice { background: var(--violet-l); box-shadow: inset 0 0 0 3px var(--violet), 0 5px 0 var(--violet-d); }
.mode.voice:active { box-shadow: inset 0 0 0 3px var(--violet), 0 2px 0 var(--violet-d); }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,.8); font-size: 22px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 700 20px/1.1 var(--font); }
.m-txt small { font: 500 13px/1.3 var(--font); color: var(--muted); }
.best { margin: 0; font: 600 15px var(--font); color: var(--muted); }
.name-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 2px #dfe3f3; font: 600 13px 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 #dfe3f3; font: 600 15px var(--font); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; }
.name-row input:focus { border-color: var(--violet); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rules span { padding: 4px 10px; border-radius: 99px; background: #fff; box-shadow: inset 0 0 0 2px #dfe3f3; font: 600 12px 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: var(--gold-l); box-shadow: inset 0 0 0 3px var(--gold); text-align: center; }
.duel-invite b { font: 700 17px/1.2 var(--font); }
.duel-invite span { font: 500 13px/1.3 var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- lot */
#s-play { justify-content: flex-start; }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding-right: 48px; flex: none; }
.hud .pill-gates { margin-right: auto; }
.hud .pill-mode:not([hidden]) + .pill-gates { margin-right: 0; margin-left: auto; }
.task { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; width: 100%; margin-top: 10px; padding: 9px 14px; border-radius: 18px; flex: none;
  background: rgba(253,233,168,.9); box-shadow: inset 0 0 0 3px var(--gold), 0 3px 0 rgba(0,0,0,.08); text-align: center; }
.task.flash { animation: bump .35s cubic-bezier(.3,1.8,.5,1); }
.t-lbl { font: 600 17px var(--font); }
.t-q { font: 700 22px/1.2 var(--font); }
.t-q.sentence { font-size: 18px; }
.t-hint { width: 100%; font: 600 15px var(--font); color: var(--muted); opacity: 0; transition: opacity .6s; }
.t-hint.on { opacity: 1; }
.start-hint { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); padding: 10px 20px; border-radius: 99px; background: rgba(255,255,255,.85); font: 700 18px var(--font); white-space: nowrap; animation: pulse 1s ease-in-out infinite alternate; pointer-events: none; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.06); } }
.ground-hint { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); text-align: center; font: 700 17px var(--font); color: var(--ink); pointer-events: none; }
.bubble { position: absolute; padding: 7px 14px; border-radius: 18px; background: #dbe7fb; box-shadow: inset 0 0 0 3px var(--blue); font: 700 18px var(--font); white-space: nowrap; transform: translate(-30%, -100%); pointer-events: none; animation: pop .3s cubic-bezier(.2,1.6,.4,1); }
.bubble.miss { background: #fde2df; box-shadow: inset 0 0 0 3px var(--red); }
@keyframes pop { from { transform: translate(-30%, -100%) scale(.6); opacity: 0; } }
.mic { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.mic-ico { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--violet-l); box-shadow: inset 0 0 0 4px var(--violet-d); font-size: 28px; }
.mic.live .mic-ico { animation: ring 1.1s ease-out infinite; }
@keyframes ring { 0% { box-shadow: inset 0 0 0 4px var(--violet-d), 0 0 0 0 rgba(75,79,180,.5); } 100% { box-shadow: inset 0 0 0 4px var(--violet-d), 0 0 0 22px rgba(75,79,180,0); } }
.mic-txt { font: 600 13px var(--font); color: var(--ink); background: rgba(255,255,255,.75); padding: 1px 8px; border-radius: 99px; }

/* koniec lotu */
.crash { position: absolute; inset: 56px 0 60px; z-index: 4; padding: 14px 12px; border-radius: 28px; background: rgba(226,239,252,.86); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); box-shadow: 0 10px 30px rgba(31,37,71,.18); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; animation: pop2 .4s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop2 { from { transform: scale(.85); opacity: 0; } }
.c-title { font: 700 30px var(--font); color: var(--ink); text-shadow: 0 2px 0 rgba(255,255,255,.6); }
.c-lbl { font: 600 16px var(--font); color: var(--ink); background: rgba(255,255,255,.7); padding: 2px 12px; border-radius: 99px; }
.c-card { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; max-width: 330px; padding: 14px 16px; border-radius: 22px; background: var(--violet-l); box-shadow: inset 0 0 0 3px var(--violet-d), 0 6px 18px rgba(31,37,71,.2); }
.c-word { font: 700 28px/1.15 var(--font); }
.c-listen { border: 0; background: none; font: 700 16px var(--font); color: var(--ink); padding: 4px 10px; border-radius: 99px; }
.c-listen:active { background: rgba(255,255,255,.5); }
.c-def { font: 500 15px/1.35 var(--font); color: var(--muted); }
.c-pills { display: flex; gap: 10px; }
.ribbon { padding: 8px 30px; background: var(--gold-l); font: 700 20px var(--font); clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%); }
.duel { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 16px; background: rgba(255,255,255,.85); font: 600 15px var(--font); }
.duel b { font-size: 16px; }

/* ---------------------------------------------------------------- okna */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(31,37,71,.45); -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: 24px; background: #fff; text-align: center; }
.modal-title { font: 700 26px var(--font); }
.modal-card p { margin: 0 0 6px; font: 500 16px/1.4 var(--font); color: var(--muted); }

@media (max-height: 640px) {
  .task { padding: 7px 12px; margin-top: 8px; }
  .t-q { font-size: 20px; } .t-q.sentence { font-size: 16.5px; }
  .crash { gap: 7px; }
  .c-title { font-size: 26px; }
  .c-word { font-size: 25px; }
  .mode { min-height: 56px; }
  .title { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
