:root {
  --sky-top: #6ec6ff;
  --sky-bottom: #bfe9ff;
  --ink: #2b1a12;
  --cream: #fff7e8;
  --accent: #ff5d3b;
  --accent-dark: #c73f22;
  --leaf: #2f9e44;

  --font-display: "Baloo 2", "Segoe UI", sans-serif;
  --font-body: "Poppins", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #123;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  font-family: var(--font-body);
}

/* Mindig a böngésző-ablak tényleges belső méretét tölti ki — nincs
   1280x800-ra korlátozott "dobozos" kártya-nézet, a teljes rendelkezésre
   álló helyet használja, asztalon és mobilon egyaránt. A "height: 100vh"
   sor a tartalék azoknak a böngészőknek, amik még nem ismerik a
   100dvh-t — ahol ismerik, a dvh felülírja. */
.game-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  border-radius: 14px;
  box-shadow: 0 0 60px rgba(0,0,0,.5);
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  isolation: isolate;
}

html.ksz-fullscreen .game-frame {
  height: 100vh;
  height: 100dvh;
}

/* A rendelkezésre álló hely (a vezérlő-sáv fölötti rész) — ez adja a
   "keretet", amiben a tényleges 16:9 játékterületnek (.viewport) el kell
   férnie. Flexbox-os középre-igazítással kerül helyre benne a .viewport, amit a
   game.js resize()-ja méretez pontosan úgy, hogy akár a szélesség, akár a
   magasság a szűkösebb (álló vs. fekvő nézet), sose lógjon ki/vágódjon le. */
.play-area {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewport {
  position: relative;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  image-rendering: -webkit-optimize-contrast;
}

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 5;
  pointer-events: none;
}

.hud-lives {
  background: rgba(20, 10, 5, .35);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  gap: 6px;
}

.heart {
  font-size: 18px;
  color: var(--accent);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.4));
  transition: opacity .2s ease, transform .2s ease;
}

.heart.lost {
  opacity: .25;
  transform: scale(.85);
  color: #fff;
}

.hud-pill {
  background: rgba(20, 10, 5, .35);
  border-radius: 999px;
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.hud-label {
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--cream);
  text-transform: uppercase;
  opacity: .8;
}

.hud-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--cream);
  line-height: 1.1;
}

.hud-center {
  display: flex;
  gap: 8px;
}

.hud-controls {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}

.hud-icon-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.hud-icon-btn:active {
  transform: scale(.92);
  background: rgba(255, 255, 255, .18);
}

.hud-icon-btn.muted {
  opacity: .55;
}

/* ---------------- Teljes képernyő gomb ---------------- */
/* Mindig látható (a start képernyőn és játék közben is), a game-frame
   jobb felső sarkában — nem csak a HUD része, hogy bármikor elérhető
   legyen, a menüből is. */
.fullscreen-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 20;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(12, 22, 42, .55);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}

.fullscreen-btn:active {
  transform: scale(.92);
  background: rgba(12, 22, 42, .8);
}

.fullscreen-icon {
  width: 17px;
  height: 17px;
}

.fullscreen-icon--exit {
  display: none;
}

.fullscreen-btn.is-fullscreen .fullscreen-icon--enter {
  display: none;
}

.fullscreen-btn.is-fullscreen .fullscreen-icon--exit {
  display: block;
}

/* ---------------- Irányítás-infó gomb + felugró leírás ---------------- */
/* Sötétkékes, a fullscreen gombhoz hasonló dizájn. Csak a kezdő-folyamat
   alatt látszik (JS kapcsolja ki/be) — bal alsó sarokban, hogy ne
   ütközzön a jobb felső teljes-képernyő gombbal. */
.controls-info-btn {
  position: absolute;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  z-index: 20;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(12, 22, 42, .55);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}

.controls-info-btn:active {
  transform: scale(.92);
  background: rgba(12, 22, 42, .8);
}

.controls-info-btn svg {
  width: 20px;
  height: 20px;
}

.controls-info-btn.hidden {
  display: none;
}

.controls-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 22, .6);
}

.controls-modal.hidden {
  display: none;
}

.controls-modal-panel {
  position: relative;
  width: 100%;
  max-width: 340px;
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, #1c3a5e, #142a47);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

.controls-modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--cream);
  margin: 0 0 14px;
  text-align: center;
}

