/* BeeSpeaker Word Crush — neonowy ul: miodowe kafelki, fioletowa noc, soczyste animacje.
   Mobile-first: 360×640 bez przewijania. Rozmiar kafelka liczy JS → --tile. */

:root {
  --bg0: #190a2e;
  --bg1: #2d1259;
  --bg2: #3d1270;
  --honey: #ffc61e;
  --honey2: #ff8a1a;
  --ink: #2a1004;
  --pick: #ff3d8b;
  --pick2: #ff7ab8;
  --good: #38e8a0;
  --bad: #ff5a6e;
  --paper: #fff5e0;
  --muted: #d9c2f5;
  --line: rgba(255, 198, 30, .28);
  --tile: 48px;
  --gap: 6px;
  --radius: 14px;
  --font: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* własne `display` w regułach niżej wygrywa z [hidden] z przeglądarki — bez tego ukryte sekcje byłyby widoczne */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: #fff;
  background: radial-gradient(130% 90% at 50% 0%, var(--bg2) 0%, var(--bg1) 45%, var(--bg0) 100%);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* delikatny plaster miodu w tle */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  pointer-events: none;
  opacity: .16;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255, 198, 30, .5) 0 2px, transparent 3px),
    radial-gradient(circle at 50% 50%, rgba(255, 198, 30, .5) 0 2px, transparent 3px);
  background-size: 54px 94px, 54px 94px;
  background-position: 0 0, 27px 47px;
}

.app {
  position: relative;
  width: 100%;
  max-width: 560px;        /* na desktopie kolumna zamiast rozciągniętego na całą szerokość HUD-u */
  margin-inline: auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top) + 8px)
    calc(env(safe-area-inset-right) + 12px)
    calc(env(safe-area-inset-bottom) + 8px)
    calc(env(safe-area-inset-left) + 12px);
}

.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen:not([hidden]) { display: flex; }

/* ---------- ekran bezczynności ---------- */

.idle { align-items: center; justify-content: center; gap: 24px; }

.idle-hive { display: flex; gap: 10px; }

.idle-hive span {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: linear-gradient(170deg, var(--t-hi), var(--t-mid) 46%, var(--t-lo));
  color: var(--t-ink);
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 6px 0 var(--t-edge), 0 12px 24px rgba(0, 0, 0, .4);
  animation: bob 2.4s ease-in-out infinite;
}

