/* ============================================================
   GHICEȘTE PIESA — înfățișarea jocului
   ============================================================

   Scena are 1600 x 900 de puncte și atât are oricând. Potrivirea la
   ecran se face dintr-un singur loc — mărimea `--scara`, calculată în
   ecran.js — așa că fiecare mărime de aici se scrie o singură dată,
   în puncte de-ale scenei.

   AȘEZAREA
     - sus, bara: titlul, piesa a câta, stelele, butoanele;
     - rândul de sus: poza piesei în stânga, vorba lui Bit la mijloc,
       Bit cu baloanele în dreapta;
     - la mijloc, cuvântul: câte o căsuță pentru fiecare literă;
     - jos, tastatura de pe ecran.
   ============================================================ */

:root {
  --albastru: #2f7ff0;
  --albastru-umbra: #1b4fb0;
  --portocaliu: #f59421;
  --portocaliu-umbra: #c96c05;
  --mov: #8b5cf6;
  --galben: #f5c400;
  --verde: #34b36a;
  --verde-umbra: #1e7a45;
  --rosu: #e4573d;

  --bleumarin: #12307a;
  --cerneala: #1f2933;

  --scara: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--cerneala);
  background: #0e2a63;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   RAMA ȘI SCENA
   ============================================================ */

.rama {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scena {
  position: relative;
  width: 1600px;
  height: 900px;
  flex: none;
  overflow: hidden;
  transform: scale(var(--scara));
  transform-origin: center center;
  background: #eaf5ff;
}

.clasa {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ============================================================
   BARA DE SUS
   ============================================================ */

.bara {
  position: absolute;
  top: 20px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.bara__mijloc,
.bara__dreapta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pastila {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 62px;
  padding: 0 26px;
  border-radius: 31px;
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  border: 4px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18), 0 14px 26px rgba(18, 48, 122, 0.28);
  white-space: nowrap;
}

.pastila--titlu   { background: linear-gradient(180deg, #4b95ff, var(--albastru)); }
.pastila--progres { background: linear-gradient(180deg, #ffb057, var(--portocaliu)); }
.pastila--stele   { background: linear-gradient(180deg, #ffe36e, var(--galben)); color: #5a4300; }

.rotund {
  width: 62px;
  height: 62px;
  flex: none;
  padding: 0;
  border: 4px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  background: linear-gradient(180deg, #4b95ff, var(--albastru));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18), 0 14px 26px rgba(18, 48, 122, 0.28);
  display: grid;
  place-items: center;
  transition: transform 0.12s, box-shadow 0.12s;
}

.rotund svg { width: 30px; height: 30px; }

.rotund:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18), 0 6px 12px rgba(18, 48, 122, 0.25);
}

/* ============================================================
   POZA PIESEI
   ============================================================ */

.piesa {
  position: absolute;
  top: 104px;
  left: 40px;
  width: 520px;
  height: 340px;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 34px;
  border: 6px solid #ffffff;
  background: #ffffff;
  box-shadow: 0 12px 0 rgba(18, 48, 122, 0.12), 0 22px 40px rgba(18, 48, 122, 0.22);
}

/* Poza umple caseta fără să iasă din ea, oricare i-ar fi proporțiile:
   lată la tastatură, înaltă la carcasă. */
.piesa__poza {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Poza nouă intră cu o săltare scurtă, ca să se vadă schimbarea. */
.piesa.noua { animation: izbucnire 0.4s ease-out; }

/* ============================================================
   BIT ȘI BALOANELE
   ============================================================ */

.bit {
  position: absolute;
  right: 60px;
  top: 96px;
  width: 300px;
  height: 350px;
  pointer-events: none;
}

.bit__pozitii {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 250px;
  height: 250px;
  transform: translateX(-50%);
  animation: plutire 3.8s ease-in-out infinite;
}

.bit__poza {
  position: absolute;
  left: 50%;
  bottom: 0;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  transform: translateX(-50%);
  opacity: 0;
  filter: drop-shadow(0 14px 20px rgba(18, 48, 122, 0.28));
  transition: opacity 0.16s ease;
}

.bit[data-poza='arata'] .bit__poza[data-pentru='arata'],
.bit[data-poza='bucurie'] .bit__poza[data-pentru='bucurie'],
.bit[data-poza='gandeste'] .bit__poza[data-pentru='gandeste'],
.bit[data-poza='mira'] .bit__poza[data-pentru='mira'] {
  opacity: 1;
}

/* Baloanele stau într-un mănunchi deasupra lui Bit, fiecare pe sfoara
   lui. Cel care zboară urcă și se stinge; locul lui rămâne gol până la
   piesa următoare, ca să se vadă câte au mai rămas. */
.bit__baloane {
  position: absolute;
  top: 0;
  left: 50%;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
}

.balonas {
  --fata: #62a6ff;
  --fund: var(--albastru);
  position: relative;
  width: 54px;
  height: 66px;
  border-radius: 50% 50% 50% 50% / 56% 56% 44% 44%;
  background:
    radial-gradient(60% 45% at 35% 26%, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(180deg, var(--fata) 0%, var(--fund) 100%);
  box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.18), 0 8px 14px rgba(18, 48, 122, 0.22);
  animation: plutire 3.2s ease-in-out infinite;
  transition: opacity 0.3s;
}

.balonas::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -60px;
  width: 2px;
  height: 60px;
  background: rgba(18, 48, 122, 0.4);
  transform: translateX(-50%);
}

.balonas--albastru   { --fata: #62a6ff; --fund: var(--albastru); }
.balonas--portocaliu { --fata: #ffb057; --fund: var(--portocaliu); animation-delay: 0.4s; }
.balonas--mov        { --fata: #b08cff; --fund: var(--mov); animation-delay: 0.8s; }
.balonas--galben     { --fata: #ffe36e; --fund: var(--galben); animation-delay: 1.2s; }
.balonas--verde      { --fata: #7de0a6; --fund: var(--verde); animation-delay: 1.6s; }

/* Balonul zburat: urcă și se stinge. Rămâne nevăzut. */
.balonas.zburat {
  animation: zbor 1s ease-in forwards;
}

/* ============================================================
   VORBA LUI BIT
   ============================================================ */

.vorba {
  position: absolute;
  top: 120px;
  left: 600px;
  width: 620px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.vorba__text {
  position: relative;
  margin: 0;
  padding: 22px 30px;
  border-radius: 26px;
  border: 5px solid var(--albastru);
  background: #ffffff;
  color: var(--bleumarin);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 22px rgba(18, 48, 122, 0.22);
}

/* Coada bulei, spre Bit, în dreapta. */
.vorba__text::after {
  content: "";
  position: absolute;
  right: -16px;
  top: 40px;
  width: 26px;
  height: 26px;
  background: #ffffff;
  border-right: 5px solid var(--albastru);
  border-top: 5px solid var(--albastru);
  transform: rotate(45deg);
  border-radius: 0 8px 0 0;
}

.vorba__text.bine { border-color: var(--verde); color: var(--verde-umbra); }
.vorba__text.bine::after { border-color: var(--verde); }
.vorba__text.rau { border-color: var(--portocaliu); color: #8a4b00; }
.vorba__text.rau::after { border-color: var(--portocaliu); }

/* „Ascultă": vocea sistemului citește ce spune Bit. Se arată numai când
   browserul are o voce românească. */
.asculta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border: 3px solid #b9d0f5;
  border-radius: 30px;
  background: #ffffff;
  color: #33518c;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
}

.asculta[hidden] { display: none; }
.asculta:hover { border-color: var(--albastru); }
.asculta.vorbeste { border-color: var(--verde); color: var(--verde-umbra); }

/* ============================================================
   CUVÂNTUL
   ============================================================ */

.cuvant {
  position: absolute;
  top: 470px;
  left: 40px;
  right: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.litera {
  display: grid;
  place-items: center;
  width: 84px;
  height: 104px;
  border-radius: 18px;
  border: 5px solid #ffffff;
  background: linear-gradient(180deg, #ffffff, #dfeaff);
  color: var(--bleumarin);
  font-size: 66px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 0 rgba(18, 48, 122, 0.12), 0 14px 24px rgba(18, 48, 122, 0.18);
}

/* Litera necunoscută: căsuța goală, cu o linie jos. */
.litera.ascunsa {
  color: transparent;
  background: linear-gradient(180deg, #f3f7ff, #dfeaff);
  box-shadow: 0 8px 0 rgba(18, 48, 122, 0.12), 0 14px 24px rgba(18, 48, 122, 0.18), inset 0 -10px 0 #b9cff5;
}

/* Litera tocmai găsită: sare o clipă. */
.litera.gasita { animation: izbucnire 0.4s ease-out; }

/* Literele arătate de Bit, când baloanele s-au terminat: portocalii. */
.litera.aratata {
  background: linear-gradient(180deg, #fff1dc, #ffd9a8);
  color: #8a4b00;
}

/* Spațiul dintre cuvinte: o căsuță fără chenar. */
.litera--spatiu {
  width: 40px;
  border: 0;
  background: none;
  box-shadow: none;
}

/* Cuvintele lungi, cu peste 12 litere, au căsuțe mai mici. */
.cuvant.lung .litera { width: 70px; height: 90px; font-size: 54px; }
.cuvant.lung .litera--spatiu { width: 30px; }

/* ============================================================
   TASTATURA DE PE ECRAN
   ============================================================ */

.taste {
  position: absolute;
  top: 610px;
  left: 40px;
  right: 40px;
  bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px;
}

.tasta {
  --fata: #62a6ff;
  --fund: var(--albastru);
  --dedesubt: var(--albastru-umbra);
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 4px solid #ffffff;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--fata), var(--fund));
  color: #ffffff;
  font: inherit;
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 8px 0 var(--dedesubt), 0 14px 22px rgba(18, 48, 122, 0.25);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
}

/* Cu puține litere, tastele sunt mai mari: încap pe un rând. */
.taste.putine .tasta { width: 104px; height: 104px; font-size: 56px; }

.tasta:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--dedesubt), 0 6px 12px rgba(18, 48, 122, 0.25);
}

.tasta:focus-visible {
  outline: 6px solid #ffd54a;
  outline-offset: 4px;
}

/* Tasta apăsată o dată nu se mai apasă: verde dacă litera era în
   cuvânt, ștearsă dacă nu. */
.tasta:disabled { cursor: default; transform: none; }

.tasta.buna {
  --fata: #6ee2a0;
  --fund: var(--verde);
  --dedesubt: var(--verde-umbra);
}

.tasta.rea {
  --fata: #d7dee8;
  --fund: #b7c3d6;
  --dedesubt: #8d9bb2;
  color: #f4f7fb;
}

/* Cât timp Bit se bucură sau arată cuvântul, tastele nu primesc nimic. */
.taste.blocate .tasta { pointer-events: none; }

/* ============================================================
   PANOURILE (început, sfârșit)
   ============================================================ */

.panou {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(18, 48, 122, 0.45), rgba(18, 48, 122, 0.72));
  backdrop-filter: blur(3px);
}

body[data-stare="meniu"] .panou--start,
body[data-stare="final"] .panou--final { display: flex; }

body:not([data-stare="joc"]) .bara,
body:not([data-stare="joc"]) .taste,
body:not([data-stare="joc"]) .vorba { pointer-events: none; }

body[data-stare="meniu"] .bara,
body[data-stare="meniu"] .piesa,
body[data-stare="meniu"] .vorba,
body[data-stare="meniu"] .cuvant,
body[data-stare="meniu"] .taste,
body[data-stare="meniu"] .bit { opacity: 0; }

.panou__cutie {
  width: 1080px;
  max-width: 100%;
  padding: 36px 60px 34px;
  border-radius: 44px;
  border: 8px solid rgba(255, 255, 255, 0.9);
  background: linear-gradient(180deg, #ffffff, #eaf3ff);
  box-shadow: 0 26px 60px rgba(8, 24, 64, 0.45);
  text-align: center;
  animation: intra 0.3s ease-out;
}

.titlu-joc {
  margin: 0;
  font-size: 66px;
  font-weight: 800;
  line-height: 1.05;
  color: var(--bleumarin);
  text-shadow: 0 5px 0 rgba(47, 127, 240, 0.22);
}

.panou__titlu {
  margin: 0;
  font-size: 62px;
  font-weight: 800;
  color: var(--bleumarin);
}

.panou__subtitlu {
  margin: 10px auto 0;
  max-width: 900px;
  font-size: 24px;
  line-height: 1.45;
  color: #3c5280;
}

/* ---------- reglajele ---------- */

.reglaje {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 22px 0 0;
  flex-wrap: wrap;
}

.nivel__descriere {
  max-width: 900px;
  min-height: 1.4em;
  margin: 14px auto 0;
  font-size: 22px;
  line-height: 1.35;
  color: #3c5280;
}

.reglaj {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.reglaj__nume {
  font-size: 20px;
  font-weight: 700;
  color: #5b6f96;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.reglaj__optiuni {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 22px;
  background: #dfeaff;
}

.optiune {
  padding: 10px 20px;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: #33518c;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.optiune:hover { background: #cddffb; }

.optiune.aleasa {
  background: linear-gradient(180deg, #4b95ff, var(--albastru));
  color: #fff;
  box-shadow: 0 5px 0 var(--albastru-umbra);
}

/* ---------- butoanele ---------- */

.buton-mare {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 420px;
  min-height: 100px;
  margin-top: 22px;
  padding: 0 52px;
  border: 6px solid #ffffff;
  border-radius: 56px;
  background: linear-gradient(180deg, #46d585, var(--verde));
  color: #fff;
  font: inherit;
  font-size: 42px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 14px 0 var(--verde-umbra), 0 22px 36px rgba(8, 24, 64, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}

.buton-mare:active {
  transform: translateY(10px);
  box-shadow: 0 4px 0 var(--verde-umbra), 0 10px 18px rgba(8, 24, 64, 0.3);
}

.buton-mare--sters {
  background: linear-gradient(180deg, #7fa8ec, #4b79d0);
  box-shadow: 0 14px 0 #2a4f97, 0 22px 36px rgba(8, 24, 64, 0.35);
}

.buton-mare--sters:active { box-shadow: 0 4px 0 #2a4f97, 0 10px 18px rgba(8, 24, 64, 0.3); }

.buton-mic {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 26px;
  border: 3px solid #b9d0f5;
  border-radius: 30px;
  background: #ffffff;
  color: #33518c;
  font: inherit;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.buton-mic:hover { background: #eaf2ff; border-color: var(--albastru); }
.buton-mic[aria-pressed="false"] { color: #8a97ad; }
.buton-mic__semn { font-size: 26px; line-height: 1; }

.panou__unelte {
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.panou__unelte--final { gap: 26px; }

.inapoi {
  display: inline-block;
  margin-top: 20px;
  color: #5b6f96;
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}

.inapoi:hover { color: var(--albastru); text-decoration: underline; }

/* ---------- fișa de final ---------- */

.rezultat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  margin-top: 30px;
}

.bit-final {
  width: auto;
  height: 220px;
  filter: drop-shadow(0 12px 18px rgba(18, 48, 122, 0.24));
}

.rezultat__casuta {
  min-width: 340px;
  padding: 24px 32px;
  border-radius: 32px;
  background: linear-gradient(180deg, #ffffff, #dfeaff);
  border: 5px solid #ffffff;
  box-shadow: 0 10px 0 rgba(18, 48, 122, 0.12), 0 18px 30px rgba(18, 48, 122, 0.18);
}

.rezultat__numar {
  display: block;
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  color: var(--albastru);
}

.rezultat__eticheta {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  color: #5b6f96;
}

.record {
  margin: 22px 0 0;
  font-size: 26px;
  color: #5b6f96;
}

.record[hidden] { display: none; }
.record b { color: var(--bleumarin); font-size: 30px; }

.record.nou {
  color: var(--verde-umbra);
  font-weight: 700;
  animation: bataie 0.9s ease-in-out 3;
}

/* ============================================================
   MIȘCĂRILE
   ============================================================ */

@keyframes plutire {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -10px; }
}

@keyframes intra {
  0% { transform: scale(0.88); opacity: 0; }
  60% { transform: scale(1.03); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes izbucnire {
  0% { transform: scale(1); }
  40% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes zbor {
  0% { translate: 0 0; opacity: 1; }
  100% { translate: 20px -260px; opacity: 0; }
}

@keyframes bataie {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .balonas, .bit__pozitii, .piesa.noua, .litera.gasita, .panou__cutie, .record.nou { animation: none; }
  .balonas.zburat { animation: none; opacity: 0; }
}
