/* =========================
   1) FŐ STÍLUS (alap)
   ========================= */

:root{
  --bg0:#070714;
  --bg1:#0a0b18;
  --card:#0f1126;
  --card2:#0b0d1f;
  --line:#1b1f3f;
  --text:#eaf0ff;
  --muted:#aab6da;

  --neonC:#00e5ff;
  --neonP:#a855f7;
  --neonG:#22c55e;
  --danger:#ff3b6b;

  --r:18px;
  --shadow: 0 18px 55px rgba(0,0,0,.55);

  --safeTop: env(safe-area-inset-top, 0px);
  --safeBot: env(safe-area-inset-bottom, 0px);

  --mobileNavH: 86px;
}

/* -- Alap dobozmodell + vízszintes kilógás tiltása -- */
*,
*::before,
*::after{box-sizing:border-box}

html, body{
  height:100%;
  margin:0;
  width:100%;
  overflow-x:hidden; /* ne tudjon oldalra kilógni semmi */
}

body{
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color:var(--text);
  background:
    radial-gradient(1100px 800px at 15% 10%, rgba(168,85,247,.16), transparent 55%),
    radial-gradient(1000px 780px at 85% 30%, rgba(0,229,255,.13), transparent 60%),
    radial-gradient(900px 680px at 50% 95%, rgba(34,197,94,.10), transparent 60%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow:hidden; /* app-szerű nézet, a belső elemek kezelik a scrollt */
}

a{color:var(--neonC); text-decoration:none}
a:hover{text-decoration:underline}

/* -- Alkalmazás konténer -- */
.app{
  height:100%;
  display:flex;
  flex-direction:column;
  min-height:0;
  max-width:100%;
}

/* =========================
   Felső sáv (Topbar)
   ========================= */

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: calc(12px + var(--safeTop)) 14px 12px;
  border-bottom:1px solid rgba(27,31,63,.75);
  background: linear-gradient(180deg, rgba(15,17,38,.86), rgba(10,11,24,.68));
  backdrop-filter: blur(10px);
  min-width:0; /* fontos: ne tudjon széthúzódni */
}

/* Bal oldali márka rész */
.brand{display:flex; align-items:center; gap:12px; min-width:0}
.brand-mark{
  width:38px; height:38px;
  border-radius:14px;
  display:flex; align-items:center; justify-content:center;
  font-weight:900;
  letter-spacing:.5px;
  color:rgba(255,255,255,.95);
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35), transparent 45%),
    linear-gradient(135deg, rgba(0,229,255,.9), rgba(168,85,247,.85));
  box-shadow: 0 0 22px rgba(0,229,255,.18), 0 0 26px rgba(168,85,247,.14);
  flex:0 0 auto;
}
.brand-text{min-width:0}
.brand-title{font-weight:900; letter-spacing:.5px; font-size:16px; line-height:1}
.brand-sub{
  color:var(--muted);
  font-size:12px;
  margin-top:3px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Jobb oldali gombsor */
.topbar-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
  min-width:0;
}

/* Gomb stílus */
.btn{
  appearance:none;
  border:1px solid rgba(27,31,63,.9);
  background: linear-gradient(180deg, rgba(15,17,38,.92), rgba(10,11,24,.9));
  color:var(--text);
  border-radius:14px;
  padding:10px 12px;
  cursor:pointer;
  user-select:none;
  box-shadow: 0 10px 22px rgba(0,0,0,.28);
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-width:0;
}
.btn:hover{border-color: rgba(0,229,255,.45)}
.btn:active{transform: translateY(1px)}
.btn:focus-visible{
  outline:none;
  box-shadow: 0 0 0 3px rgba(0,229,255,.16), 0 10px 22px rgba(0,0,0,.28);
}
.btn-primary{
  border-color: rgba(0,229,255,.35);
  background: linear-gradient(180deg, rgba(0,229,255,.14), rgba(15,17,38,.92));
  box-shadow: 0 12px 26px rgba(0,229,255,.10), 0 12px 26px rgba(168,85,247,.08);
}
.btn .icon{opacity:.95}
.btn .label{font-weight:800}

