:root {
  --sky: #8fd3ff; --ink: #3a2208; --cream: #fff8e6; --honey: #ffb703; --honey-d: #c77d00; --brown: #5a3a1a; --brown-d: #3d250e;
  --green: #2fbf71; --red: #ef4b4b; --card: rgba(255,248,230,.96); --line: rgba(90,58,26,.25);
  --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: #6cc24a; 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; }
#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: inset 0 0 0 2px var(--line); 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: 700 19px var(--font); }
.btn-honey { background: linear-gradient(180deg, #ffd25a, var(--honey)); color: var(--brown-d); box-shadow: 0 4px 0 var(--honey-d); }
.btn-honey:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--honey-d); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 38px; padding: 0 14px; border-radius: 99px; font: 700 19px var(--font); white-space: nowrap; background: var(--cream); color: var(--brown-d); box-shadow: inset 0 0 0 3px var(--brown), 0 3px 0 var(--brown-d); }
.pill.bump { animation: bump .3s cubic-bezier(.3,1.8,.5,1); }
@keyframes bump { 40% { transform: scale(1.15); } }
.pill-mult { background: #ff7a1a; color: #fff; box-shadow: inset 0 0 0 3px #b34700, 0 3px 0 #b34700; }

/* ---------------------------------------------------------------- powitanie i menu */
.hero-title { margin: -22vh 0 0; text-align: center; font: 700 50px/1 var(--font); color: #fff; text-shadow: 0 4px 0 var(--honey-d), 0 0 22px rgba(255,183,3,.6); -webkit-text-stroke: 2px var(--brown); }
.hero-sub { margin: 12px 0 0; font: 600 20px var(--font); color: var(--brown-d); background: rgba(255,248,230,.85); padding: 4px 16px; border-radius: 99px; }
#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 3px var(--brown), 0 6px 0 var(--brown-d); flex: none; }
.title { margin: 0; font: 700 27px/1.05 var(--font); color: var(--brown-d); text-align: center; }
.demo { display: flex; gap: 10px; }
.demo span { width: 54px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(180deg, #a86b33, #7a4a1f); color: #fff8e6; font: 700 20px var(--font); box-shadow: 0 3px 0 var(--brown-d); }
.lead { margin: 0; text-align: center; font: 500 16px/1.4 var(--font); color: #6b4a2c; }
.lead b { color: var(--brown-d); font-weight: 700; }
.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: var(--brown-d);
  background: linear-gradient(180deg, #ffd25a, var(--honey)); box-shadow: 0 4px 0 var(--honey-d); }
.mode:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--honey-d); }
.m-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.45); font-size: 22px; }
.m-txt { display: flex; flex-direction: column; min-width: 0; }
.m-txt b { font: 700 22px/1.1 var(--font); }
.m-txt small { font: 500 14px/1.3 var(--font); color: #6b4300; }
.best { margin: 0; font: 600 16px var(--font); color: var(--honey-d); }
.name-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; border-radius: 14px; background: rgba(90,58,26,.07); box-shadow: inset 0 0 0 2px var(--line); font: 600 14px var(--font); color: #6b4a2c; }
.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: #fff; font: 600 16px var(--font); color: var(--ink); outline: none; user-select: text; -webkit-user-select: text; }
.name-row input:focus { border-color: var(--honey); }
.rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rules span { padding: 3px 10px; border-radius: 99px; background: rgba(255,183,3,.18); box-shadow: inset 0 0 0 1px rgba(199,125,0,.35); font: 600 13px var(--font); color: #6b4a2c; }
.duel-invite { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px; border-radius: 18px; background: rgba(255,183,3,.18); box-shadow: inset 0 0 0 2px var(--honey); text-align: center; }
.duel-invite b { font: 700 18px/1.2 var(--font); color: var(--brown-d); }
.duel-invite span { font: 500 14px/1.3 var(--font); color: #6b4a2c; }

/* ---------------------------------------------------------------- gra */
#s-play { justify-content: flex-start; }
.hud { position: relative; display: flex; align-items: flex-start; justify-content: space-between; width: 100%; padding-right: 48px; flex: none; height: 64px; }
.hex { position: absolute; left: 50%; top: -2px; transform: translateX(-50%); width: 64px; height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: var(--brown); }
.hex::before { content: ''; position: absolute; inset: 4px; clip-path: inherit; background: linear-gradient(180deg, #ffd25a, var(--honey)); }
.hex b, .hex small { position: relative; color: var(--brown-d); line-height: 1; }
.hex b { font: 700 26px var(--font); }
.hex small { font: 700 10px var(--font); letter-spacing: .5px; }
.hex.low::before { background: linear-gradient(180deg, #ff8a8a, var(--red)); }
.hex.low b, .hex.low small { color: #fff; }
.hex.pen { animation: hexpen .45s; }
@keyframes hexpen { 25%, 75% { transform: translateX(calc(-50% - 6px)); } 50% { transform: translateX(calc(-50% + 6px)); } }
.pill-mult { margin-right: 6px; }

.feedback { position: absolute; left: 0; right: 0; bottom: calc(var(--hive-h, 150px) + 14px); margin: 0 auto; width: max-content; max-width: 100%; padding: 8px 16px; border-radius: 16px; background: var(--cream); box-shadow: inset 0 0 0 3px var(--red), 0 3px 0 rgba(0,0,0,.2); font: 600 18px/1.25 var(--font); text-align: center; pointer-events: none; animation: pop2 .25s ease both; }
.feedback b { color: var(--green); font-weight: 700; }
@keyframes pop2 { from { transform: scale(.8); opacity: 0; } }
.tap-hint { position: absolute; left: 0; right: 0; bottom: calc(var(--hive-h, 150px) + 18px); margin: 0; text-align: center; font: 600 17px var(--font); color: var(--brown-d); pointer-events: none; animation: hintb 1.2s ease-in-out infinite; }
@keyframes hintb { 50% { transform: translateY(5px); } }

#fx { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 3; }
.hives { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; gap: 8px; }
.hive { position: relative; flex: 1; max-width: 140px; aspect-ratio: 1 / 1.06; padding: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.hive svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 4px 0 rgba(58,32,8,.35)); }
.hive .plaque { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%) rotate(-3deg); min-width: 64%; padding: 2px 10px 4px; border-radius: 10px; background: linear-gradient(180deg, #a86b33, #7a4a1f); color: #fff8e6; font: 700 clamp(24px, 8vw, 34px)/1.1 var(--font); box-shadow: 0 3px 0 var(--brown-d), inset 0 0 0 2px rgba(255,255,255,.15); }
.hive:active svg { transform: scale(.96); }
.hive.good .plaque { background: linear-gradient(180deg, #4fdc8f, var(--green)); }
.hive.good { animation: hgood .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes hgood { 40% { transform: scale(1.08); } }
.hive.bad .plaque { background: linear-gradient(180deg, #ff7f7f, var(--red)); }
.hive.bad { animation: hbad .4s; }
@keyframes hbad { 25%, 75% { transform: translateX(-6px) rotate(-2deg); } 50% { transform: translateX(6px) rotate(2deg); } }
.hive.right .plaque { box-shadow: 0 0 0 4px var(--green), 0 3px 0 var(--brown-d); }

.over { position: absolute; inset: 70px 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 3px var(--brown), 0 6px 0 var(--brown-d); text-align: center; animation: pop2 .35s ease both; }
.o-title { font: 700 32px var(--font); color: var(--brown-d); }
.o-score { font: 700 46px/1 var(--font); color: var(--brown-d); }
.o-stats { font: 600 16px var(--font); color: #6b4a2c; }
.o-rank { padding: 5px 18px; border-radius: 99px; background: linear-gradient(180deg, #ffd25a, var(--honey)); color: var(--brown-d); font: 700 18px var(--font); box-shadow: 0 3px 0 var(--honey-d); }
.o-mist { width: 100%; max-width: 340px; padding: 10px 12px; border-radius: 18px; background: rgba(239,75,75,.08); box-shadow: inset 0 0 0 2px rgba(239,75,75,.45); }
.o-mist b { font: 700 16px 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: 500 16px/1.25 var(--font); }
.o-mist li b { color: var(--green); }
.o-mist li s { color: var(--red); text-decoration-thickness: 2px; }
.o-mist li button { border: 0; background: rgba(90,58,26,.12); border-radius: 99px; width: 30px; height: 26px; font-size: 14px; padding: 0; flex: none; }
.duel { display: flex; flex-direction: column; gap: 2px; padding: 6px 14px; border-radius: 14px; background: rgba(90,58,26,.08); font: 600 16px var(--font); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(40,24,8,.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: 22px; background: var(--card); box-shadow: inset 0 0 0 3px var(--brown); text-align: center; }
.modal-title { font: 700 26px var(--font); }
.modal-card p { margin: 0 0 6px; font: 500 17px/1.4 var(--font); color: #6b4a2c; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
