/* Warstwa emocji AMBASSARA (klient/emocje.js, projekt gra/docs/emocje.md).
 * Bezpieczeństwo: żadnego migotania szybciej niż 3 razy na sekundę (WCAG 2.3.1) — alarm pulsuje 1,2 Hz, trzy razy.
 * prefers-reduced-motion: bez ruchu, iskier i wibracji; zostaje statyczna karta. */

/* ——— scena emocji ——— */
.emoScena { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity .35s ease; pointer-events: auto; }
.emoScena.widoczna { opacity: 1; }
.emoTlo { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(8, 12, 22, .55), rgba(4, 7, 14, .88)); cursor: pointer; }
.emoIskry { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.emoKarta { position: relative; max-width: min(560px, 92vw); text-align: center; padding: 30px 30px 24px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(22, 34, 56, .96), rgba(11, 18, 32, .97)); border: 1px solid var(--k, rgba(227, 182, 90, .35));
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 60px var(--poswiataEmo, rgba(227, 182, 90, .12)); color: var(--tusz, #f4ede0);
  transform: translateY(14px) scale(.96); transition: transform .5s cubic-bezier(.2, .9, .25, 1.2); }
.emoScena.widoczna .emoKarta { transform: none; }
.emoNad { font: 700 12px/1 var(--sans, Inter, sans-serif); letter-spacing: .28em; text-transform: uppercase; color: var(--k, #e3b65a); margin-bottom: 10px; }
.emoTytul { margin: 0 0 10px; font: 800 clamp(30px, 6vw, 46px)/1.05 var(--sans, Inter, sans-serif); letter-spacing: .02em; color: #fff; text-wrap: balance; }
.emoOpis { margin: 0 auto 14px; max-width: 44ch; font-size: 16px; line-height: 1.45; color: var(--tusz2, #c3cbd8); text-wrap: pretty; }
.emoList, .emoKto { display: flex; gap: 12px; align-items: center; text-align: start; margin: 4px auto 16px; padding: 12px 14px; border-radius: 10px; background: rgba(255, 255, 255, .05); border-inline-start: 3px solid var(--k, #e3b65a); font-size: 14.5px; line-height: 1.45; max-width: 46ch; }
.emoList b { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--tusz3, #97a3b6); margin-bottom: 2px; }
.emoKto { justify-content: center; border: 0; background: none; padding: 0; color: var(--tusz2, #c3cbd8); }
.emoPortret { flex: none; line-height: 0; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px var(--k, #e3b65a); }
.emoPortret img, .emoPortret svg { width: 48px; height: 48px; display: block; }
.emoAkcje { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.emoMala { place-items: start center; padding-top: calc(var(--gora, 76px) + 8px); pointer-events: none; } /* mała wersja niczego nie blokuje… */
.emoMala .emoKarta { pointer-events: auto; } /* …poza własną kartą */
/* świeża scena / odznaka: kliknięcie, które już leciało do przycisku gry, przechodzi przez nią (playtest 28.11) */
.emoScena.swieza, .emoScena.swieza *, .osToast.swieza { pointer-events: none !important; }
.emoOdznaka { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 14px; color: var(--tusz, #f4ede0); }
.emoOdznaka b { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--zloto, #e3b65a); }
.emoOdznaka .osMedal { width: 36px; height: 36px; }
.emoMala .emoTlo { background: none; pointer-events: none; }
.emoMala .emoKarta { padding: 14px 18px; }
.emoMala .emoTytul { font-size: 22px; }

/* podgląd do zrzutów (#emo=…): cudze nakładki schowane */
body.emoPodglad :is(.fabTlo, .scenaTlo, .fabPrzycisk, #samouczek) { display: none !important; }

/* kolory emocji */
.emo-strach, .emo-gniew { --k: #f0646a; --poswiataEmo: rgba(240, 100, 106, .25); }
.emo-zdrada { --k: #b98cff; --poswiataEmo: rgba(185, 140, 255, .22); }
.emo-wstyd { --k: #97a3b6; --poswiataEmo: rgba(0, 0, 0, 0); }
.emo-ulga { --k: #7cb7ea; --poswiataEmo: rgba(124, 183, 234, .22); }
.emo-nadzieja { --k: #ffb46b; --poswiataEmo: rgba(255, 180, 107, .2); }
.emo-radosc, .emo-duma, .emo-triumf { --k: #e3b65a; --poswiataEmo: rgba(227, 182, 90, .28); }

/* alarm: czerwona winieta pulsująca trzy razy (1,2 Hz) i taśma u góry */
.efekt-alarm .emoTlo { background: radial-gradient(ellipse at center, rgba(40, 6, 10, .5), rgba(30, 2, 6, .9)); }
.efekt-alarm::before { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px 40px rgba(240, 60, 70, .55); opacity: 0; animation: emoAlarm .84s ease-in-out 3; }
.efekt-alarm::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; pointer-events: none;
  background: repeating-linear-gradient(-45deg, #f0646a 0 14px, #2a0a0e 14px 28px); animation: emoTasma 1.2s linear infinite; }
@keyframes emoAlarm { 50% { opacity: 1; } }
@keyframes emoTasma { to { background-position: 40px 0; } }
.efekt-alarm .emoTytul { animation: emoDrzenie .5s ease-out 1; }
@keyframes emoDrzenie { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* zdrada: pęknięcia szkła, mapa szarzeje */
.emoPekniecia { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.emoPekniecia path { fill: none; stroke: rgba(230, 220, 255, .75); stroke-width: .35; vector-effect: non-scaling-stroke; stroke-dasharray: 160; stroke-dashoffset: 160; animation: emoPeka .55s ease-out forwards; animation-delay: calc(var(--i) * 45ms); filter: drop-shadow(0 0 3px rgba(185, 140, 255, .8)); }
.emoPekniecia path { stroke-width: 1.6px; }
@keyframes emoPeka { to { stroke-dashoffset: 0; } }
body.emoSzarosc #mapa { filter: grayscale(1) brightness(.7); transition: filter .8s ease; }
#mapa { transition: filter .8s ease; }
.efekt-pekniecie .emoKarta { animation: emoUderzenie .35s ease-out 1; }
@keyframes emoUderzenie { 0% { transform: scale(1.06); } 100% { transform: none; } }

/* ulga: niebieska fala rozchodzi się od środka */
.efekt-fala::before { content: ""; position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 2px rgba(124, 183, 234, .7), 0 0 40px rgba(124, 183, 234, .5); animation: emoFala 2.2s ease-out 2; }
@keyframes emoFala { from { transform: scale(.2); opacity: 1; } to { transform: scale(40); opacity: 0; } }

/* wstyd: ciężki cień, tytuł wolno wychodzi z mroku */
.efekt-cien .emoTlo { background: rgba(2, 4, 8, .92); }
.efekt-cien .emoTytul { animation: emoZMroku 1.6s ease-out 1 both; }
@keyframes emoZMroku { from { opacity: 0; letter-spacing: .3em; } to { opacity: 1; } }

/* nadzieja: świt od dołu */
.efekt-swit .emoTlo { background: linear-gradient(0deg, rgba(255, 150, 80, .35), rgba(11, 18, 32, .85) 60%); animation: emoSwit 2s ease-out 1; }
@keyframes emoSwit { from { background-position: 0 100px; filter: brightness(.6); } }

/* duma i triumf: złoty błysk przez tytuł */
:is(.efekt-zloto, .efekt-fajerwerki) .emoTytul { background: linear-gradient(100deg, #fff 30%, #f5d27a 45%, #fff 60%) 0 0 / 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: emoBlysk 2.4s ease-in-out 1; }
@keyframes emoBlysk { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* spokojny tryb: bez ruchu */
.emoSpokojnie *, .emoSpokojnie::before, .emoSpokojnie::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { body.emoSzarosc #mapa { filter: none; } }

/* ——— pasek odliczania i horyzontu ——— */
#emoPasek { position: fixed; z-index: 9; left: 50%; transform: translateX(-50%); top: calc(var(--gora, 76px) + 10px); display: flex; align-items: center; gap: 8px; max-width: min(400px, calc(100vw - 32px));
  padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--szklo, rgba(14, 22, 38, .8)); border: 1px solid rgba(227, 182, 90, .18); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--cien); font-size: 13px; color: var(--tusz2, #c3cbd8); }
#emoPasek[hidden] { display: none; }
[dir="rtl"] #emoPasek { padding: 6px 12px 6px 6px; }

.emoOdl[hidden] { display: none; }
.emoOdl[hidden] + .emoHor { border-inline-start: 0; padding-inline-start: 0; }
.emoOdl { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--tusz, #f4ede0); white-space: nowrap; }
.emoHor { border: 0; background: none; color: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; padding-inline-start: 8px; border-inline-start: 1px solid var(--linia, #2a3854); }
.emoHor[hidden] { display: none; }
.emoHor[data-waga="4"], .emoHor[data-waga="5"] { color: var(--zloto, #e3b65a); }
.emoDzwonek { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--linia, #2a3854); background: transparent; color: var(--tusz3, #97a3b6); display: grid; place-items: center; cursor: pointer; }
.emoDzwonek.wl { color: var(--zloto, #e3b65a); border-color: rgba(227, 182, 90, .5); }
.emoDzwonek[hidden] { display: none; }
#emoPasek[data-faza="blisko"] { border-color: rgba(227, 182, 90, .7); }
#emoPasek[data-faza="blisko"] .emoOdl { color: var(--zloto, #e3b65a); animation: emoBicie 1.6s ease-in-out infinite; }
#emoPasek[data-faza="ostatnie"] { border-color: rgba(240, 100, 106, .8); box-shadow: 0 0 22px rgba(240, 100, 106, .25); }
#emoPasek[data-faza="ostatnie"] .emoOdl { color: var(--czerwony, #f0646a); animation: emoBicie .9s ease-in-out infinite; }
#emoPasek[data-faza="liczy"] .emoOdl { color: var(--blekit, #7cb7ea); }
@keyframes emoBicie { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { #emoPasek .emoOdl { animation: none !important; } }
@media (max-width: 799px) {
  /* telefon: nad przełącznikiem trybów mapy (.tryby: bottom 168px), żeby nie zasłaniać paska i banera u góry */
  #emoPasek { top: auto; bottom: calc(222px + env(safe-area-inset-bottom)); font-size: 12px; max-width: calc(100vw - 24px); }
  .panel:not(.zwiniety) ~ #emoPasek { display: none; }
  .emoKarta { padding: 22px 18px 18px; }
}
body.pisze #emoPasek { display: none; }

/* ——— kronika sezonu (ekran końca sezonu) ——— */
.emoKronika { margin: 18px 0; padding: 18px; border-radius: 12px; background: var(--karta, #162238); border: 1px solid rgba(227, 182, 90, .2); text-align: start; }
.emoKronika h3 { margin: 0 0 6px; }
.emoPrzydomek { margin: 0 0 12px; font-size: 18px; }
.emoPrzydomek b { color: var(--zloto, #e3b65a); font-style: italic; }
.emoDni { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.emoDni li { display: grid; grid-template-columns: 74px 1fr; gap: 4px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--linia, #2a3854); animation: wjazd .4s ease-out both; animation-delay: calc(var(--i) * 70ms); }
.emoDzien { font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--tusz3, #97a3b6); grid-row: span 2; }
.emoChwila { font-size: 14px; line-height: 1.4; color: var(--tusz2, #c3cbd8); }
.emoChwila b { color: var(--tusz, #f4ede0); margin-inline-end: 4px; }
.emoChwila.e-strach b, .emoChwila.e-gniew b { color: var(--czerwony, #f0646a); }
.emoChwila.e-zdrada b { color: #b98cff; }
.emoChwila.e-ulga b { color: var(--blekit, #7cb7ea); }
.emoChwila.e-triumf b, .emoChwila.e-duma b, .emoChwila.e-radosc b { color: var(--zloto, #e3b65a); }
.emoChwila.cisza { color: var(--tusz3, #97a3b6); font-style: italic; }
.emoLiczby { font-weight: 650; margin-bottom: 10px; }
.emoKrzywa { margin: 0 0 12px; }
.emoKrzywa svg { width: 100%; height: 56px; display: block; }
.emoKrzywa polyline { fill: none; stroke: var(--zloto, #e3b65a); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-width: 2.5px; stroke-linejoin: round; }
.emoNowy { margin: 12px 0; }
.emoNowy h4 { margin: 0 0 8px; }
.emoNowyLista { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 10px; }
.emoNowyKarta { text-align: start; display: grid; gap: 4px; padding: 12px; border-radius: 10px; border: 1px solid rgba(227, 182, 90, .3); background: var(--karta2, #1b2a44); color: var(--tusz, #f4ede0); cursor: pointer; animation: wjazd .4s ease-out both; animation-delay: calc(var(--i) * 90ms + 200ms); }
.emoNowyKarta:hover, .emoNowyKarta:focus-visible { border-color: var(--zloto, #e3b65a); }
.emoNowyKarta span { font-size: 13px; color: var(--tusz2, #c3cbd8); }

/* ——— osiągnięcia (klient/osiagniecia-logika.js): medal w kolorze rzadkości ——— */
.osMedal { --rk: #9fb3c8; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--rk);
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .14), rgba(255, 255, 255, .02) 60%); box-shadow: inset 0 0 0 3px var(--rk), 0 0 14px color-mix(in srgb, var(--rk) 35%, transparent); }
.osMedal svg { width: 22px; height: 22px; }
.r-rzadkie .osMedal, .osMedal.r-rzadkie { --rk: #7cb7ea; }
.r-epickie .osMedal, .osMedal.r-epickie { --rk: #b98cff; }
.r-legendarne .osMedal, .osMedal.r-legendarne { --rk: #f5d27a; }
.osMedal.zablokowany { --rk: #3a4a66; color: #55657f; box-shadow: inset 0 0 0 2px var(--rk); filter: grayscale(1); }
.osToast { position: fixed; z-index: 36; left: 50%; top: calc(var(--gora, 76px) + 12px); transform: translate(-50%, -16px); opacity: 0; transition: opacity .3s, transform .4s cubic-bezier(.2, .9, .25, 1.2);
  display: flex; gap: 12px; align-items: center; max-width: min(440px, calc(100vw - 24px)); padding: 12px 16px 12px 12px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, rgba(22, 34, 56, .97), rgba(11, 18, 32, .97)); border: 1px solid rgba(227, 182, 90, .35); box-shadow: 0 16px 40px rgba(0, 0, 0, .5); color: var(--tusz, #f4ede0); }
.osToast.widoczna { opacity: 1; transform: translate(-50%, 0); }
.osToast.r-legendarne { border-color: #f5d27a; box-shadow: 0 16px 40px rgba(0, 0, 0, .5), 0 0 40px rgba(245, 210, 122, .3); }
.osToast.r-epickie { border-color: rgba(185, 140, 255, .7); }
.osToast b { display: block; font-size: 17px; line-height: 1.2; }
.osNad { display: block; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--zloto, #e3b65a); margin-bottom: 2px; }
.osOpis { display: block; font-size: 13px; line-height: 1.35; color: var(--tusz2, #c3cbd8); margin-top: 2px; }
.osIskry { z-index: 37; }
.osSekcja { margin: 14px 0 6px; }
.osSekcja h4 { margin: 0 0 8px; }
.osRzad, .osSiatka { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.osPoz { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .03); }
.osPoz b { display: block; font-size: 14px; }
.osPoz small { display: block; font-size: 12px; line-height: 1.3; color: var(--tusz3, #97a3b6); }
.osPoz.brak b { color: var(--tusz3, #97a3b6); }
.osGaleria { margin-top: 10px; }
.osGaleria summary { cursor: pointer; font-weight: 650; color: var(--zloto, #e3b65a); }
.osGaleria .osSiatka { margin-top: 8px; max-height: 340px; overflow: auto; }
@media (max-width: 799px) { .osToast { top: auto; bottom: calc(270px + env(safe-area-inset-bottom)); } }
.osPct { display: block; font-size: 12px; margin-top: 3px; color: var(--zloto, #e3b65a); font-weight: 600; }