/* =========================
   Fő tartalom (Main)
   ========================= */

.main{
  flex:1;
  min-height:0;
  display:grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap:14px;
  padding: 14px;
  padding-bottom: calc(14px + var(--safeBot));
  overflow:hidden;

  width:100%;
  max-width:1240px;
  margin:0 auto;
}

/* Bal oldal */
.game-col{
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:12px;
  overflow:hidden;
  min-width:0;
  width:100%;
  max-width: 900px;
  justify-self:center;
}

.game-shell{
  flex:1;
  min-height:0;
  display:flex;
  align-items:stretch;
  overflow:hidden;
  min-width:0;
}

/* Pálya keret */
.canvas-wrap{
  position:relative;
  flex:1;
  min-height:0;
  border-radius: var(--r);
  border:1px solid rgba(27,31,63,.85);
  background:
    radial-gradient(800px 600px at 30% 15%, rgba(0,229,255,.10), transparent 60%),
    radial-gradient(800px 600px at 75% 80%, rgba(168,85,247,.10), transparent 65%),
    linear-gradient(180deg, rgba(15,17,38,.90), rgba(9,10,22,.92));
  box-shadow: var(--shadow), 0 0 30px rgba(0,229,255,.06), 0 0 36px rgba(168,85,247,.05);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  padding: 14px;
}

/* A canvas NE torzuljon: mindig 1:2 arány (szélesség:magasság) */
#game{
  display:block;
  width:auto;
  height:auto;
  max-width:100%;
  max-height:100%;
  aspect-ratio: 1 / 2;
  touch-action: none;
  image-rendering: auto;
}

.canvas-glow{
  pointer-events:none;
  position:absolute;
  inset:-30px;
  background:
    radial-gradient(300px 220px at 35% 30%, rgba(0,229,255,.18), transparent 70%),
    radial-gradient(300px 220px at 70% 70%, rgba(168,85,247,.16), transparent 70%);
  filter: blur(10px);
  opacity:.7;
}

/* =========================
   Jobb oldali panel (Side)
   ========================= */

.side-col{
  min-height:0;
  min-width:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  gap:10px;
  width:360px;
  max-width:360px;
  justify-self:end;
}

.panel{width:100%; min-width:0}

.card{
  border-radius: var(--r);
  border:1px solid rgba(27,31,63,.85);
  background: linear-gradient(180deg, rgba(15,17,38,.92), rgba(9,10,22,.90));
  box-shadow: 0 14px 36px rgba(0,0,0,.38);
  padding: 10px;
  margin:0;
  min-width:0;
}

.card-title{
  font-weight:900;
  letter-spacing:.4px;
  margin-bottom:8px;
  font-size:14px;
  line-height:1.2;
}

/* Statisztika blokk */
.stats{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:8px;
  min-width:0;
}

.stat{
  padding:8px;
  border-radius:14px;
  background: rgba(7,7,20,.55);
  border:1px solid rgba(27,31,63,.7);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
  min-width:0;
}
.stat-label{color:var(--muted); font-size:11px}
.stat-value{font-weight:900; font-size:18px; margin-top:2px}

/* Következő / Hold blokk */
.next-stack{
  display:flex;
  flex-direction:column;
  gap:8px;
  min-width:0;
}

.mini{
  width:100%;
  height:auto;
  border-radius:14px;
  border:1px solid rgba(27,31,63,.7);
  background: rgba(7,7,20,.55);
  box-shadow: inset 0 0 0 1px rgba(0,229,255,.04);
  display:block;
  max-width:100%;
}

.mini.hold{aspect-ratio: 1 / 1}

.hint, .mini-hint, .muted{
  color:var(--muted);
  font-size:11px;
  margin-top:6px;
}

/* Vezérlés és Műveletek panel elrejtése oldalt (beállításokba kerülnek) */
.side-col .panel.card:nth-of-type(4),
.side-col .panel.card:nth-of-type(5){
  display:none !important;
}

/* =========================
   Modal
   ========================= */

/* PC-n ezek alapból rejtve vannak (mobilon a mobil.css fogja megjeleníteni) */
.mobile-stats{display:none}
.mobile-controls{display:none}

