:root {
  --bg: #eef1f6; --card: #ffffff; --ink: #14203d; --muted: #5d6a85; --line: #d9dfea;
  --navy: #1e2d55; --slate: #8fa3c6; --slate-l: #dfe6f1; --slate-d: #6d82a8;
  --yellow: #f0a830; --yellow-l: #fbe3a6; --cream: #fff4d6;
  --green: #2fa864; --green-l: #d9f2e0; --red: #d64545; --red-l: #f9dede; --orange: #f08a30;
  --font: "Nunito", 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: radial-gradient(130% 60% at 50% 0%, #ffffff 0%, var(--bg) 60%, #e3e8f1 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, a { 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(6px, 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; }
.brand { display: flex; align-items: center; gap: 8px; font: 900 20px/1 var(--font); letter-spacing: -.01em; }
.meter-ico { display: flex; flex-direction: column; justify-content: space-between; width: 26px; height: 36px; padding: 1px 0; border-radius: 9px;
  background: linear-gradient(180deg, #4cc97f, #f3c94d 50%, #e2483f); font-size: 12px; line-height: 1; align-items: center; }
.meter-ico i { font-style: normal; }
.sound { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--card); box-shadow: 0 2px 0 var(--line), inset 0 0 0 2px var(--line); font-size: 17px; }
.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 */
.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; max-width: 340px; min-height: 50px; padding: 0 18px; border-radius: 99px; border: 0;
  font: 900 17px var(--font); color: var(--ink); text-decoration: none; }
.btn-navy { background: var(--slate); box-shadow: inset 0 0 0 3px var(--navy), 0 4px 0 var(--navy); }
.btn-navy:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--navy), 0 1px 0 var(--navy); }
.btn-light { background: #d6e5fb; color: var(--navy); box-shadow: inset 0 0 0 3px #3f74d6, 0 4px 0 #a9c2ee; }
.btn-light:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px #3f74d6, 0 1px 0 #a9c2ee; }
.btn-ghost { background: none; min-height: 40px; color: var(--muted); font-size: 15px; text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 14px; border-radius: 99px; font: 900 16px var(--font); white-space: nowrap; }
.pill-round { background: var(--slate); color: var(--ink); }
.pill-time { background: var(--yellow-l); min-width: 82px; justify-content: center; }
.pill-time.danger { background: #ffc9c4; animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.pill-ok { background: var(--green-l); color: #145a33; }
.pill-bad { background: var(--red-l); color: #7a1d1d; }
.pill-pts { background: var(--yellow-l); }
.hearts { font-size: 18px; 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: heart-out .6s ease; }
@keyframes heart-out { 30% { transform: scale(1.5); } }

/* ---------------------------------------------------------------- powitanie i odmowa */
.hero { display: flex; flex-direction: column; align-items: center; gap: 22px; margin-top: -4vh; }
.hero-meter { display: flex; gap: 14px; align-items: stretch; padding: 16px 18px; border-radius: 26px; background: var(--card); box-shadow: 0 10px 30px rgba(30,45,85,.12), inset 0 0 0 2px var(--line); }
.hero-meter .bar { width: 22px; border-radius: 11px; background: linear-gradient(180deg, #4cc97f, #f3c94d 50%, #e2483f); display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 2px 0; }
.hero-meter .bar b { font-size: 18px; transform: translateX(-26px); }
.hero-chips { display: flex; flex-direction: column; gap: 9px; }
.hero-chips span { padding: 8px 16px; border-radius: 99px; background: var(--slate-l); box-shadow: inset 0 0 0 2px var(--navy); font: 800 17px var(--font); }
.hero-chips span:nth-child(2) { transform: translateX(10px) rotate(-2deg); }
.hero-chips em { vertical-align: 2px; }
.hero-sub { margin: 0; text-align: center; font: 800 16px var(--font); color: var(--muted); max-width: 320px; }
.nope { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 320px; text-align: center; }
.nope-ico { font-size: 64px; }
.nope-title { font: 900 22px var(--font); }
.nope p { margin: 0 0 8px; font: 700 16px/1.4 var(--font); color: var(--muted); }

/* ---------------------------------------------------------------- menu */
#s-menu { gap: 10px; justify-content: flex-start; overflow-y: auto; overflow-x: hidden; padding: 6px 0 10px; }
#s-menu::before, #s-menu::after { content: ''; flex: 1 1 0; }
.menu-meter { display: flex; align-items: center; gap: 8px; font-size: 26px; flex: none; }
.menu-meter i { width: 150px; height: 14px; border-radius: 7px; background: linear-gradient(90deg, #4cc97f, #f3c94d 50%, #e2483f); }
.title { margin: 0; font: 900 32px/1 var(--font); letter-spacing: .01em; text-align: center; }
.lead { margin: 0 0 4px; max-width: 360px; text-align: center; font: 600 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: 68px; padding: 9px 16px; border-radius: 22px; border: 0; text-align: left; color: var(--ink); flex: none;
  background: var(--slate); box-shadow: inset 0 0 0 3px var(--navy), 0 5px 0 var(--navy); }
.mode:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--navy), 0 2px 0 var(--navy); }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,.7); font-size: 24px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 900 20px/1.15 var(--font); }
.m-txt small { font: 700 13px/1.3 var(--font); color: #2b3a5e; }
.best { margin: 0; font: 800 14px var(--font); color: var(--muted); }
.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: 800 13px var(--font); color: var(--muted); flex: none; }
.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); font: 800 15px var(--font); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; }
.name-row input:focus { border-color: var(--navy); }
.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: 800 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(--yellow), 0 5px 0 #c98a1e; display: flex; flex-direction: column; gap: 10px; flex: none; }
.di-top { display: flex; align-items: center; gap: 12px; }
.di-ava { width: 50px; height: 50px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--yellow-l); font-size: 24px; }
.di-top b { display: block; font: 900 16px/1.2 var(--font); }
.di-top span { font: 700 13px/1.3 var(--font); color: var(--muted); }
.duel-invite .btn { max-width: none; }

