/* ===== WSPÓLNY WYGLĄD WSZYSTKICH GIER ===== */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, "Segoe UI", sans-serif;
  color: #1d2a44;
  background: linear-gradient(160deg, #c9e8ff, #e4d4ff 50%, #ffd9ec);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 16px;
}
h1, h2, h3 { font-family: "Baloo 2", system-ui, sans-serif; margin: 0; }

/* Biała karta */
.karta {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .15);
  padding: 28px 24px;
  max-width: 640px;
  width: 100%;
  text-align: center;
}
h1 { font-size: 38px; line-height: 1.1; }
.wstep { font-size: 17px; line-height: 1.5; margin: 8px 0 16px; }

/* Link "← Wszystkie gry" na górze strony gry */
.powrot { display: inline-block; margin-bottom: 8px; font-weight: 700; text-decoration: none; background: #f1f4f9; border-radius: 999px; padding: 4px 14px; }

/* Ramka "Jak grać?" (rozwija się po kliknięciu) */
.opis-gry { text-align: left; background: #f5f7fd; border-radius: 16px; padding: 6px 16px; margin: 0 0 14px; font-size: 15px; line-height: 1.5; }
.opis-gry summary { cursor: pointer; font-weight: 700; text-align: center; padding: 4px 0; }
.opis-gry ul { margin: 6px 0 8px; padding-left: 20px; }
.opis-gry li { margin-bottom: 4px; }

/* Wybór tematu i poziomu */
.etykieta { font-weight: 700; font-size: 15px; margin: 12px 0 6px; }
.wybor { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.wybor button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #d9def0;
  background: #f5f7fd;
  color: inherit;
  cursor: pointer;
}
.wybor button[aria-pressed="true"] { background: #6c4fe0; border-color: #6c4fe0; color: #fff; }

/* Pasek z wynikami */
.wyniki { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; }
.wyniki span { background: #f1f4f9; border-radius: 999px; padding: 4px 14px; font-weight: 600; }

/* Plansza memory */
.plansza { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 520px; margin: 0 auto; }
.plansza.szesc { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 600px; }

/* Kafelek: obracamy go w 3D jak prawdziwą kartę */
.kafelek { aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: pointer; perspective: 600px; font: inherit; color: inherit; }
.wnetrze { position: relative; display: block; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.kafelek.odkryty .wnetrze { transform: rotateY(180deg); }
.tyl, .przod {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .18);
}
.tyl {
  transform: rotateY(0deg);
  background: repeating-linear-gradient(45deg, #6c4fe0 0 10px, #5f43d0 10px 20px);
  color: #fff;
  font-size: clamp(22px, 6vw, 34px);
}
.przod { transform: rotateY(180deg); background: #fff; border: 2px solid #e3e8ef; font-size: clamp(26px, 8vw, 46px); padding: 4px; }
.plansza.szesc .przod { font-size: clamp(20px, 6vw, 38px); }
.przod img { width: 76%; height: auto; }
.kafelek.para .przod { background: #eafbea; border-color: #2e9e4f; }
.kafelek:focus-visible { outline: 3px solid #2a7fd4; outline-offset: 3px; border-radius: 14px; }
/* Karta z emoji i podpisem (np. postacie, flagi) */
.emo { font-size: clamp(28px, 9vw, 46px); line-height: 1.1; }
.podpis { font-size: clamp(10px, 2.8vw, 14px); font-weight: 700; line-height: 1.1; margin-top: 3px; }
.brawo { font-weight: 700; min-height: 24px; margin: 14px 0; }

/* Przyciski */
.przyciski { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.guzik {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: #ff5d8f;
  border: none;
  border-radius: 999px;
  padding: 8px 24px;
  cursor: pointer;
  box-shadow: 0 5px 0 #c93a68;
}
.guzik:active { transform: translateY(3px); box-shadow: 0 2px 0 #c93a68; }
.guzik.szary { background: #6b7690; box-shadow: 0 5px 0 #4a5268; }
.guzik.szary:active { box-shadow: 0 2px 0 #4a5268; }
.guzik.fioletowy { background: #7b5cd6; box-shadow: 0 5px 0 #5940a8; }
.guzik.fioletowy:active { box-shadow: 0 2px 0 #5940a8; }
.guzik.zielony { background: #2e9e4f; box-shadow: 0 5px 0 #1f7238; }
.guzik.zielony:active { box-shadow: 0 2px 0 #1f7238; }

.rekord { font-size: 15px; color: #4a5268; margin: 12px 0 0; }

/* Tabela rankingowa */
.ranking { margin-top: 28px; padding-top: 20px; border-top: 3px dashed #e1d8fb; }
.ranking h2 { font-size: 28px; }
.ranking .plansza-rankingu { font-weight: 600; color: #4a5268; margin: 4px 0 0; }
.ranking table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 16px; }
.ranking th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: #4a5268; padding: 6px 4px; border-bottom: 2px solid #e8ebf5; }
.ranking td { padding: 8px 4px; border-bottom: 1px solid #f0f2f8; }
.ranking .imie { text-align: left; font-weight: 700; overflow-wrap: anywhere; }
.ranking th.imie { font-weight: inherit; }
.ranking tr.nowy td { background: #fff5c2; }
.ranking .pusto { color: #4a5268; padding: 16px 0; }
.uwaga { font-size: 13px; color: #4a5268; margin: 8px 0 0; }
.zapis { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }
.zapis[hidden] { display: none; }
.zapis input { font: inherit; font-size: 18px; padding: 8px 12px; border: 2px solid #d9def0; border-radius: 12px; width: 170px; }
.zapis input:focus { outline: 3px solid #6c4fe0; outline-offset: 1px; }

/* Okienko z gratulacjami */
.wygrana { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(29, 42, 68, .55); padding: 16px; }
.wygrana.widoczna { display: flex; }
.okienko { background: #fff; border-radius: 24px; padding: 28px 24px; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.okienko h2 { font-size: 40px; }
.okienko p { font-size: 18px; }

.stopka { font-size: 14px; color: #6b7690; margin: 24px 0 0; line-height: 1.6; }
a { color: #2a7fd4; }

@media (max-width: 420px) {
  .karta { padding: 24px 12px; }
  .plansza.szesc { gap: 5px; }
  .guzik { font-size: 17px; padding: 7px 16px; }
  .data { display: none; }
}
@media (prefers-reduced-motion: reduce) { .wnetrze { transition: none; } }