.modal{
  position: fixed;
  inset: 0;
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  padding-top: calc(18px + var(--safeTop));
  padding-bottom: calc(18px + var(--safeBot));
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(10px);
  z-index: 1000;
}
.modal.active{display:flex}

.modal-content{
  width: min(920px, 100%);
  max-height: min(86vh, 760px);
  overflow:auto;
  border-radius: 22px;
  border: 1px solid rgba(0,229,255,.25);
  background:
    radial-gradient(900px 700px at 10% 0%, rgba(0,229,255,.12), transparent 58%),
    radial-gradient(900px 700px at 90% 100%, rgba(168,85,247,.10), transparent 62%),
    linear-gradient(180deg, rgba(15,17,38,.95), rgba(9,10,22,.96));
  box-shadow: var(--shadow), 0 0 34px rgba(0,229,255,.08);
}

.modal-head{
  position:sticky;
  top:0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 12px;
  border-bottom:1px solid rgba(27,31,63,.75);
  background: linear-gradient(180deg, rgba(15,17,38,.96), rgba(12,13,28,.92));
  backdrop-filter: blur(10px);
  z-index: 1;
}

.modal-title{font-weight:900; letter-spacing:.4px}
.icon-btn{
  appearance:none;
  border:1px solid rgba(27,31,63,.9);
  background: rgba(7,7,20,.55);
  color:var(--text);
  width:42px; height:42px;
  border-radius:14px;
  cursor:pointer;
}
.icon-btn:hover{border-color: rgba(0,229,255,.45)}
.icon-btn:active{transform: translateY(1px)}

.modal-body{padding: 14px}
.modal-text{margin:0 0 12px; color:var(--muted)}

.modal-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:12px;
}

.modal-tabs{
  display:flex;
  gap:10px;
  padding: 10px 12px 0;
  flex-wrap:wrap;
}
.tab{
  appearance:none;
  border:1px solid rgba(27,31,63,.9);
  background: rgba(7,7,20,.55);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
  font-weight:900;
}
.tab.active{
  border-color: rgba(0,229,255,.35);
  box-shadow: 0 10px 22px rgba(0,229,255,.08);
}

.tabpane{display:none}
.tabpane.active{display:block}

.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}
.field{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px;
  border-radius:14px;
  background: rgba(7,7,20,.45);
  border:1px solid rgba(27,31,63,.7);
  min-width:0;
}
.field-label{font-weight:900}
.field-hint{color:var(--muted); font-size:12px}
.field input[type="range"]{width:100%}
.field select, .field input[type="text"]{
  width:100%;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid rgba(27,31,63,.9);
  background: rgba(9,10,22,.85);
  color:var(--text);
  outline:none;
}
.field select:focus, .field input[type="text"]:focus{
  border-color: rgba(0,229,255,.45);
  box-shadow: 0 0 0 3px rgba(0,229,255,.12);
}


/* =========================
   MODAL: ne legyen belső scrollbar (PC + mobil)
   ========================= */

/* A modál tartalma ne scrollozzon belül */
.modal-content{
  max-height: none !important;
  overflow: visible !important;
}

/* A modál háttér réteg se kényszerítsen belső scrollt */
.modal{
  overflow: visible !important;
}

/* (opcionális, de ajánlott) a body továbbra se mozogjon modál alatt */
body{
  overflow: hidden;
}


/* Checkbox sor – PC és mobil kompatibilis */
.check-row{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}
.check-row input[type="checkbox"]{
  width:18px;
  height:18px;
  flex:0 0 auto;
  accent-color: var(--neonC);
}

.pill-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(27,31,63,.75);
  background: rgba(7,7,20,.55);
  color:var(--muted);
  font-size:12px;
  font-weight:800;
}

