/* BeeSpeaker Tongue Twisters — komiksowo: promienie, kropki, grube kontury, przesunięte cienie. */
:root {
  --navy: #1d1e4f;
  --navy-2: #2a2b6e;
  --yellow: #ffd801;
  --pink: #ff4f9a;
  --pink-2: #ff8ab8;
  --mint: #3ee09a;
  --red: #ff5d5d;
  --ink: #1d1e4f;
  --paper: #fffdf4;
  --display: "Bungee", "Baloo 2", system-ui, sans-serif;
  --body: "Baloo 2", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--navy);
  color: #fff;
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; -webkit-appearance: none; appearance: none; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
}
/* tło: obracające się promienie + kropki rastra */
.rays, .dots { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; }
.rays {
  left: -50%; top: -50%; right: -50%; bottom: -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 79, 154, .16) 0deg 12deg, rgba(255, 79, 154, 0) 12deg 24deg);
  animation: spin 60s linear infinite;
}
.dots {
  background-image: radial-gradient(rgba(255, 255, 255, .09) 2px, transparent 2.5px);
  background-size: 18px 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.screen { position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---------- tytuł ---------- */
.title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 44px;
  line-height: .95;
  text-align: center;
  color: var(--yellow);
  text-shadow: 3px 3px 0 var(--navy), 5px 5px 0 rgba(0, 0, 0, .35);
  letter-spacing: .02em;
}
.title .pink { color: var(--pink); }
.title.small { font-size: 28px; margin: 6px 0 10px; }
.idle { align-items: center; justify-content: center; gap: 18px; }

/* ---------- pszczoła ---------- */
.bee-wrap { width: 112px; height: 112px; margin: 0 auto; }
.bee-wrap.big { width: 180px; height: 180px; }
.bee { width: 100%; height: 100%; animation: bob 2.4s ease-in-out infinite; transform-origin: 50% 80%; }
.bee svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bee .mouth-open { display: none; }
.bee.talk .mouth-open { display: block; animation: talk .18s steps(2) infinite; }
.bee.talk .mouth-closed { display: none; }
.bee .tongue-knot { display: none; }
.bee.tied { animation: shake .5s ease-in-out 2; }
.bee.tied .tongue-knot { display: block; }
.bee.tied .mouth-closed, .bee.tied .mouth-open { display: none; }
.bee.happy { animation: hop .5s ease-out 2; }
.bee.listen { animation: lean 1s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
@keyframes talk { 50% { transform: scaleY(.4); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.05); } 75% { transform: rotate(12deg) scale(1.05); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px) scale(1.06); } }
@keyframes lean { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }

/* ---------- HUD ---------- */
.hud { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.tongues { display: flex; gap: 2px; font-size: 24px; line-height: 1; }
.tongues .lost { filter: grayscale(1); opacity: .35; transform: rotate(-20deg); }
.count { flex: 1; text-align: center; font-family: var(--display); font-size: 16px; color: #cfd0f2; }
.pts {
  font-family: var(--display); font-size: 18px; color: var(--navy); background: var(--yellow);
  padding: 4px 12px; border-radius: 999px; border: 3px solid var(--navy); box-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
  min-width: 64px; text-align: center;
}
.pts.bump { animation: bump .4s ease-out; }
@keyframes bump { 40% { transform: scale(1.25) rotate(-4deg); } }
.icon-btn { background: rgba(255, 255, 255, .1); border: 0; width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }

/* ---------- wybór języka i poziomu ---------- */
.setup { justify-content: center; gap: 10px; padding: 6px 0 4px; overflow-y: auto; }
.label { margin: 6px 0 2px; font-size: 17px; font-weight: 800; text-align: center; color: #fff; }
.langs { display: flex; justify-content: center; gap: 10px; }
.langs .lang-card { flex: 1 1 0; max-width: 170px; }
.lang-card {
  border: 3px solid var(--navy); border-radius: 18px; background: var(--paper); color: var(--ink);
  padding: 12px 6px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .4); transition: transform .12s ease;
}
.lang-card .flag { width: 46px; height: 32px; border-radius: 6px; overflow: hidden; border: 2px solid var(--navy); display: block; }
.lang-card .flag svg { width: 100%; height: 100%; display: block; }
.lang-card b { font-family: var(--display); font-weight: 400; font-size: 15px; }
.lang-card small { font-size: 12.5px; color: #5a5b8a; font-weight: 700; line-height: 1.1; text-align: center; }
.lang-card[aria-checked="true"] { background: var(--yellow); transform: translate(-2px, -2px) rotate(-2deg); box-shadow: 6px 6px 0 var(--pink); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level-btn {
  border: 3px solid var(--navy); border-radius: 999px; background: rgba(255, 255, 255, .12); color: #fff;
  padding: 10px 4px; font-weight: 800; font-size: 15px; display: flex; flex-direction: column; align-items: center; line-height: 1.1;
}
.level-btn span { font-size: 22px; }
.level-btn[aria-checked="true"] { background: var(--pink); box-shadow: 3px 3px 0 var(--navy); }
.go {
  margin: 14px auto 0; display: block; width: 100%; max-width: 380px; border: 4px solid var(--navy); border-radius: 999px;
  padding: 14px 18px; font-family: var(--display); font-size: 24px; color: var(--navy);
  background: linear-gradient(180deg, #ffe85a, var(--yellow) 55%, #f6b60b);
  box-shadow: 0 6px 0 var(--navy), 0 10px 24px rgba(0, 0, 0, .35); animation: pulse 1.6s ease-in-out infinite;
}
.go:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--navy); }
.go.small { font-size: 19px; padding: 11px 16px; margin: 0; animation: none; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.note { margin: 6px 0 0; text-align: center; font-size: 13.5px; color: #cfd0f2; min-height: 1em; }

/* ---------- rozgrywka ---------- */
.play { gap: 8px; padding-top: 2px; }
.main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px; min-height: 0; }
.stage { position: relative; height: 150px; flex: none; }
.stage .bee-wrap { width: 150px; height: 150px; }
.burst {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-6deg);
  padding: 10px 18px; background: var(--yellow); color: var(--navy); font-family: var(--display); font-size: 23px; line-height: 1.05;
  border: 4px solid var(--navy); border-radius: 16px; box-shadow: 6px 6px 0 var(--pink), 0 10px 26px rgba(0, 0, 0, .4);
  max-width: 92%; width: max-content; text-align: center; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1) both; z-index: 3;
}
.burst.bad { background: var(--red); color: #fff; box-shadow: 6px 6px 0 var(--navy), 0 10px 26px rgba(0, 0, 0, .4); }
.burst.good { background: var(--mint); }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.2) rotate(-30deg); opacity: 0; } }

