:root {
  --space: #140a3a; --ink: #f4f1ff; --muted: #c8c2ef; --card: rgba(26,18,74,.92); --line: rgba(160,140,255,.35);
  --cyan: #38d6ff; --pink: #ff3d8b; --pink-d: #b0125a; --gold: #ffd23f; --green: #3ddc84; --red: #ff4d5e;
  --font: "Exo 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: var(--space); 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; }

/* wysokość .app ustawia skrypt według widocznej części ekranu (klawiatura telefonu ją zmniejsza) */
/* 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; }
#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,.14); box-shadow: inset 0 0 0 2px var(--line); color: #fff; font-size: 17px; }
.stage { position: absolute; inset: 0; z-index: 2; }
.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; }

.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 18px var(--font); color: #fff; }
.btn-pink { background: linear-gradient(180deg, #ff5fa2, var(--pink)); box-shadow: 0 4px 0 var(--pink-d), 0 0 20px rgba(255,61,139,.45); }
.btn-pink:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pink-d); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 14px; border-radius: 12px; font: 800 18px var(--font); white-space: nowrap; background: rgba(20,12,60,.75); box-shadow: inset 0 0 0 2px var(--cyan), 0 0 14px rgba(56,214,255,.35); }
.pill.bump { animation: bump .3s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.15); } }
.pill-level { font-size: 14px; box-shadow: inset 0 0 0 2px var(--line); color: var(--muted); }

/* ---------------------------------------------------------------- powitanie i menu */
.hero-title { margin: -24vh 0 0; font: 800 54px/1 var(--font); font-style: italic; color: var(--gold); text-shadow: 0 0 18px rgba(255,210,63,.6), 0 4px 0 #a5520c; }
.hero-sub { margin: 10px 0 0; font: 700 18px var(--font); color: var(--ink); }
#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: 24px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line), 0 0 40px rgba(110,80,255,.35); flex: none; }
.title { margin: 0; font: 800 32px/1 var(--font); font-style: italic; color: var(--gold); text-shadow: 0 0 14px rgba(255,210,63,.45); }
.lead { margin: 0; text-align: center; font: 600 15px/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(90deg, rgba(56,214,255,.25), rgba(255,61,139,.25)); box-shadow: inset 0 0 0 2px var(--cyan), 0 4px 0 #1b6c8a; }
.mode:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px var(--cyan), 0 1px 0 #1b6c8a; }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.12); font-size: 22px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 800 21px/1.1 var(--font); }
.m-txt small { font: 600 13px/1.3 var(--font); color: var(--muted); }
.best { margin: 0; font: 700 15px var(--font); color: var(--gold); }
.name-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 14px; background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 2px var(--line); font: 700 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 var(--line); background: rgba(0,0,0,.25); font: 700 15px var(--font); color: #fff; outline: none; user-select: text; -webkit-user-select: text; }
.name-row input:focus { border-color: var(--cyan); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rules span { padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px var(--line); font: 700 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: rgba(255,61,139,.15); box-shadow: inset 0 0 0 2px var(--pink); text-align: center; }
.duel-invite b { font: 800 17px/1.2 var(--font); }
.duel-invite span { font: 600 13px/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; }
.hearts { margin-left: auto; font-size: 22px; letter-spacing: 1px; white-space: nowrap; }
.hearts i { font-style: normal; display: inline-block; }
.hearts i.lost { filter: grayscale(1); opacity: .3; }
.hearts i.pop { animation: bump .5s ease; }
.banner { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); padding: 12px 24px; border-radius: 18px; background: var(--card); box-shadow: inset 0 0 0 2px var(--gold), 0 0 30px rgba(255,210,63,.4); font: 800 26px var(--font); font-style: italic; color: var(--gold); white-space: nowrap; animation: pop .45s cubic-bezier(.2,1.5,.4,1) both; pointer-events: none; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.5); opacity: 0; } }
.feedback { position: absolute; left: 0; right: 0; bottom: 74px; margin: 0 auto; width: max-content; max-width: 100%; padding: 7px 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; }
.feedback.good { box-shadow: inset 0 0 0 2px var(--green); }
.feedback b { color: var(--gold); }
@keyframes pop2 { from { transform: scale(.8); opacity: 0; } }
.typebar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 6px; border-radius: 22px; background: rgba(20,12,60,.88); box-shadow: inset 0 0 0 2px #8b6cff, 0 0 24px rgba(139,108,255,.45); }
.typebar.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
#type { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 0; border-radius: 16px; background: transparent; color: #fff; font: 800 26px var(--font); outline: none; caret-color: var(--cyan); user-select: text; -webkit-user-select: text; }
#type::placeholder { color: rgba(200,194,239,.55); font-weight: 700; font-size: 20px; }
.fire { width: 54px; height: 48px; flex: none; border: 0; border-radius: 14px; background: linear-gradient(180deg, #4be38e, #22b25f); box-shadow: 0 3px 0 #127a3e; color: #fff; font: 800 26px var(--font); }
.fire:active { transform: translateY(2px); box-shadow: 0 1px 0 #127a3e; }

.over { position: absolute; inset: 52px 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: rgba(20,12,60,.92); box-shadow: inset 0 0 0 2px var(--line); text-align: center; animation: pop2 .35s ease both; }
.o-title { font: 800 30px var(--font); font-style: italic; color: var(--gold); }
.o-score { font: 800 46px/1 var(--font); }
.o-ships { font: 700 15px var(--font); color: var(--muted); }
.o-rank { padding: 5px 18px; border-radius: 99px; background: linear-gradient(90deg, #38d6ff, #8b6cff); font: 800 18px var(--font); }
.o-mist { width: 100%; max-width: 340px; padding: 10px 12px; border-radius: 18px; background: rgba(255,77,94,.12); box-shadow: inset 0 0 0 2px rgba(255,77,94,.6); }
.o-mist b { font: 800 15px var(--font); }
.o-mist ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 26vh; overflow-y: auto; }
.o-mist li { display: flex; align-items: center; justify-content: center; gap: 6px; font: 700 15px/1.25 var(--font); }
.o-mist li em { font-style: normal; color: var(--muted); }
.o-mist li b { color: var(--gold); }
.o-mist li button { border: 0; background: rgba(255,255,255,.15); color: #fff; border-radius: 99px; width: 30px; height: 26px; font-size: 14px; padding: 0; }
.duel { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 14px; background: rgba(255,255,255,.08); font: 700 15px var(--font); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(10,5,30,.6); -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 16px/1.4 var(--font); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