/* ---------------------------------------------------------------- runda */
#s-play { justify-content: flex-start; gap: 6px; }
.hud { display: flex; align-items: center; justify-content: space-between; width: 100%; flex: none; }
.timebar { width: 100%; height: 6px; border-radius: 3px; background: #dde3ee; overflow: hidden; flex: none; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--yellow); transform-origin: left; }
.order, .verdict, .quiz { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; flex: 1; min-height: 0; padding-top: 4px; }
.situation { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 10px 16px 12px; border-radius: 20px; text-align: center; flex: none;
  background: var(--yellow-l); box-shadow: inset 0 0 0 3px var(--yellow); animation: pop-in .35s cubic-bezier(.2,1.4,.4,1) both; }
.situation::after { content: ''; position: absolute; left: 30px; bottom: -12px; border: 12px solid transparent; border-top-color: var(--yellow); border-bottom: 0; }
.sit-emoji { font-size: 28px; letter-spacing: 4px; }
.sit-txt { font: 900 16.5px/1.25 var(--font); }
@keyframes pop-in { from { transform: scale(.9); opacity: 0; } }
.order-lbl { margin: 6px 0 0; font: 800 15px var(--font); color: var(--muted); flex: none; }
.meter { display: flex; gap: 12px; width: 100%; flex: none; }
.scale { position: relative; width: 22px; flex: none; display: flex; flex-direction: column; align-items: center; }
.scale b { font-size: 18px; line-height: 1; }
.scale i { flex: 1; width: 12px; margin: 4px 0; border-radius: 6px; background: linear-gradient(180deg, #4cc97f, #f3c94d 50%, #e2483f); }
.scale.down i { background: linear-gradient(180deg, #e2483f, #f3c94d 50%, #4cc97f); }
.chips { position: relative; flex: 1; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chip { position: relative; display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 6px 16px; border-radius: 99px; background: var(--slate-l); box-shadow: inset 0 0 0 2.5px var(--navy), 0 3px 0 rgba(30,45,85,.25);
  font: 900 17.5px/1.15 var(--font); color: var(--ink); touch-action: none; cursor: grab; transition: transform .22s cubic-bezier(.2,1,.4,1), background .15s; border: 0; text-align: left; width: 100%; }
.flag { display: inline-block; padding: 2px 6px; border-radius: 6px; font: 900 11px/1.2 var(--font); font-style: normal; letter-spacing: .04em; vertical-align: 2px; color: #fff; }
.flag.uk { background: #012169; }
.flag.us { background: #b22234; }
.mini-flag { display: inline-block; width: 1.3em; height: .87em; border-radius: 3px; vertical-align: -1px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.chip.dragging { z-index: 3; background: var(--slate); transition: background .15s; cursor: grabbing; box-shadow: inset 0 0 0 3px var(--navy), 0 10px 22px rgba(30,45,85,.3); }
.chip.sel { background: #ffe7a3; box-shadow: inset 0 0 0 3px var(--yellow), 0 3px 0 #c98a1e; }
.chip.flip { transition: transform .5s cubic-bezier(.3,1.2,.4,1); }
.chip:focus-visible { outline: 3px solid #3f74d6; outline-offset: 2px; }
.drag-hint { margin: 0; font: 700 12px var(--font); color: var(--muted); flex: none; }
#check { flex: none; margin-top: auto; }

/* wynik rundy */
.v-pills { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 6px; flex: none; }
.v-msg { flex: 1; text-align: center; font: 900 14px/1.2 var(--font); }
.v-msg.bad { color: var(--red); }
.v-title { margin: 2px 0 0; font: 900 17px var(--font); flex: none; }
.rows { display: flex; flex-direction: column; gap: 7px; width: 100%; margin: 0; padding: 0; list-style: none; flex: 1; min-height: 0; overflow-y: auto; }
.row { position: relative; display: flex; align-items: center; gap: 8px; padding: 7px 12px 7px 20px; border-radius: 16px; background: var(--green-l); box-shadow: inset 0 0 0 2.5px var(--green); cursor: pointer; flex: none; animation: pop-in .3s ease both; }
.row.bad { background: var(--red-l); box-shadow: inset 0 0 0 2.5px var(--red); }
.row .lvl { position: absolute; left: 0; top: 0; bottom: 0; width: 9px; border-radius: 16px 0 0 16px; }
.row .r-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .r-word { font: 900 17px/1.2 var(--font); }
.row .r-word small { font-size: 12px; font-weight: 800; color: var(--muted); }
.row .r-sub { font: 700 13px/1.3 var(--font); color: #34405c; }
.row .r-ex { display: none; margin-top: 3px; font: 700 13px/1.3 var(--font); color: var(--navy); font-style: italic; }
.row.open .r-ex { display: block; }
.row .r-mark { font: 900 20px var(--font); }
.row.speaking { outline: 3px solid #3f74d6; outline-offset: 1px; }
.v-btns { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; flex: none; }
.v-btns .btn { min-height: 46px; }

/* quiz */
.q-title { margin: 6px 0 0; font: 900 18px var(--font); text-align: center; }
.q-card { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 20px 16px; border-radius: 24px; background: var(--card); box-shadow: inset 0 0 0 3px var(--navy), 0 5px 0 var(--navy); animation: pop-in .35s cubic-bezier(.2,1.4,.4,1) both; }
.q-word { font: 900 34px/1.1 var(--font); text-align: center; }
.q-mean { font: 800 17px/1.3 var(--font); color: var(--muted); text-align: center; }
.q-ask { margin: 4px 0 0; font: 800 16px var(--font); color: var(--muted); }
.q-btns { display: flex; gap: 14px; width: 100%; justify-content: center; }
.q-btn { flex: 1; max-width: 150px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 22px; border: 0; background: var(--card); color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--slate-d), 0 5px 0 var(--slate-d); }
.q-flag { display: block; width: 64px; height: 43px; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px rgba(0,0,0,.12); margin-bottom: 4px; }
.q-flag svg { display: block; width: 100%; height: 100%; }
.q-btn b { font: 900 18px var(--font); }
.q-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 3px var(--slate-d), 0 2px 0 var(--slate-d); }
.q-btn.right { background: var(--green-l); box-shadow: inset 0 0 0 3px var(--green), 0 5px 0 var(--green); }
.q-btn.wrong { background: var(--red-l); box-shadow: inset 0 0 0 3px var(--red), 0 5px 0 var(--red); }
.q-res { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; margin-top: auto; }
.q-head { font: 900 19px var(--font); }
.q-line { font: 800 15px/1.35 var(--font); text-align: center; color: #34405c; }
.q-line:empty { display: none; }
.floats { position: fixed; inset: 0; pointer-events: none; z-index: 35; }
.float { position: absolute; padding: 5px 13px; border-radius: 99px; font: 900 17px var(--font); white-space: nowrap; transform: translate(-50%, -50%); animation: float-up 1.1s ease-out forwards; background: var(--yellow-l); }
.float.bad { background: var(--red-l); color: #7a1d1d; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -150%); } }

/* ---------------------------------------------------------------- finał */
#s-final { gap: 10px; }
.f-head { margin: 0; padding: 8px 18px; border-radius: 99px; background: var(--slate-l); font: 900 18px var(--font); }
.persona { position: relative; width: 170px; height: 170px; display: grid; place-items: center; margin: 6px 0; }
.persona .ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 200deg, #f0a830, #e2483f, #f0a830); padding: 10px;
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 67%); mask: radial-gradient(circle, transparent 66%, #000 67%); }
.persona::before { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: #f8dce5; }
.p-emoji { position: relative; font-size: 84px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.persona .sp { position: absolute; font-style: normal; font-size: 24px; }
.persona .s1 { left: -10px; top: 18px; } .persona .s2 { right: -12px; top: 6px; font-size: 30px; } .persona .s3 { right: 2px; bottom: 16px; }
.ribbon { position: relative; padding: 8px 30px; background: var(--yellow-l); font: 900 22px var(--font); text-align: center;
  clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%); }
.f-level { margin: 2px 0 0; font: 800 15px var(--font); color: var(--muted); }
.dots { display: flex; gap: 7px; }
.dots i { width: 28px; height: 10px; border-radius: 5px; background: #d9dfea; }
.dots i.on { background: linear-gradient(90deg, #4cc97f, #2fa864); }
.dots i.on.l3 { background: #f3c94d; } .dots i.on.l4 { background: var(--orange); } .dots i.on.l5 { background: var(--red); }
.duel { width: 100%; max-width: 330px; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 12px; border-radius: 20px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }
.duel-head { font: 900 16px var(--font); }
.duel-row { display: flex; align-items: center; justify-content: space-around; width: 100%; }
.duel-p { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 90px; padding-top: 16px; }
.duel-p b { font: 800 14px var(--font); color: var(--muted); }
.duel-p strong { font: 900 30px var(--font); }
.crown { position: absolute; top: -6px; font-size: 20px; line-height: 1; opacity: 0; }
.crown.on { opacity: 1; }
.vs { font: 900 16px var(--font); color: var(--red); }
.duel-out { font: 900 15px var(--font); }
.final-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.final-stats span { padding: 6px 12px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font: 800 14px var(--font); }

/* ---------------------------------------------------------------- okna */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(20,32,61,.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px 20px 14px; border-radius: 24px; background: var(--card); text-align: center; animation: pop-in .35s cubic-bezier(.2,1.4,.4,1) both; }
.modal-title { font: 900 22px var(--font); }
.modal-card p { margin: 0 0 6px; font: 700 15px/1.4 var(--font); color: #34405c; }

/* niskie ekrany */
@media (max-height: 660px) {
  .top { height: 40px; }
  .situation { padding: 8px 12px 10px; }
  .sit-emoji { font-size: 22px; }
  .sit-txt { font-size: 15px; }
  .chip { min-height: 40px; font-size: 16px; }
  .chips { gap: 6px; }
  .row { padding: 5px 10px 5px 18px; }
  .row .r-word { font-size: 15.5px; }
  .row .r-sub { font-size: 12px; }
  .btn { min-height: 44px; font-size: 16px; }
  .v-btns .btn { min-height: 42px; }
  .mode { min-height: 58px; }
  .title { font-size: 27px; }
  .lead { font-size: 14px; }
  .persona { width: 140px; height: 140px; }
  .p-emoji { font-size: 66px; }
  .q-word { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