.help-wrap{display:flex; flex-direction:column; gap:12px; min-width:0}
.help-top{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.small{font-size:12px}
.readme{
  border-radius: 18px;
  border:1px solid rgba(27,31,63,.8);
  background: rgba(7,7,20,.45);
  padding: 14px;
  overflow:auto;
  max-height: 52vh;
  line-height:1.55;
}
.readme-placeholder{color:var(--muted)}
.readme h2, .readme h3{margin: 12px 0 8px}
.readme code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(0,0,0,.35);
  border:1px solid rgba(27,31,63,.75);
  padding:2px 6px;
  border-radius:10px;
}
.readme pre{
  background: rgba(0,0,0,.35);
  border:1px solid rgba(27,31,63,.75);
  padding:12px;
  border-radius:16px;
  overflow:auto;
}
.readme pre code{background: transparent; border:0; padding:0}

.scores-actions{margin-bottom:10px}
.scores-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.score-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  border-radius:14px;
  background: rgba(7,7,20,.45);
  border:1px solid rgba(27,31,63,.7);
}
.score-left{display:flex; align-items:center; gap:10px; min-width:0}
.badge{
  width:28px; height:28px;
  border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-weight:900;
  background: rgba(0,229,255,.10);
  border:1px solid rgba(0,229,255,.25);
  flex:0 0 auto;
}
.score-name{font-weight:900; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.score-points{font-weight:900; color:rgba(234,240,255,.92); flex:0 0 auto}

.save-box{display:flex; flex-direction:column; gap:12px}
.toast{min-height: 18px; color:var(--muted); font-size:12px}

/* Biztonsági: pause modal soha ne jelenjen meg */
#modalPause{ display:none !important; }

/* =========================
   2) PC NÉZET (900px+)
   ========================= */

/* PC-n a mini canvasok mérete (Következő + Tartalék) */
@media (min-width: 900px){
  /* Következő (3) vásznak */
  .side-col .panel.card:nth-of-type(2) .next-stack canvas.mini{
    width: 90px !important;
    max-width: 90px !important;
    height: auto !important;
    margin: 0 auto;
    border-radius: 12px;
  }

  /* Tartalék (Hold) vászon */
  .side-col .panel.card:nth-of-type(3) canvas.hold.mini{
    width: 90px !important;
    max-width: 90px !important;
    height: auto !important;
    margin: 0 auto;
    display: block;
  }

  /* Topbar igazítás desktopon */
  .topbar{
    max-width:1240px;
    margin:0 auto;
  }
}



/* =========================
   PC: Beállítások modal – letisztultabb elrendezés
   Csak a #modalSettings-re vonatkozik
   ========================= */

#modalSettings .modal-body{
  padding: 16px;
}

/* Két oszlop, de rendezettebb, kisebb katyvasz */
#modalSettings .form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-items:start;
}

/* Mezők: kevesebb "doboz" érzés */
#modalSettings .field{
  padding: 12px;
  border-radius: 16px;
  background: rgba(7,7,20,.28);              /* enyhébb háttér */
  border: 1px solid rgba(27,31,63,.55);      /* finomabb keret */
  box-shadow: none;                           /* ne legyen túl sok árnyék */
}

/* Címkék és hint szellősebbek */
#modalSettings .field-label{
  font-size: 13px;
  letter-spacing: .2px;
}

#modalSettings .field-hint{
  font-size: 11px;
  margin-top: 2px;
}

/* Gyorsbillentyűk blokk: ne legyen túl széles “szétfolyó” */
#modalSettings .pill-row{
  gap: 6px;
}

#modalSettings .pill{
  font-size: 11px;
  padding: 6px 10px;
  background: rgba(7,7,20,.40);
}

/* Tab gombok: egységesebb, kevésbé harsány */
#modalSettings .modal-tabs{
  padding: 10px 12px 0;
  gap: 8px;
}

#modalSettings .tab{
  padding: 9px 12px;
  border-radius: 14px;
}

/* Kész gomb: maradjon alul, ne ússzon el */
#modalSettings .modal-actions{
  margin-top: 14px;
}


/* 900–1100px között egymás alá (tablet / kisebb desktop) */
@media (min-width: 900px) and (max-width: 1100px){
  .main{
    grid-template-columns: 1fr;
    max-width: 980px;
  }
  .game-col{
    max-width: 980px;
    justify-self:start;
  }
  .side-col{
    display:flex;
    width:100%;
    max-width: 980px;
    justify-self:start;
    overflow:hidden;
  }
}