.controls-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: var(--cream);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.controls-modal-close:active {
  background: rgba(255,255,255,.25);
}

.controls-modal .rules {
  margin: 0;
  max-width: none;
}

/* ---------------- Screens ---------------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* "safe center": ha a tartalom kifér, középre igazít; ha nem, felülről
     igazít, hogy a lenti tartalom (pl. a start gomb) görgethető maradjon
     kis mobil képernyőkön is. */
  justify-content: safe center;
  text-align: center;
  padding: 28px;
  padding-top: max(28px, env(safe-area-inset-top));
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #2a6fb0, #1c4a78);
  transition: opacity .3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
 
}
section#screen-leaderboard {
	background-image: url(images/bg-desktop.webp);
    background-size: cover;
	background-position: center;
}
.screen.hidden {
  display: none;
}

/* Fantázia-hangulatú háttér a start képernyőn — a 3 főhőssel és egy
   fantasy-világgal. Mobilon (álló kép) és asztalon (fekvő kép) más-más
   verzió tölt be, hogy a kompozíció mindkét arányban jól nézzen ki. */
#screen-start {
  overflow: hidden;
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background-image: url("images/bg-mobile.webp");
  background-size: cover;
  background-position: center;
  background-color: rgb(0 0 0 / 46%);
  background-blend-mode: overlay;
}

@media (min-width: 700px) and (min-height: 500px) {
  .hero-backdrop {
    background-image: url("images/bg-desktop.webp");
  }
}

.start-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Egyelőre a szöveges cím lakik benne — később ide kerülhet egy fix
   logókép is, a .brand-title lecserélése/kiegészítése nélkül. */
.brand-logo {
  margin: 0 0 18px;
}

.brand-logo img {
  max-width: 220px;
  height: auto;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(28px, 7vw, 44px);
  letter-spacing: .02em;
  color: var(--cream);
  margin: 0 0 6px;
  line-height: 1.05;
  text-shadow: 0 4px 0 rgba(0,0,0,.2);
}

.brand-sub {
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cream);
  margin: 0 0 22px;
  opacity: .8;
}

.flag-icon {
  font-size: 56px;
  margin-bottom: 8px;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 18px 0;
  width: 100%;
  max-width: 320px;
}

.rule {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--cream);
  background: rgba(0,0,0,.18);
  border-radius: 10px;
  padding: 8px 14px;
  text-align: left;
}

.rule--mobile {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .rule--mobile { display: flex; }
}

.key-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
  background: var(--cream);
  border-radius: 6px;
  padding: 4px 8px;
  min-width: 22px;
  text-align: center;
  flex: none;
}

.hint {
  font-size: 13px;
  color: var(--cream);
  opacity: .85;
  max-width: 320px;
  line-height: 1.5;
  margin: 0 0 24px;
}

/* A start képernyő háttere elé kerülő szöveg saját kis "kártyát" kap, hogy
   a mögötte lévő hős-sziluettek fölött is jól olvasható maradjon. */
#screen-start .hint {
  background: rgba(0,0,0,.22);
  border-radius: 10px;
  padding: 10px 14px;
}

.btnrow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    width: 100%;
    gap: 20px;
    margin-top: 10px;
}
button#btn-start {
    transition: .4s;
}
button#btn-start:hover {
    background: #fff;
    color: #000;
}
.btn-primary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .06em;
  border: none;
  border-radius: 999px;
  padding: 15px 34px;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
  width: 100%;
  max-width: 260px;
  background: linear-gradient(135deg, #000, #4d4d4d 60%, #000);
  color: var(--cream);
  box-shadow: 0 8px 22px rgb(8 8 8 / 40%);
}

.btn-primary:active {
  transform: scale(.97);
}

.btn-secondary {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .06em;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 999px;
  padding: 12px 30px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
  width: 100%;
  max-width: 260px;
  margin-top: 12px;
  background: transparent;
  color: var(--cream);
}

.btn-secondary:active {
  transform: scale(.97);
  background: rgba(255,255,255,.15);
}

/* ---------------- Karakterválasztó ---------------- */
.hero-select {
  width: 100%;
  max-width: 480px;
  margin: 4px 0 22px;
}