/* te same kolory co kafelki na planszy: W O R D */
.idle-hive span:nth-child(1) { --t-hi:#ffdcc0; --t-mid:#ff8d40; --t-lo:#e85f14; --t-edge:#a4420a; --t-ink:#4d1d00; --t-line:rgba(110,45,0,.3); }
.idle-hive span:nth-child(2) { --t-hi:#fff3bd; --t-mid:#ffc61e; --t-lo:#ff9d0a; --t-edge:#bf6f00; --t-ink:#4a2a00; --t-line:rgba(120,70,0,.3); }
.idle-hive span:nth-child(3) { --t-hi:#cfecff; --t-mid:#36a8ff; --t-lo:#0d74d6; --t-edge:#064f95; --t-ink:#fff;    --t-line:rgba(4,40,80,.34); }
.idle-hive span:nth-child(4) { --t-hi:#d4f8c7; --t-mid:#52d44f; --t-lo:#17a033; --t-edge:#0e7124; --t-ink:#0c3b11; --t-line:rgba(10,70,20,.3); }
.idle-hive span:nth-child(2) { animation-delay: .15s; }
.idle-hive span:nth-child(3) { animation-delay: .3s; }
.idle-hive span:nth-child(4) { animation-delay: .45s; }

@keyframes bob { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }

.idle-text { color: var(--muted); font-size: 16px; margin: 0; text-align: center; }


/* ---------- wybór trybu gry ---------- */

.modes { align-items: center; justify-content: center; gap: 8px; padding: 10px 2px; }

.modes-title {
  margin: 0 0 14px;
  font-size: clamp(22px, 6.4vw, 30px);
  font-weight: 700;
  text-align: center;
  background: linear-gradient(180deg, #fff3bd, var(--honey) 45%, var(--honey2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #a85d06) drop-shadow(0 0 24px rgba(255, 170, 30, .5));
  animation: cardIn .5s cubic-bezier(.2, 1.3, .4, 1) backwards;
}

.mode-grid { display: grid; gap: 12px; width: 100%; max-width: 420px; }

.mode {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 22px;
  background: linear-gradient(170deg, var(--t-hi), var(--t-mid) 48%, var(--t-lo));
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 6px 0 var(--t-edge), 0 10px 20px rgba(0, 0, 0, .45);
  color: var(--t-ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease, opacity .25s ease;
  animation: cardIn .52s cubic-bezier(.2, 1.3, .4, 1) backwards;
}

.mode::before {
  content: "";
  position: absolute;
  top: 6%; left: 8%;
  width: 52%; height: 30%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.mode:active { transform: translateY(4px); box-shadow: 0 0 0 2px var(--t-line) inset, 0 2px 0 var(--t-edge); }

.mode-classic { --t-hi:#cfecff; --t-mid:#36a8ff; --t-lo:#0d74d6; --t-edge:#064f95; --t-ink:#fff;    --t-line:rgba(4,40,80,.34); }
.mode-voice   { --t-hi:#fff3bd; --t-mid:#ffc61e; --t-lo:#ff9d0a; --t-edge:#bf6f00; --t-ink:#4a2a00; --t-line:rgba(120,70,0,.3); }

.mode-off { filter: grayscale(.7); opacity: .5; cursor: default; }
.mode-off:active { transform: none; }

.mode-icon { flex: none; font-size: 34px; position: relative; z-index: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.mode-text { min-width: 0; position: relative; z-index: 1; }
.mode-name { display: block; font-size: 19px; font-weight: 700; }
.mode-desc { display: block; font-size: 13.5px; line-height: 1.35; opacity: .85; }

.modes.picking .mode { pointer-events: none; opacity: .3; transform: scale(.94); }
.modes.picking .mode.chosen { opacity: 1; animation: chosenPop .42s cubic-bezier(.2, 1.6, .35, 1); }

@keyframes chosenPop {
  0% { transform: scale(1) }
  35% { transform: scale(1.06) }
  100% { transform: scale(1) }
}

@keyframes cardIn {
  from { transform: translateY(30px) scale(.9); opacity: 0 }
  to { transform: none; opacity: 1 }
}

/* ---------- tryb głosowy ---------- */

.voicehint {
  flex: none;
  margin: 0 0 4px;
  min-height: 20px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}

.voicehint.good { color: var(--good); }
.voicehint.bad { color: var(--bad); }

.tool-mic { --t-hi:#ffd0e8; --t-mid:#ff3d8b; --t-lo:#c4166c; --t-edge:#8d0b4c; --t-ink:#fff; --t-line:rgba(110,0,55,.4); }

.tool-mic.on { animation: micOn 1.2s ease-in-out infinite; }
.tool-mic.live .tool-icon { animation: micPulse .8s ease-in-out infinite; }

@keyframes micOn {
  0%, 100% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 16px rgba(255, 61, 139, .6) }
  50% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 34px rgba(255, 61, 139, 1) }
}
@keyframes micPulse {
  0%, 100% { transform: scale(1) }
  50% { transform: scale(1.25) }
}

/* w trybie głosowym mikrofon jest główny, reszta zwija się do ikon */
.app.voice .tools .tool-text { display: none; }
.app.voice #btnHint, .app.voice #btnShuffle { flex: 0 0 48px; padding: 8px 0; }
.app.voice .tool-mic { flex: 1 1 auto; }
.app.voice .tool-mic .tool-text { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .mode, .modes-title, .tool-mic, .tool-mic .tool-icon { animation: none; }
}

/* ---------- arkusz z legendą bonusów ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 3, 22, .72);
  animation: fade .2s ease;
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet-card {
  width: 100%;
  max-width: 420px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  border: 2px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(160deg, var(--bg2), var(--bg1) 70%);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .5);
  animation: sheetUp .28s cubic-bezier(.2, 1.2, .4, 1);
}

@keyframes sheetUp { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }

.sheet-title { margin: 0 0 10px; font-size: 20px; font-weight: 700; color: var(--honey); }

.howto-line { margin: 0 0 8px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.howto-earn { margin: 14px 0 10px; font-size: 14px; font-weight: 600; color: #fff; }

.howto-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }

.howto-list li {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--paper);
}

.pw {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  font-size: 19px;
  background: linear-gradient(170deg, var(--t-hi), var(--t-mid) 46%, var(--t-lo));
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 3px 0 var(--t-edge);
}

.pw-bee   { --t-hi:#fffbe0; --t-mid:#ffd93d; --t-lo:#ffab00; --t-edge:#b06f00; --t-line:rgba(120,70,0,.34); }
.pw-bomb  { --t-hi:#ffd0b8; --t-mid:#ff6b35; --t-lo:#d82e12; --t-edge:#95200a; --t-line:rgba(90,20,0,.38); }
.pw-bolt  { --t-hi:#d8fbff; --t-mid:#36e6ff; --t-lo:#00a8d6; --t-edge:#00708f; --t-line:rgba(0,60,80,.34); }
.pw-honey { --t-hi:#fff3bd; --t-mid:#ffc61e; --t-lo:#ff9d0a; --t-edge:#bf6f00; --t-line:rgba(120,70,0,.3); }
.pw-neon  { --t-hi:#ffd1f5; --t-mid:#c04cff; --t-lo:#6a00d6; --t-edge:#3d0080; --t-line:rgba(60,0,110,.4); }

.pw-text { min-width: 0; }

.sheet-close {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(140deg, var(--honey), var(--honey2));
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 #bf6f00;
}

.sheet-close:active { transform: translateY(3px); box-shadow: 0 2px 0 #bf6f00; }

/* ---------- konfetti i emoji ---------- */

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 60;
}

.confetti {
  position: absolute;
  top: -40px;
  animation: fall linear forwards;
}

@keyframes fall {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1 }
  to { transform: translate(var(--drift), 108dvh) rotate(var(--rot)); opacity: .85 }
}

.pop-emoji {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
  animation: popOut .95s cubic-bezier(.2, .9, .3, 1) forwards;
}

@keyframes popOut {
  from { transform: translate(-50%, -50%) scale(.3) rotate(0deg); opacity: 0 }
  25% { opacity: 1 }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.1) rotate(var(--rot)); opacity: 0 }
}

/* ---------- HUD ---------- */

.hud {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 6px;
}

.hud-cell { display: flex; flex-direction: column; line-height: 1.05; }
.hud-cell:nth-child(3) { align-items: flex-end; }
.hud-cell.timer { align-items: center; }

.hud-label {
  font-size: 10px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .85;
}

.hud-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer .hud-value { color: var(--honey); }
.timer.low .hud-value { color: var(--bad); animation: pulse .9s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { transform: scale(1) } 50% { transform: scale(1.12) } }

.timebar {
  flex: none;
  height: 5px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .35);
  overflow: hidden;
  margin-bottom: 6px;
}

.timebar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--honey2), var(--honey));
  transform-origin: left center;
  transition: transform .25s linear, background .3s ease;
}

.timebar i.low { background: linear-gradient(90deg, #ff2d4b, var(--bad)); }

/* ---------- pasek bieżącego słowa ---------- */

.wordbar {
  flex: none;
  position: relative;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

.current {
  font-size: clamp(20px, 6.4vw, 28px);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
  min-height: 1em;
  transition: color .12s ease, transform .12s ease;
}

.current.ok { color: var(--good); transform: scale(1.1); }
.current.no { color: var(--bad); }

/* komunikat (np. „za krótkie”) — zdanie, więc bez wersalików i rozstrzelenia */
.current.msg {
  font-size: clamp(14px, 4.2vw, 17px);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.current .pts { font-size: .6em; color: var(--honey); margin-left: .4em; }

/* neon: „osnd → DONS” — gracz od razu widzi, co mu wyszło z przestawionych liter */
.current.swap { animation: swapPop .45s cubic-bezier(.3,1.7,.5,1); }
.swap-from { opacity: .55; text-decoration: line-through; text-decoration-thickness: .08em; }
.swap-arrow { color: #fff; opacity: .7; font-size: .75em; margin: 0 .34em; }
.swap-to {
  color: #fff;
  text-shadow: 0 0 10px #ff00aa, 0 0 22px #00c8ff;
  animation: neonText 1.1s linear infinite;
}
@keyframes swapPop {
  0% { transform: scale(.7); opacity: 0; }
  60% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1.1); opacity: 1; }
}

.combo {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 99px;
  background: linear-gradient(140deg, var(--pick), #c2186a);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 0 18px rgba(255, 61, 139, .65);
  animation: comboPop .3s ease;
}

@keyframes comboPop { from { transform: translateY(-50%) scale(.4) } to { transform: translateY(-50%) scale(1) } }

/* ---------- plansza ---------- */

.board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
}

.board {
  position: relative;
  touch-action: none;
}

.trace { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; overflow: visible; }

.trace polyline {
  fill: none;
  stroke: url(#traceGrad);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
  filter: drop-shadow(0 0 10px rgba(255, 61, 139, .85));
}

/* Kafelki jak cukierki: każda grupa liter ma swój kolor, połysk i „papierowy” kontur.
   Samogłoski są miodowe (to one wiążą słowa i jest ich najwięcej), reszta to tęcza. */
.tile {
  position: absolute;
  width: var(--tile);
  height: var(--tile);
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(170deg, var(--t-hi), var(--t-mid) 46%, var(--t-lo));
  color: var(--t-ink);
  font-size: calc(var(--tile) * .46);
  font-weight: 700;
  text-transform: uppercase;
  box-shadow:
    0 0 0 2px var(--t-line) inset,
    0 5px 0 var(--t-edge),
    0 9px 16px rgba(0, 0, 0, .4);
  transition: transform .26s cubic-bezier(.28, 1.3, .5, 1), opacity .18s ease, box-shadow .14s ease;
  will-change: transform;
  z-index: 1;
  overflow: hidden;
}

/* połysk — eliptyczne światło u góry, jak na lukrowanym cukierku */
.tile::before {
  content: "";
  position: absolute;
  top: 6%;
  left: 12%;
  width: 56%;
  height: 34%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.tile > span { position: relative; z-index: 1; }

.tile .val {
  position: absolute;
  right: 6%;
  bottom: 2%;
  font-size: calc(var(--tile) * .2);
  font-weight: 600;
  opacity: .55;
}

.g-v { --t-hi:#fff3bd; --t-mid:#ffc61e; --t-lo:#ff9d0a; --t-edge:#bf6f00; --t-ink:#4a2a00; --t-line:rgba(120,70,0,.3); }
.g-c1 { --t-hi:#cfecff; --t-mid:#36a8ff; --t-lo:#0d74d6; --t-edge:#064f95; --t-ink:#ffffff; --t-line:rgba(4,40,80,.34); }
.g-c2 { --t-hi:#d4f8c7; --t-mid:#52d44f; --t-lo:#17a033; --t-edge:#0e7124; --t-ink:#0c3b11; --t-line:rgba(10,70,20,.3); }
.g-c3 { --t-hi:#ecd4ff; --t-mid:#ab5bf7; --t-lo:#7726d4; --t-edge:#53179c; --t-ink:#ffffff; --t-line:rgba(45,5,90,.34); }
.g-c4 { --t-hi:#ffdcc0; --t-mid:#ff8d40; --t-lo:#e85f14; --t-edge:#a4420a; --t-ink:#4d1d00; --t-line:rgba(110,45,0,.3); }
.g-c5 { --t-hi:#ffccd2; --t-mid:#ff5263; --t-lo:#d61a2e; --t-edge:#980e20; --t-ink:#ffffff; --t-line:rgba(90,5,15,.34); }

/* bonusy */
.tile.bee  { --t-hi:#fffbe0; --t-mid:#ffd93d; --t-lo:#ffab00; --t-edge:#b06f00; --t-ink:#3d2200; --t-line:rgba(120,70,0,.34); animation: beeGlow 1.5s ease-in-out infinite; }
.tile.bomb { --t-hi:#ffd0b8; --t-mid:#ff6b35; --t-lo:#d82e12; --t-edge:#95200a; --t-ink:#ffffff; --t-line:rgba(90,20,0,.38); animation: bombPulse 1.2s ease-in-out infinite; }
.tile.bolt { --t-hi:#d8fbff; --t-mid:#36e6ff; --t-lo:#00a8d6; --t-edge:#00708f; --t-ink:#00303d; --t-line:rgba(0,60,80,.34); animation: boltGlow 1.3s ease-in-out infinite; }

@keyframes beeGlow {
  0%, 100% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 16px rgba(255, 220, 60, .65) }
  50% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 30px rgba(255, 220, 60, 1) }
}
@keyframes bombPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 16px rgba(255, 90, 40, .6) }
  50% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 30px rgba(255, 90, 40, 1) }
}
@keyframes boltGlow {
  0%, 100% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 16px rgba(60, 230, 255, .6) }
  50% { box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 32px rgba(60, 230, 255, 1) }
}

/* zaznaczenie wygrywa z kolorem grupy — dlatego stoi po nich */
.tile.sel {
  --t-hi: #ffc2e0; --t-mid: var(--pick); --t-lo: #c4166c; --t-edge: #8d0b4c; --t-ink: #fff; --t-line: rgba(110,0,55,.4);
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 0 26px rgba(255, 61, 139, .95);
  z-index: 4;
  animation: none;
}

/* .app.blast/.frenzy/.neon .tile mają własne animacje i wyższą specyficzność niż sama
   .tile.hintme — bez tego wzmocnienia podpowiedź w tych trybach jest zupełnie niewidoczna. */
.app .tile.hintme { animation: hintPop .62s ease-in-out 3; }

@keyframes hintPop {
  0%, 100% { transform: translate(var(--x), var(--y)) scale(1) }
  50% { transform: translate(var(--x), var(--y)) scale(1.18) }
}

.tile.pop {
  opacity: 0;
  z-index: 5;
  transition: transform .34s cubic-bezier(.25, .9, .35, 1), opacity .3s ease;
}

/* kafelek w locie przy przetasowaniu */
.tile.flying { z-index: 3; }
.tile.flying .ch { animation: flySpin .56s ease-in-out; }

@keyframes flySpin {
  0% { transform: scale(1) rotate(0) }
  45% { transform: scale(1.25) rotate(14deg) }
  100% { transform: scale(1) rotate(0) }
}

/* bonusy muszą żyć, nawet gdy tylko leżą na planszy */
.tile.bee .ch { display: block; animation: wobbleBee 1.25s ease-in-out infinite; }
.tile.bomb .ch { display: block; animation: wobbleBomb .72s ease-in-out infinite; }
.tile.bolt .ch { display: block; animation: wobbleBolt .9s steps(1, end) infinite; }

@keyframes wobbleBee {
  0%, 100% { transform: translateY(0) rotate(-9deg) }
  50% { transform: translateY(-4px) rotate(9deg) scale(1.1) }
}
@keyframes wobbleBomb {
  0%, 100% { transform: scale(1) }
  40% { transform: scale(1.26) rotate(-6deg) }
  70% { transform: scale(.94) rotate(5deg) }
}
@keyframes wobbleBolt {
  0%, 60%, 100% { transform: scale(1.12) rotate(-6deg); opacity: 1 }
  30% { transform: scale(.88) rotate(8deg); opacity: .55 }
  80% { transform: scale(1.3) rotate(0); opacity: 1 }
}

/* przelatujący połysk po kafelku bonusowym */
.tile.bee::after, .tile.bomb::after, .tile.bolt::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 36%, rgba(255, 255, 255, .6) 50%, transparent 64%);
  transform: translateX(-130%);
  animation: shine 2.4s ease-in-out infinite;
}

.tile.bomb::after { animation-duration: 1.7s; }
.tile.bolt::after { animation-duration: 1.4s; }

@keyframes shine {
  0% { transform: translateX(-130%) }
  55%, 100% { transform: translateX(130%) }
}

/* ---------- wybuchy ---------- */

.beam {
  position: absolute;
  pointer-events: none;
  z-index: 8;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(60, 230, 255, 0), #d8fbff 18%, #36e6ff 50%, #d8fbff 82%, rgba(60, 230, 255, 0));
  box-shadow: 0 0 26px 8px rgba(60, 230, 255, .85);
}

.beam-h { left: -8%; width: 116%; animation: beamH .6s cubic-bezier(.2, .9, .3, 1) forwards; }
.beam-v {
  top: -8%;
  height: 116%;
  background: linear-gradient(180deg, rgba(60, 230, 255, 0), #d8fbff 18%, #36e6ff 50%, #d8fbff 82%, rgba(60, 230, 255, 0));
  animation: beamV .6s cubic-bezier(.2, .9, .3, 1) forwards;
}

@keyframes beamH {
  0% { transform: scaleX(0) scaleY(.2); opacity: 0 }
  25% { transform: scaleX(1) scaleY(1.15); opacity: 1 }
  100% { transform: scaleX(1) scaleY(.1); opacity: 0 }
}
@keyframes beamV {
  0% { transform: scaleY(0) scaleX(.2); opacity: 0 }
  25% { transform: scaleY(1) scaleX(1.15); opacity: 1 }
  100% { transform: scaleY(1) scaleX(.1); opacity: 0 }
}

.shockwave {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 5px solid #ffb86b;
  pointer-events: none;
  z-index: 8;
  animation: shock .6s cubic-bezier(.15, .8, .3, 1) forwards;
}

@keyframes shock {
  0% { transform: scale(.3); opacity: 1; border-color: #fff3bd }
  100% { transform: scale(13); opacity: 0; border-color: #ff5a1a }
}

.shockwave.huge { border-width: 7px; animation-name: shockHuge; animation-duration: .75s; }

@keyframes shockHuge {
  0% { transform: scale(.3); opacity: 1; border-color: #fff }
  100% { transform: scale(24); opacity: 0; border-color: #ff2d00 }
}

/* ---------- trzęsienie ekranu ---------- */

.shake { animation: shakeA .3s ease-in-out; }
.shake-hard { animation: shakeB .46s ease-in-out; }

@keyframes shakeA {
  0%, 100% { transform: translate(0, 0) }
  20% { transform: translate(-5px, 3px) }
  40% { transform: translate(5px, -3px) }
  60% { transform: translate(-4px, -2px) }
  80% { transform: translate(4px, 2px) }
}
@keyframes shakeB {
  0%, 100% { transform: translate(0, 0) rotate(0) }
  15% { transform: translate(-10px, 6px) rotate(-.7deg) }
  30% { transform: translate(10px, -6px) rotate(.7deg) }
  45% { transform: translate(-8px, -5px) rotate(-.5deg) }
  60% { transform: translate(8px, 5px) rotate(.5deg) }
  80% { transform: translate(-4px, 2px) rotate(0) }
}

/* ---------- deszcz emoji pasujących do słowa ---------- */

.rain-emoji {
  position: absolute;
  pointer-events: none;
  animation: rainUp 2.1s cubic-bezier(.2, .7, .3, 1) forwards;
}

@keyframes rainUp {
  0% { transform: translate(0, 40px) scale(.2) rotate(0); opacity: 0 }
  18% { transform: translate(0, 0) scale(1.15) rotate(var(--spin)); opacity: 1 }
  100% { transform: translate(var(--rx), var(--ry)) scale(.9) rotate(var(--spin)); opacity: 0 }
}

/* ---------- lecące sekundy ---------- */

.timefly {
  position: absolute;
  font-size: 22px;
  font-weight: 700;
  color: #38e8a0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7), 0 0 18px rgba(56, 232, 160, .8);
  pointer-events: none;
  white-space: nowrap;
  animation: flyClock 1.1s cubic-bezier(.3, .4, .2, 1) forwards;
}

.timefly.big {
  font-size: 40px;
  animation-duration: 1.6s;
  color: #ffe066;
  text-shadow: 0 3px 14px rgba(0, 0, 0, .8), 0 0 28px rgba(255, 210, 60, .9);
}

@keyframes flyClock {
  0% { transform: translate(-50%, 0) scale(.5); opacity: 0 }
  18% { transform: translate(-50%, -26px) scale(1.25); opacity: 1 }
  55% { transform: translate(-50%, -34px) scale(1.1); opacity: 1 }
  100% { transform: translate(calc(-50% + var(--tx)), var(--ty)) scale(.45); opacity: 0 }
}

.timer.gain .hud-value { color: #38e8a0; animation: gainPop .5s ease; }

@keyframes gainPop {
  0%, 100% { transform: scale(1) }
  40% { transform: scale(1.35) }
}
.tile.spawn { opacity: 0; }

/* ---------- liczby i banery ---------- */

.floaters { position: absolute; inset: 0; pointer-events: none; z-index: 6; }

.floater {
  position: absolute;
  font-size: 22px;
  font-weight: 700;
  color: var(--honey);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .7);
  animation: floatUp 1s ease-out forwards;
  white-space: nowrap;
}

@keyframes floatUp {
  from { transform: translate(-50%, 0) scale(.6); opacity: 0 }
  25% { transform: translate(-50%, -14px) scale(1.15); opacity: 1 }
  to { transform: translate(-50%, -62px) scale(1); opacity: 0 }
}

.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--honey);
  pointer-events: none;
  animation: sparkFly .62s ease-out forwards;
}

@keyframes sparkFly {
  from { transform: translate(-50%, -50%) scale(1); opacity: 1 }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0 }
}

/* Komunikaty mają własny pas nad planszą — dzięki temu nigdy nie zasłaniają kafelków. */
.bannerbar {
  flex: none;
  height: 30px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
}

.banner {
  max-width: 100%;
  padding: 5px 14px;
  border-radius: 99px;
  background: linear-gradient(140deg, var(--honey), var(--honey2));
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .4), 0 0 20px rgba(255, 170, 30, .5);
  animation: bannerIn .4s cubic-bezier(.2, 1.5, .4, 1);
  pointer-events: none;
}

@keyframes bannerIn {
  from { transform: scale(.4) translateY(-8px); opacity: 0 }
  to { transform: none; opacity: 1 }
}

/* ---------- kartka ze słowem ---------- */

.teachcard {
  flex: none;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  min-height: 30px;
  padding: 4px 10px;
  margin-top: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  animation: cardIn .3s ease;
}

@keyframes cardIn { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }

.teachcard.plain { justify-content: center; }
.teachcard-word { color: var(--honey); font-size: 17px; font-weight: 700; text-transform: lowercase; }
.teachcard-gloss { color: var(--paper); font-size: 14px; opacity: .92; text-align: center; }

/* ---------- narzędzia ---------- */

.tools {
  flex: none;
  display: flex;
  gap: 8px;
  padding-top: 8px;
}

.tool {
  flex: 1 1 auto;          /* auto, nie 0 — dłuższa etykieta dostaje więcej miejsca niż krótsza */
  min-width: 0;            /* bez tego długie etykiety (pl „Podpowiedź”) wypychają przycisk dźwięku poza ekran */
  position: relative;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 10px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(170deg, var(--t-hi), var(--t-mid) 48%, var(--t-lo));
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 5px 0 var(--t-edge), 0 8px 16px rgba(0, 0, 0, .4);
  color: var(--t-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  transition: transform .1s ease, box-shadow .1s ease, opacity .15s ease;
}

/* lukrowy połysk jak na kafelkach */
.tool::before {
  content: "";
  position: absolute;
  top: 7%;
  left: 10%;
  width: 55%;
  height: 32%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .6), rgba(255, 255, 255, 0));
  pointer-events: none;
}

/* wciśnięcie: guzik osiada na swojej krawędzi */
.tool:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 2px var(--t-line) inset, 0 1px 0 var(--t-edge), 0 3px 8px rgba(0, 0, 0, .4);
}

.tool > * { position: relative; z-index: 1; }

#btnHint    { --t-hi:#fff3bd; --t-mid:#ffc61e; --t-lo:#ff9d0a; --t-edge:#bf6f00; --t-ink:#4a2a00; --t-line:rgba(120,70,0,.3); }
#btnShuffle { --t-hi:#cfecff; --t-mid:#36a8ff; --t-lo:#0d74d6; --t-edge:#064f95; --t-ink:#ffffff; --t-line:rgba(4,40,80,.34); }
#btnSound   { --t-hi:#ecd4ff; --t-mid:#ab5bf7; --t-lo:#7726d4; --t-edge:#53179c; --t-ink:#ffffff; --t-line:rgba(45,5,90,.34); }
#btnHowto   { --t-hi:#d4f8c7; --t-mid:#52d44f; --t-lo:#17a033; --t-edge:#0e7124; --t-ink:#0c3b11; --t-line:rgba(10,70,20,.3); }

.tool[disabled] { opacity: .45; cursor: default; filter: grayscale(.55); }
.tool[disabled]:active { transform: none; }
.tool-icon-only { flex: 0 0 48px; padding: 8px 0; }
.tool-icon { flex: none; font-size: 19px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.tool-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* wąskie telefony: ciaśniejsze przyciski, żeby długie etykiety mieściły się bez skracania */
@media (max-width: 400px) {
  .tools { gap: 4px; }
  .tool { gap: 4px; padding: 8px 6px; font-size: 12.5px; }
  .tool-icon { font-size: 16px; }
  .tool-icon-only { flex: 0 0 38px; padding: 8px 0; }
  .tool-icon-only .tool-icon { font-size: 18px; }
  .tool-count { min-width: 17px; padding: 1px 4px; font-size: 11px; }
}

.tool-count {
  flex: none;
  min-width: 21px;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .34);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset;
}

/* ---------- koniec czasu: na cały ekran ---------- */

.timeup {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(80, 10, 60, .84), rgba(10, 3, 22, .95));
  animation: fade .18s ease;
  pointer-events: none;
}

.timeup-text {
  font-size: clamp(56px, 23vw, 170px);
  font-weight: 700;
  line-height: .95;
  text-align: center;
  padding: 0 16px;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .02em;
  background: linear-gradient(180deg, #fff3bd, var(--honey) 45%, var(--honey2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 0 #a8500a) drop-shadow(0 0 60px rgba(255, 170, 30, 1));
  animation: timeupIn .7s cubic-bezier(.2, 1.6, .35, 1);
}

@keyframes timeupIn {
  0% { transform: scale(2.6) rotate(-10deg); opacity: 0 }
  45% { transform: scale(.88) rotate(3deg); opacity: 1 }
  70% { transform: scale(1.1) rotate(-2deg) }
  100% { transform: scale(1) rotate(0) }
}

/* ---------- tryb „miodowy wybuch” ---------- */

/* Pasek trybu leży NAD obszarem planszy zamiast w przepływie — inaczej jego pojawienie
   się spychało siatkę w dół w trakcie gry. Nie łapie też kliknięć. */
.blastbar {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  max-width: 100%;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 99px;
  background: linear-gradient(100deg, #ff3d8b, #ff8a1a 55%, #ffc61e);
  box-shadow: 0 0 22px rgba(255, 61, 139, .7);
  animation: blastPulse .9s ease-in-out infinite;
}

@keyframes blastPulse {
  0%, 100% { box-shadow: 0 0 16px rgba(255, 61, 139, .55) }
  50% { box-shadow: 0 0 30px rgba(255, 138, 26, .95) }
}

.blastbar-label {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #2a1004;
  white-space: nowrap;
}

.blastbar-track { flex: 1; height: 6px; border-radius: 99px; background: rgba(0, 0, 0, .35); overflow: hidden; }

.blastbar-track i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: #fff;
  transform-origin: left center;
  transition: transform .2s linear;
}

.app.blast { background: radial-gradient(130% 80% at 50% 0%, rgba(255, 61, 139, .3), transparent 62%); }
.app.blast .board { animation: boardGlow 1.1s ease-in-out infinite; border-radius: 20px; }

@keyframes boardGlow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 61, 139, .55), 0 0 40px rgba(255, 61, 139, .45) }
  50% { box-shadow: 0 0 0 5px rgba(255, 170, 30, .8), 0 0 70px rgba(255, 138, 26, .7) }
}

.app.blast .hud-value { color: #ffd9ec; }
.app.blast .timer .hud-value { color: #ff7ab8; }
.app.blast .timebar i { background: linear-gradient(90deg, #ff3d8b, #ffc61e); }
.app.blast .current { color: #ffd9ec; }
.app.blast .tile { animation: blastTile 1.4s ease-in-out infinite; }
.app.blast .tile.sel { animation: none; }

@keyframes blastTile {
  0%, 100% { filter: saturate(1) brightness(1) }
  50% { filter: saturate(1.5) brightness(1.14) }
}

/* ---------- szał: tryb nad trybem wybuchu ---------- */

.app.frenzy { background: radial-gradient(130% 80% at 50% 0%, rgba(255, 60, 20, .34), transparent 60%); }
.app.frenzy .board { animation: boardFrenzy .55s ease-in-out infinite; }

@keyframes boardFrenzy {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 70, 20, .7), 0 0 50px rgba(255, 70, 20, .6) }
  50% { box-shadow: 0 0 0 6px rgba(255, 210, 60, .95), 0 0 90px rgba(255, 140, 20, .9) }
}

.app.frenzy .blastbar { background: linear-gradient(100deg, #ff2d00, #ff8a1a 50%, #ffd93d); animation-duration: .5s; }
.app.frenzy .hud-value { color: #ffd9a8; }
.app.frenzy .timer .hud-value { color: #ff8a3d; }
.app.frenzy .tile { animation: blastTile .7s ease-in-out infinite; }
.app.frenzy .current { color: #ffd9a8; }

@media (prefers-reduced-motion: reduce) {
  .app.blast .tile, .app.blast .board, .blastbar,
  .app.frenzy .tile, .app.frenzy .board { animation: none; }
}


/* ---------- NEON: kolejność liter przestaje mieć znaczenie ---------- */

.app.neon {
  /* dwie warstwy: wędrujące neonowe plamy + przelewająca się tęcza pod spodem */
  background:
    radial-gradient(42vmax 42vmax at 18% 22%, rgba(255, 0, 170, .72), transparent 62%),
    radial-gradient(38vmax 38vmax at 82% 28%, rgba(0, 200, 255, .68), transparent 62%),
    radial-gradient(44vmax 44vmax at 30% 86%, rgba(0, 255, 160, .6), transparent 62%),
    radial-gradient(40vmax 40vmax at 76% 78%, rgba(255, 220, 0, .58), transparent 62%),
    linear-gradient(130deg, #ff00aa, #7a00ff 25%, #00c8ff 50%, #00ffa0 75%, #ffd93d);
  background-size: 160% 160%, 160% 160%, 160% 160%, 160% 160%, 300% 300%;
  animation: neonBlobs 5.5s ease-in-out infinite;
}

/* plansza i HUD muszą zostać czytelne mimo szaleństwa w tle */
.app.neon .board { background: rgba(10, 2, 30, .5); }
.app.neon .hud {
  background: rgba(8, 2, 26, .55);
  border-radius: 16px;
  backdrop-filter: blur(3px);
}
.app.neon .hud-label { color: rgba(255, 255, 255, .85); text-shadow: 0 2px 6px rgba(0, 0, 0, .9); }
.app.neon .teachcard { background: rgba(8, 2, 26, .72); }

@keyframes neonBlobs {
  0%   { background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%, 0% 50% }
  50%  { background-position: 100% 60%, 0% 80%, 70% 0%, 20% 10%, 100% 50% }
  100% { background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%, 0% 50% }
}

@keyframes neonSky {
  0% { background-position: 0% 50% }
  100% { background-position: 300% 50% }
}

/* kafelki przelatują przez całe widmo — to jest ten „szalony neon” */
.app.neon .tile {
  animation: neonTile 1.6s linear infinite;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, .5) inset,
    0 5px 0 var(--t-edge),
    0 0 22px currentColor;
}

@keyframes neonTile {
  0%   { filter: hue-rotate(0deg) saturate(2.1) brightness(1.18) }
  100% { filter: hue-rotate(360deg) saturate(2.1) brightness(1.18) }
}

/* każda kolumna startuje w innym miejscu widma — plansza faluje kolorem */
.app.neon .tile:nth-child(6n+1) { animation-delay: 0s }
.app.neon .tile:nth-child(6n+2) { animation-delay: -.27s }
.app.neon .tile:nth-child(6n+3) { animation-delay: -.53s }
.app.neon .tile:nth-child(6n+4) { animation-delay: -.8s }
.app.neon .tile:nth-child(6n+5) { animation-delay: -1.07s }
.app.neon .tile:nth-child(6n)   { animation-delay: -1.33s }

.app.neon .tile.sel { animation: none; filter: none; }

.app.neon .board {
  border-radius: 22px;
  animation: neonBoard 1.1s linear infinite;
}

@keyframes neonBoard {
  0%   { box-shadow: 0 0 0 4px #ff00aa, 0 0 60px #ff00aa }
  25%  { box-shadow: 0 0 0 4px #7a00ff, 0 0 60px #7a00ff }
  50%  { box-shadow: 0 0 0 4px #00c8ff, 0 0 60px #00c8ff }
  75%  { box-shadow: 0 0 0 4px #00ffa0, 0 0 60px #00ffa0 }
  100% { box-shadow: 0 0 0 4px #ff00aa, 0 0 60px #ff00aa }
}

.app.neon .blastbar {
  background: linear-gradient(100deg, #ff00aa, #7a00ff 25%, #00c8ff 50%, #00ffa0 75%, #ffd93d);
  background-size: 300% 100%;
  animation: neonSky 2s linear infinite;
}

.app.neon .blastbar-label { color: #fff; text-shadow: 0 0 10px rgba(0, 0, 0, .7); }

.app.neon .hud-value,
.app.neon .timer .hud-value,
.app.neon .current { animation: neonText 1.4s linear infinite; }

/* biel + ciemna obwódka: czytelne nad każdym kolorem tła, poświata robi neon */
@keyframes neonText {
  0%   { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 16px #ff00aa, 0 0 30px #ff00aa }
  33%  { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 16px #3b5bff, 0 0 30px #3b5bff }
  66%  { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 16px #00ffa0, 0 0 30px #00ffa0 }
  100% { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.9), 0 0 16px #ff00aa, 0 0 30px #ff00aa }
}

.app.neon .timebar i { background: linear-gradient(90deg, #ff00aa, #00c8ff, #00ffa0); }

@media (prefers-reduced-motion: reduce) {
  .app.neon, .app.neon .tile, .app.neon .board, .app.neon .blastbar,
  .app.neon .hud-value, .app.neon .current { animation: none; }
  .app.neon .tile { filter: saturate(1.6); }
}

/* ---------- finał rundy ---------- */

.finale {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0 16px;
  text-align: center;
  animation: finaleIn .55s cubic-bezier(.2, 1.4, .35, 1);
}

@keyframes finaleIn {
  from { transform: scale(.7) translateY(24px); opacity: 0 }
  to { transform: none; opacity: 1 }
}

.finale-line {
  font-size: clamp(18px, 5.4vw, 26px);
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.finale-score.landed { animation: scoreLand .42s cubic-bezier(.3, 1.7, .5, 1); }

@keyframes scoreLand {
  0%   { transform: scale(1) }
  45%  { transform: scale(1.16) }
  100% { transform: scale(1) }
}

.finale-score {
  font-size: clamp(56px, 19vw, 130px);
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-shadow: 0 5px 0 rgba(0, 0, 0, .35), 0 0 46px rgba(255, 198, 30, .55);
  font-variant-numeric: tabular-nums;
}

/* ranga czeka, aż licznik się zatrzyma */
.finale.counting .finale-rank { opacity: 0; transform: translateY(8px) scale(.9); }
.finale-rank {
  margin-top: 6px;
  transition: opacity .25s ease, transform .3s cubic-bezier(.3, 1.6, .5, 1);
  padding: 10px 24px;
  border-radius: 99px;
  font-size: clamp(18px, 5.2vw, 26px);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, #ff7ab8, #ff3d8b);
  box-shadow: 0 5px 0 #a3104f, 0 10px 28px rgba(0, 0, 0, .45);
}

/* im lepszy wynik, tym cieplejsza i jaśniejsza plakietka */
.finale.tier0 .finale-rank { background: linear-gradient(140deg, #8d7ff0, #5b48c9); box-shadow: 0 5px 0 #3b2b94, 0 10px 28px rgba(0,0,0,.45); }
.finale.tier1 .finale-rank { background: linear-gradient(140deg, #ff7ab8, #ff3d8b); box-shadow: 0 5px 0 #a3104f, 0 10px 28px rgba(0,0,0,.45); }
.finale.tier2 .finale-rank {
  background: linear-gradient(140deg, #fff3bd, var(--honey) 45%, var(--honey2));
  color: var(--ink);
  box-shadow: 0 5px 0 #bf6f00, 0 0 54px rgba(255, 198, 30, .9);
  animation: rankGlow 1.1s ease-in-out infinite;
}

@keyframes rankGlow {
  0%, 100% { box-shadow: 0 5px 0 #bf6f00, 0 0 36px rgba(255, 198, 30, .7) }
  50% { box-shadow: 0 5px 0 #bf6f00, 0 0 72px rgba(255, 198, 30, 1) }
}

.finale.tier2 .finale-score {
  background: linear-gradient(180deg, #fff6d0, var(--honey) 55%, var(--honey2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  /* text-shadow rysuje się POD literą, a jej wnętrze jest tu przezroczyste —
     cień prześwitywałby przez cyfry. Cień robi więc drop-shadow na całym kształcie. */
  text-shadow: none;
  filter: drop-shadow(0 6px 0 #a8500a) drop-shadow(0 0 50px rgba(255, 170, 30, .95));
}

@media (prefers-reduced-motion: reduce) {
  .finale, .finale.tier2 .finale-rank { animation: none; }
}

/* ---------- niskie ekrany i dostępność ---------- */

@media (max-height: 700px) {
  .teachcard { display: none; }
  .hero { padding: 2px 0 6px; }
  .hero-tile { width: 28px; height: 28px; font-size: 16px; border-radius: 8px; }
  .howto-btn { margin: 10px auto 2px; min-height: 40px; padding: 8px 14px; }
  .wordbar { height: 38px; }
  .hud-value { font-size: 19px; }
  .say-sub { display: none; }
  .mic { width: 80px; height: 80px; font-size: 32px; }
  .say-tile { width: 38px; height: 38px; font-size: 20px; border-radius: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .level, .levels-title, .howto-btn { animation: none; }
  .tile.bee::after, .tile.bomb::after, .tile.bolt::after,
  .beam, .shockwave, .rain-emoji, .confetti, .pop-emoji { display: none; }
  .shake, .shake-hard { animation: none; }

  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .05s !important;
  }
  body::before { display: none; }
}

/* ---------- samouczek: podpowiedź leżąca na planszy, dopóki gracz po niej nie przejedzie ---------- */

/* linia leży NA kafelkach — ma prowadzić palec, nie chować się w szczelinach */
.coachtrace { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; overflow: visible; }

.coachtrace polyline { fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* gruba, miękka wstęga pod spodem — to ona niesie kształt całego słowa */
.coachtrace .coach-base {
  stroke: rgba(255, 255, 255, .34);
  stroke-width: 17;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, .75));
}

/* jasne kreski płynące po wstędze w stronę końca słowa — pokazują kierunek ciągnięcia */
.coachtrace .coach-flow {
  stroke: rgba(255, 255, 255, .95);
  stroke-width: 8;
  stroke-dasharray: 20 16;
  animation: coachDash .75s linear infinite;
}

@keyframes coachDash { to { stroke-dashoffset: -36 } }

.coachhand {
  position: absolute;
  left: 0; top: 0;
  width: 44px; height: 44px;
  margin: 2px 0 0 6px;            /* opuszek palca ląduje na środku kafelka */
  font-size: 34px;
  line-height: 44px;
  text-align: center;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .6));
}

.coachhand.show { opacity: 1; }
.coachhand.move { transition: transform .32s cubic-bezier(.4, 0, .2, 1), opacity .2s ease; }

/* kafelki pulsują falą wzdłuż słowa — opóźnienie bierze się z kolejności litery */
.app .tile.coachme {
  z-index: 4;
  animation: coachPulse 1.2s ease-in-out infinite;
  animation-delay: calc(var(--coach-i, 0) * .13s);
}

@keyframes coachPulse {
  0%, 100% {
    transform: translate(var(--x), var(--y)) scale(1.03);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, .9) inset, 0 5px 0 var(--t-edge), 0 0 20px rgba(255, 255, 255, .75);
  }
  50% {
    transform: translate(var(--x), var(--y)) scale(1.1);
    box-shadow: 0 0 0 4px #fff inset, 0 5px 0 var(--t-edge), 0 0 30px rgba(255, 255, 255, .95);
  }
}

.coachtip {
  display: inline-flex;
  align-items: center;
  gap: .45em;
  max-width: 100%;
  padding: 7px 16px;
  border-radius: 99px;
  background: rgba(10, 2, 30, .85);
  border: 2px solid rgba(255, 255, 255, .38);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
  animation: coachTipIn .3s cubic-bezier(.3, 1.6, .5, 1);
}

.coachtip-word {
  color: var(--honey);
  letter-spacing: .08em;
  text-shadow: 0 0 10px rgba(255, 198, 30, .7);
}

@keyframes coachTipIn {
  from { transform: translateY(-8px) scale(.9); opacity: 0 }
  to   { transform: none; opacity: 1 }
}

@media (max-width: 400px) { .coachtip { font-size: 13px; padding: 6px 12px; } }

@media (prefers-reduced-motion: reduce) {
  .coachhand { transition: none; }
  .coachtrace polyline { animation: none; stroke-dasharray: none; }
  .tile.coachme {
    animation: none;
    box-shadow: 0 0 0 4px #fff inset, 0 5px 0 var(--t-edge), 0 0 26px rgba(255, 255, 255, .9);
  }
}

/* Neon: litery, które nie weszły do słowa — gra ich nie zbiera, więc gasną */
.tile.sel.spare {
  filter: saturate(.45) brightness(.72);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .25) inset, 0 5px 0 var(--t-edge);
  opacity: .72;
}
.app.neon .tile.sel.spare { animation: none; }

.current .left {
  font-size: .5em;
  margin-left: .55em;
  opacity: .8;
  letter-spacing: .04em;
  text-transform: none;
}
/* kropka oddziela punkty od licznika nieużytych liter — bez niej zlewały się w jeden ciąg */
.current .left::before { content: '· '; opacity: .6; }

/* ---------- podświetlenia muszą przebić animacje trybów ----------
   .app.blast/.frenzy/.neon .tile mają po trzy klasy, czyli tyle samo co .app .tile.hintme —
   przy remisie wygrywa reguła położona niżej, więc podpowiedź i samouczek lądują na końcu
   arkusza i dostają własny wariant dla każdego trybu. */
.app .tile.hintme,
.app.blast .tile.hintme,
.app.frenzy .tile.hintme,
.app.neon .tile.hintme { animation: hintPop .62s ease-in-out 3; }

.app .tile.coachme,
.app.blast .tile.coachme,
.app.frenzy .tile.coachme,
.app.neon .tile.coachme {
  z-index: 4;
  animation: coachPulse 1.2s ease-in-out infinite;
  animation-delay: calc(var(--coach-i, 0) * .13s);
}