.card {
  position: relative; background: var(--paper); color: var(--ink); border: 4px solid var(--navy); border-radius: 22px;
  padding: 18px 16px 14px; box-shadow: 6px 6px 0 var(--pink), 0 14px 30px rgba(0, 0, 0, .35); text-align: center;
  animation: slide .35s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes slide { from { transform: translateY(26px) rotate(2deg); opacity: 0; } }
.tag {
  position: absolute; top: -15px; left: 50%; transform: translateX(-50%) rotate(-2deg); background: var(--navy); color: var(--yellow);
  font-family: var(--display); font-size: 12.5px; padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.twister { margin: 4px 0 6px; font-size: 26px; font-weight: 800; line-height: 1.2; }
.twister .w { display: inline-block; border-radius: 6px; padding: 0 2px; transition: background .2s ease; }
.twister .w.ok { background: rgba(62, 224, 154, .45); }
.twister .w.close { background: rgba(255, 216, 1, .6); }
.twister .w.miss { background: rgba(255, 93, 93, .45); text-decoration: line-through wavy rgba(255, 93, 93, .9); }
.twister.long { font-size: 22px; }
.twister.xlong { font-size: 19px; }
.meaning { margin: 0; font-size: 14px; color: #5a5b8a; font-weight: 600; line-height: 1.3; }

.listen-row { display: flex; justify-content: center; gap: 10px; }
.pill {
  border: 3px solid var(--navy); border-radius: 999px; background: #fff; color: var(--navy); padding: 8px 16px; font-weight: 800; font-size: 15.5px;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
}
.pill:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0, 0, 0, .35); }
.pill.playing { background: var(--yellow); }
.heard { margin: 0; min-height: 1.4em; text-align: center; font-size: 15.5px; color: #e9e9ff; font-style: italic; line-height: 1.3; }

.mic-zone { margin-top: auto; padding-bottom: 6px; }
.mic {
  width: 100%; border: 4px solid var(--navy); border-radius: 26px; padding: 16px 14px; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(180deg, #ff7fb4, var(--pink)); color: #fff; font-family: var(--display); font-size: 19px; line-height: 1.1;
  box-shadow: 0 6px 0 var(--navy), 0 12px 26px rgba(255, 79, 154, .45);
}
.mic .mic-ico { font-size: 30px; }
.mic:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--navy); }
.mic.listening { background: linear-gradient(180deg, #ffe85a, var(--yellow)); color: var(--navy); animation: rec 1s ease-in-out infinite; }
.mic[disabled] { opacity: .6; }
@keyframes rec { 50% { box-shadow: 0 6px 0 var(--navy), 0 0 0 12px rgba(255, 216, 1, .25); } }

.self { margin-top: auto; text-align: center; }
.self-q { margin: 0 0 8px; font-weight: 800; }
.self-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.self-btn {
  border: 3px solid var(--navy); border-radius: 18px; background: #fff; color: var(--navy); padding: 10px 4px; display: flex; flex-direction: column; align-items: center;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .35); font-size: 14px;
}
.self-btn span { font-size: 30px; line-height: 1.1; }
.self-note { margin: 8px 0 0; font-size: 13px; color: #cfd0f2; }

.result { margin-top: auto; text-align: center; animation: slide .3s ease-out both; }
.acc { display: flex; align-items: center; justify-content: center; gap: 10px; }
.acc-num { font-family: var(--display); font-size: 44px; color: var(--yellow); text-shadow: 3px 3px 0 var(--navy); }
.stars { font-size: 26px; letter-spacing: 2px; }
.times { margin: 2px 0; font-size: 15px; color: #e9e9ff; }
.gain { margin: 0 0 10px; font-weight: 800; font-size: 17px; color: var(--mint); }
.gain.lose { color: var(--red); }
.result-row { display: flex; gap: 10px; align-items: center; }
.result-row .pill { flex: none; }
.result-row .go { flex: 1; }

@media (max-height: 640px) {
  .stage { height: 96px; }
  .stage .bee-wrap, .bee-wrap { width: 96px; height: 96px; }
  .twister { font-size: 22px; }
  .twister.long { font-size: 19px; }
  .twister.xlong { font-size: 17px; }
  .card { padding: 14px 12px 10px; }
  .mic { padding: 12px; font-size: 17px; }
  .acc-num { font-size: 36px; }
  .title { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