.hero-select-label {
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--cream);
  opacity: .65;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.hero-select-row {
  display: flex;
  gap: 10px;
}

.hero-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  border: 2px solid rgba(255,255,255,.25);
  border-radius: 14px;
  padding: 8px 4px 10px;
  background: rgba(255,255,255,.06);
  color: var(--cream);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.hero-btn:active {
  transform: scale(.96);
}

.hero-btn-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}

.hero-btn-title {
  font-size: 11px;
  font-weight: 600;
  opacity: .85;
}

.hero-btn.selected {
  border-color: var(--accent);
  background: rgba(255,93,59,.2);
}

.hero-btn.selected .hero-btn-title {
  opacity: 1;
}

/* ---------------- Világválasztó ---------------- */
.world-select {
  width: 100%;
  max-width: 480px;
  margin-top: 8px;
  margin-bottom: 22px;
}

.world-select-label {
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--cream);
  opacity: .65;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.world-select-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.world-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: var(--font-body);
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 14px;
  padding: 10px 6px;
  background: rgba(255,255,255,.06);
  color: var(--cream);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.world-btn:hover {
    background: #171713;
}
.world-btn:active {
  transform: scale(.96);
  background: rgba(255,255,255,.16);
}

.world-btn-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.world-btn-sub {
  font-size: 11px;
  opacity: .75;
}

.world-btn.locked {
  cursor: not-allowed;
  opacity: .45;
  background: rgba(0,0,0,.15);
}

.world-btn.locked:active {
  transform: none;
}

.world-btn.locked .world-btn-title::after {
  content: " 🔒";
}

/* ---------------- Leaderboard ---------------- */
.leaderboard-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-list.hidden {
  display: none;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--cream);
  background:rgba(0,0,0,1);
  border-radius: 10px;
  padding: 8px 14px;
}

.leaderboard-list .lb-rank {
  font-family: var(--font-display);
  font-weight: 700;
  min-width: 20px;
  opacity: .8;
}

.leaderboard-list .lb-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list .lb-score {
  font-family: var(--font-display);
  font-weight: 700;
  color: #e3b784;
}

.leaderboard-list .lb-time {
  font-family: var(--font-display);
  font-weight: 700;
  opacity: .75;
  font-size: 12px;
}

.leaderboard-empty {
  font-size: 13px;
  color: var(--cream);
  opacity: .7;
  margin: 0 0 20px;
}

.highscore-form {
  width: 100%;
  max-width: 320px;
  margin: 0 0 18px;
}

.highscore-form.hidden {
  display: none;
}

.name-input {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  margin: 10px 0 12px;
  text-align: center;
  box-sizing: border-box;
}

/* ---------------- Touch controls ---------------- */
/* Saját, a játéktér ALATT elhelyezkedő sáv — nem takarja a pályát, mint
   egy ráúsztatott overlay, hanem a game-frame flex-elrendezésében kap
   helyet, fix magassággal. Csak érintős eszközön jelenik meg és foglal
   helyet — egérrel/billentyűzettel kezelt gépen 0 magasságú marad. */
#touch-controls {
  flex: 0 0 auto;
  height: 0;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(18px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(18px, env(safe-area-inset-right));
  background: rgba(10, 6, 4, .55);
  overflow: hidden;
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: flex;
    height: max(96px, calc(84px + env(safe-area-inset-bottom)));
  }
}

.touch-dpad {
  display: flex;
  gap: 14px;
}

.touch-btn {
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  border: none;
  border-radius: 16px;
  background: rgba(255, 255, 255, .12);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 26px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  flex: none;
}

.touch-btn:active {
  background: rgba(255, 255, 255, .25);
}

.touch-btn--jump {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  font-size: 12px;
  background: rgba(255, 93, 59, .7);
}

.touch-btn--jump:active {
  background: rgba(255, 93, 59, .95);
}

/* ---------------- Start / karakterválasztó / pályaválasztó — asztali
   térköz-finomítás ---------------- */
@media (min-width: 700px) and (min-height: 500px) {
  #screen-start,
  #screen-hero-select,
  #screen-world-select {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  #screen-start .start-content,
  #screen-hero-select .start-content,
  #screen-world-select .start-content {
    max-width: 560px;
  }
}

