/* ===== Tesztelői belépőkapu ===== */
.access-gate {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2a2150, #14132a 70%);
  padding: 20px;
}
.access-box {
  width: min(420px, 92vw); text-align: center; color: #eef;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 18px; padding: 28px 26px; box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.access-logo { width: 120px; height: 120px; object-fit: contain; border-radius: 16px; margin-bottom: 14px; }
.access-title { margin: 0 0 6px; font-size: 19px; font-weight: 800; color: #fff; }
.access-sub { margin: 0 0 18px; font-size: 13px; color: #b9b9d8; line-height: 1.5; }
.access-sub-en { color: #8e8eb5; font-style: italic; }
.access-input {
  width: 100%; box-sizing: border-box; padding: 12px 14px; font-size: 15px;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 11px;
  background: rgba(255,255,255,0.06); color: #fff; text-align: center; letter-spacing: .5px;
}
.access-input::placeholder { color: #8e8eb5; }
.access-input:focus { outline: none; border-color: #8a7bff; box-shadow: 0 0 0 3px rgba(138,123,255,0.25); }
.access-submit {
  width: 100%; margin-top: 12px; padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
  border: none; border-radius: 11px; color: #fff;
  background: linear-gradient(120deg, #6d4bff, #4f7cff);
}
.access-submit:hover { filter: brightness(1.08); }
.access-err { margin-top: 12px; color: #ff9a9a; font-size: 13px; font-weight: 600; }
@media print { .access-gate { display: none !important; } }

:root {
  --light: #e9edfb;
  --dark: #a7b1e6;
  --frame: #242a52;
  --coord-color: #ffffff;
  --coord-size: 18px;
  --coord-weight: 700;
  --coord-font: "Inter", sans-serif;
  --coord-min: 32px;                 /* a koordináta helyigénye (JS állítja) */
  --frame-size: 30px;                /* kívánt keretvastagság */
  --square: clamp(40px, 8.2vmin, 78px);
  --piece-scale: 0.9;                  /* figura/ikon mérete a mezőn belül (50–100%) */
  --corner-radius: 16px;               /* tábla (mezők) sarok lekerekítése (0 = szögletes) */
  --frame-corner-radius: 16px;         /* keret külső sarok lekerekítése (0 = szögletes) */
  /* A keret automatikusan vastagabb lesz, ha a koordináta nem férne el */
  --coord-strip: max(var(--frame-size), var(--coord-min));
  --panel-w: 320px;

  /* Logó-paletta: neon cián → kék → ibolya, világos felületen */
  --cyan: #06b6d4;
  --blue: #4f7cff;
  --violet: #9333ea;
  --accent: #6d4bff;          /* reprezentatív kiemelőszín */
  --grad: linear-gradient(135deg, var(--cyan) 0%, var(--blue) 50%, var(--violet) 100%);
  --danger: #ef3e6d;
  --ink: #1b2148;             /* fő szövegszín */
  --muted: #5a6385;          /* halvány szöveg */
  --panel-bg: rgba(255, 255, 255, 0.82);
  --hairline: rgba(109, 75, 255, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 16% 10%, rgba(109, 75, 255, 0.12), transparent 60%),
    radial-gradient(900px 620px at 88% 90%, rgba(6, 182, 212, 0.12), transparent 60%),
    linear-gradient(160deg, #f6f8ff 0%, #eaeefb 100%);
  background-attachment: fixed;
  /* Másolás-gátlás: kijelölés tiltva (űrlapelemeknél engedve) */
  user-select: none;
  -webkit-user-select: none;
}
body {
  display: flex;
  align-items: center;
  justify-content: center;
}
input, textarea, select { user-select: text; }
img { -webkit-user-drag: none; user-drag: none; }

/* ============ Tárhely (feladattár) modal ============ */
.db-modal {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(11, 13, 24, 0.55);
  backdrop-filter: blur(4px);
}
.db-modal.hidden { display: none; }
.db-box {
  width: min(1000px, 94vw); height: min(86vh, 760px);
  display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.db-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--ink); color: #fff;
}
.db-head h2 { margin: 0; font-size: 18px; }
.db-head-btns { display: flex; gap: 8px; }
.db-close, .db-min, .db-max { border: none; background: rgba(255,255,255,.15); color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 16px; cursor: pointer; line-height: 1; }
.db-close:hover, .db-min:hover, .db-max:hover { background: rgba(255,255,255,.28); }
/* Teljes képernyő */
.db-modal.maxed .db-box { width: 100vw; height: 100vh; border-radius: 0; }
/* Tálca (lekicsinyített ablak) */
#db-taskbar { position: fixed; left: 20px; bottom: 20px; z-index: 1490; display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: none; border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#db-taskbar:hover { background: var(--accent); }
#db-taskbar.hidden { display: none; }
#db-taskbar .tb-up { opacity: .8; }
.db-body { flex: 1; display: flex; min-height: 0; }
.db-left { width: 290px; flex: 0 0 auto; padding: 18px; overflow-y: auto; border-right: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 8px; }
.db-left h3 { margin: 4px 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.db-left input, .db-left select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--hairline); border-radius: 8px;
  font-size: 13px; background: #fff; color: var(--ink); box-sizing: border-box;
}
.db-left label { font-size: 12px; color: var(--muted); }
.db-fld-label { font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: -2px; }
.db-left hr { border: none; border-top: 1px solid var(--hairline); width: 100%; margin: 6px 0; }
.db-folder-label { font-size: 11px; color: var(--muted); word-break: break-all; }
.db-struct { font-size: 10px; color: var(--muted); margin: 2px 0 4px; }
.db-cloud-row { display: flex; gap: 6px; flex-wrap: wrap; }
.db-cloud-row .db-mini { flex: 1 1 auto; }
.db-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.db-mini { border: 1px solid var(--hairline); background: rgba(109,75,255,.08); color: var(--accent); border-radius: 7px; font-size: 12px; padding: 5px 9px; cursor: pointer; }
.db-mini:hover { background: rgba(109,75,255,.16); }
/* Mentett leírások chip-ek */
.db-descs { display: flex; flex-wrap: wrap; gap: 6px; max-height: 110px; overflow-y: auto; }
.db-desc-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(109,75,255,.08); border: 1px solid var(--hairline); border-radius: 14px; padding: 3px 4px 3px 9px; font-size: 12px; color: var(--ink); }
.db-desc-chip .t { cursor: pointer; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-desc-chip .x { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 12px; line-height: 1; padding: 2px; }
/* Mappafa */
.db-folders-head { display: flex; align-items: center; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.db-folders { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow-y: auto; }
.db-folder { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 8px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink); }
.db-folder:hover { background: rgba(109,75,255,.07); }
.db-folder.sel { background: rgba(109,75,255,.16); font-weight: 600; }
.db-folder .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-folder .fdel { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 12px; opacity: 0; flex: 0 0 auto; }
.db-folder:hover .fdel { opacity: 1; }
/* Jobb oldal: eszköztár + feladatok + PDF sáv */
.db-right { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #f6f8ff; }
.db-right-bar { display: flex; align-items: center; gap: 6px; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.db-clip { font-size: 11px; color: var(--muted); margin-left: auto; }
.db-tasks { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-content: start; }
.db-tasks:empty::after { content: attr(data-empty); color: var(--muted); font-size: 13px; }
.db-task { border: 1px solid var(--hairline); border-radius: 10px; background: #fff; padding: 8px; position: relative; }
.db-task img { width: 100%; border-radius: 6px; display: block; background: #eef1fb; }
.db-task .db-seq { position: absolute; top: 8px; right: 10px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.db-task .db-task-cap { font-size: 12px; font-weight: 600; color: var(--ink); margin: 6px 0 4px; }
/* 6 oszlopos rács: 1. sor ↑ ↓ ✎ (2-2-2), 2. sor Betöltés / Törlés (3-3) – sosem lóg ki */
.db-task .db-task-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.db-task .db-task-actions button { min-width: 0; border: 1px solid var(--hairline); background: rgba(109,75,255,.08); color: var(--accent); border-radius: 7px; font-size: 11px; padding: 5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-task .db-task-actions .up { grid-column: span 2; }
.db-task .db-task-actions .down { grid-column: span 2; }
.db-task .db-task-actions .edit { grid-column: span 2; }
.db-task .db-task-actions .load { grid-column: 1 / 4; }
.db-task .db-task-actions .del { grid-column: 4 / 7; color: var(--danger); }
.db-task .db-sel { position: absolute; top: 10px; left: 10px; width: 18px; height: 18px; cursor: pointer; }
.db-pdfbar { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--hairline); background: #fff; }
.db-pdfbar > input, .db-pdfbar > textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 13px; box-sizing: border-box; font-family: inherit; resize: vertical; }
.db-pdfrow { display: flex; align-items: center; gap: 8px; }
.db-pdfrow select { padding: 8px 9px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 13px; background: #fff; color: var(--ink); }
.db-pdfrow > .db-fld-label { margin-bottom: 0; }
.db-pdfrow .btn { margin-left: auto; white-space: nowrap; }
.db-pdfchecks { display: flex; flex-wrap: wrap; gap: 14px; }
.db-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.db-chk input { cursor: pointer; }

/* PDF nyomtatási nézet */
#print-area { display: none; }
@media print {
  .app, .lang-switch, .toast, .db-modal, #db-taskbar, .piece-popup, .index-input { display: none !important; }
  #print-area { display: block !important; }
  /* margin:0 → a böngésző NEM ír dátumot/címet/URL-t a lapszélre; saját fejléc/láblécet rajzolunk */
  @page { size: A4; margin: 0; }
}
.print-page { position: relative; overflow: hidden; box-sizing: border-box; width: 210mm; height: 297mm; padding: 12mm 12mm 6mm; display: flex; flex-direction: column; break-after: page; page-break-after: always; }
/* Free PDF-vízjel: nagy, átlós „ChessPixel" csíkok az egész oldalon (a tábla-kép vízjelén felül) */
.print-wm { position: absolute; top: 50%; left: 50%; width: 160%; height: 160%; transform: translate(-50%, -50%) rotate(-32deg); transform-origin: center; display: flex; flex-direction: column; align-items: center; justify-content: space-between; pointer-events: none; z-index: 5; }
.print-wm-row { white-space: nowrap; font-size: 30pt; font-weight: 800; letter-spacing: 8px; text-transform: uppercase; color: rgba(82,96,150,0.14); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-header { flex: 0 0 auto; min-height: 7mm; text-align: center; font-size: 13pt; font-weight: 600; color: #000; padding-bottom: 3mm; }
.print-footer { flex: 0 0 auto; margin-top: 4mm; display: flex; align-items: flex-end; justify-content: space-between; gap: 6mm; font-size: 9pt; color: #555; padding-top: 3mm; border-top: 0.3mm solid #ccc; }
.print-footer .pf-company { white-space: pre-line; text-align: left; line-height: 1.35; }
.print-footer .pf-meta { white-space: nowrap; text-align: right; color: #555; }
/* Fix márka-sor – mindig az oldal alján */
.print-brand { flex: 0 0 auto; margin-top: 2mm; text-align: center; font-size: 8pt; color: #888; }
.print-brand a { color: #888; text-decoration: none; }
/* Háttér sémák (a feladatok mindig fehér kártyán maradnak) */
.print-page.pbg-white { background: #fff; }
.print-page.pbg-gray { background: #f1f3f8; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-page.pbg-blue { background: #eef3fc; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-page.pbg-grid { background: #ffffff; background-image: linear-gradient(rgba(70,90,150,.07) 0.2mm, transparent 0.2mm), linear-gradient(90deg, rgba(70,90,150,.07) 0.2mm, transparent 0.2mm); background-size: 8mm 8mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-page.pbg-gray .print-cell, .print-page.pbg-blue .print-cell, .print-page.pbg-grid .print-cell { background: #fff; border: 0.3mm solid #e2e6f0; border-radius: 3mm; box-shadow: 0 0.4mm 1.4mm rgba(0,0,0,.06); padding: 4mm; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.print-grid { flex: 1 1 auto; min-height: 0; display: grid; gap: 6mm; }
.print-grid.per-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.print-grid.per-2 { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.print-grid.per-3 { grid-template-columns: 1fr; grid-template-rows: repeat(3, 1fr); }
.print-grid.per-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.print-grid.per-6 { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); }
.print-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; break-inside: avoid; min-height: 0; }
.print-cell .num { flex: 0 0 auto; font-size: 12pt; font-weight: 700; color: #000; margin-bottom: 2mm; }
.print-cell img { max-width: 100%; max-height: 78%; object-fit: contain; }
.print-cell .cap { flex: 0 0 auto; font-size: 10pt; font-weight: 600; margin-top: 3mm; text-align: center; color: #000; }

/* Megosztás ablak */
.share-modal { position: fixed; inset: 0; z-index: 1600; display: flex; align-items: center; justify-content: center; background: rgba(11,13,24,.55); backdrop-filter: blur(4px); }
.share-modal.hidden { display: none; }
.share-box { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.share-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--ink); color: #fff; border-radius: 18px 18px 0 0; }
.share-head h2 { margin: 0; font-size: 18px; }
.share-close { border: none; background: rgba(255,255,255,.15); color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 16px; cursor: pointer; }
.share-close:hover { background: rgba(255,255,255,.28); }
.share-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.share-thumb { width: 160px; align-self: center; border-radius: 10px; background: #eef1fb; display: block; }
.share-fmt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.share-fmt button { min-width: 34px; height: 34px; border: 1px solid var(--hairline); background: #fff; border-radius: 8px; font-size: 15px; cursor: pointer; }
.share-fmt button:hover { background: rgba(109,75,255,.1); }
.share-fmt-sep { width: 1px; height: 22px; background: var(--hairline); margin: 0 2px; }
.share-body textarea { width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 10px; font-size: 14px; font-family: inherit; resize: vertical; color: var(--ink); }
.share-hint { font-size: 11px; color: var(--muted); }
.share-primary { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; border: none; border-radius: 12px; background: linear-gradient(120deg, var(--accent), var(--blue)); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
.share-primary:hover { filter: brightness(1.06); }
.share-primary .sp-ic { font-size: 18px; }
.share-secondary { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px; border: 1px solid var(--hairline); border-radius: 12px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; }
.share-secondary:hover { background: rgba(31,38,80,.05); }
.share-secondary .sp-ic { font-size: 16px; }
.share-or { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.share-platform { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--hairline); border-radius: 10px; background: #fff; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; }
.share-platform:hover { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 8%, #fff); }
.share-platform .sp-ic { flex: 0 0 26px; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--pc); color: #fff; font-size: 14px; font-weight: 800; }
.share-platform .sp-lb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Rövid értesítés (toast) */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  max-width: 90vw; text-align: center;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* Nyelvválasztó (fix, jobb felső sarok) */
/* Fiókkezelő fül */
.acct-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline);
}
.acct-label { font-size: 12px; color: var(--muted); }
.acct-val { font-size: 13px; font-weight: 600; color: var(--ink); text-align: right; }
.acct-lang {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.acct-key-btn { display: block; text-align: center; text-decoration: none; }

/* Tx: lépésjegyzet */
.mv-controls { display: flex; gap: 8px; margin-bottom: 10px; }
.mv-controls .btn { flex: 1 1 0; }
#mv-toggle.is-on { background: linear-gradient(120deg, #e2403b, #ff7a59); }
.mv-copy { width: 100%; margin: 8px 0; }
.mv-out { min-height: 120px; max-height: 46vh; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--hairline); border-radius: 10px; background: #fff; color: var(--ink); font-size: 15px; line-height: 2; user-select: text; -webkit-user-select: text; }
.mv-out:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.mv-num { color: var(--muted); font-weight: 700; }
.mv-move { white-space: nowrap; font-weight: 600; cursor: pointer; padding: 1px 3px; border-radius: 5px; }
.mv-move:hover { background: rgba(109,75,255,.1); }
.mv-move.is-active { background: var(--grad); color: #fff; }
.mv-fig { height: 1.05em; width: auto; vertical-align: -0.18em; }
.mv-empty { color: var(--muted); font-size: 13px; line-height: 1.5; font-weight: 400; cursor: default; }
/* Értékelő jelek */
.mv-annot-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin: 10px 0 4px; }
.mv-annot { display: flex; flex-wrap: wrap; gap: 5px; }
.mv-asym { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid var(--hairline); background: rgba(109,75,255,.06); color: var(--ink); border-radius: 8px; font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer; }
.mv-asym:hover { background: rgba(109,75,255,.14); border-color: var(--blue); }
/* kompenzáció: ∞ az egyenlőség fölött (stackelt) */
.mv-comp { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: .82; font-size: .8em; vertical-align: middle; }
.mv-comp span { display: block; }
.mv-asym .mv-comp { font-size: 13px; }
/* egyetlen lépés négyzete – teljes betűméretű, CSS-rajzolt keret */
.mv-sq { display: inline-block; width: .68em; height: .68em; border: .13em solid currentColor; box-sizing: border-box; vertical-align: -0.02em; border-radius: 1px; margin: 0 .04em; }
.mv-asym .mv-sq { width: 15px; height: 15px; border-width: 2px; vertical-align: middle; }
/* emojik a jegyzetben + gombon */
.mv-emo { display: inline-block; font-size: 1.04em; vertical-align: -0.12em; margin: 0 .03em; }
.mv-asym .mv-emo { font-size: 17px; vertical-align: middle; }
/* játszma eredménye */
.mv-res { font-weight: 700; margin-left: .15em; white-space: nowrap; }
.mv-asym .mv-res { margin-left: 0; }

/* Háttérréteg a feltöltött képnek */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.app {
  position: relative;
  z-index: 1;
  width: 90vw;
  height: 90vh;
  display: flex;
  align-items: stretch;       /* a két konténer egyforma (teljes) magasságú */
  justify-content: center;
  gap: clamp(12px, 2vw, 28px);
}

/* ============ KONTÉNEREK (bal/jobb, egyforma méret) ============ */
.panel {
  flex: 0 0 auto;
  width: clamp(250px, 24vw, 360px);
  max-height: 100%;
  overflow-y: auto;           /* lefelé görgethető */
  overflow-x: hidden;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(31, 38, 80, 0.16),
              inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Bal oldali oszlop: logó (külön) + konténer */
.side--left {
  flex: 0 0 auto;
  width: clamp(250px, 24vw, 360px);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel--left {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
}
/* Jobb oldali oszlop: rajzeszközök (külön) + beállítások konténer */
.side--right {
  flex: 0 0 auto;
  width: clamp(250px, 24vw, 360px);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel--draw { width: 100%; flex: 0 0 auto; max-height: none; }
.side--right .panel--right { width: 100%; flex: 1 1 auto; min-height: 0; max-height: none; display: flex; flex-direction: column; }
/* A fülnav fix magasságú; a fülek alapból természetes magasságúak (a panel görget), az Info fül viszont kitölti a maradékot */
.panel--right > .seg { flex: 0 0 auto; }
.panel--right > .tabpane { flex: 0 0 auto; }
.panel--right > .tabpane[data-pane="info"].is-active { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

.brand { flex: 0 0 auto; }
.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  border: 1px solid rgba(31, 38, 80, 0.12);
  box-shadow: 0 12px 28px rgba(31, 38, 80, 0.24);
}

/* Készletfülek + gombok egy sorban */
.set-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.set-bar .set-tabs { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }

/* Figurakészlet-fülek */
.set-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.set-tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  background: rgba(109, 75, 255, 0.07);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.set-tab.is-active { background: var(--grad); border-color: transparent; color: #fff; }
.set-tab .set-name:focus { outline: none; }
.set-tab .set-name[contenteditable="true"] { cursor: text; }

/* + (betöltés) gomb */
.addbtn {
  width: 34px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--grad);
  color: #fff;
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.addbtn:hover { filter: brightness(1.08); }
.addbtn.disabled { opacity: .45; pointer-events: none; filter: grayscale(.4); }

/* Fő gombsor */
.seg {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.seg__btn {
  flex: 1;
  padding: 10px 6px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(109, 75, 255, 0.07);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg__btn:hover { box-shadow: 0 0 0 1px var(--blue) inset; }
.seg__btn.is-active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 124, 255, 0.35);
}
.seg__btn:active { transform: translateY(1px); }
.seg__btn--icon { flex: 1 1 0; min-width: 0; font-size: 17px; padding: 10px 0; }

/* Rajz – színpaletta + fogaskerék */
.draw-colors-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.draw-colors { display: flex; gap: 10px; flex: 1 1 auto; }
.draw-swatch {
  flex: 1;
  height: 38px;
  border-radius: 10px;
  border: 2px solid rgba(31, 38, 80, 0.15);
  cursor: pointer;
  position: relative;
}
.draw-swatch.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent);
}
/* Szerkesztő mód: a minták jelezzék, hogy szín módosítható */
.draw-colors.editing .draw-swatch { cursor: pointer; outline: 2px dashed var(--accent); outline-offset: 2px; }
.color-gear {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--hairline); background: rgba(109, 75, 255, 0.07);
  color: var(--accent); font-size: 16px; cursor: pointer; line-height: 1;
}
.color-gear:hover { box-shadow: 0 0 0 1px var(--blue) inset; }
.color-gear.is-active { background: var(--grad); border-color: transparent; color: #fff; }
.color-gear.hidden { display: none; }

/* Rajz – eszközgombok */
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.tool-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 10px 8px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: rgba(109, 75, 255, 0.07);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.tool-btn:hover { box-shadow: 0 0 0 1px var(--blue) inset; }
.tool-btn.is-active {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(79, 124, 255, 0.3);
}
/* Billentyűkombináció-jelzés (kbd) */
.tkbd {
  flex: 0 0 auto; font-family: inherit; font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px; line-height: 1.4;
  background: rgba(31, 38, 80, 0.1); color: var(--ink);
  border: 1px solid rgba(31, 38, 80, 0.12);
}
.tool-btn.is-active .tkbd { background: rgba(255,255,255,.25); color: #fff; border-color: rgba(255,255,255,.35); }
/* Rajzok törlése: ugyanakkora, mint a többi rajzeszköz-gomb (a rácsban), finom piros árnyalattal */
.draw-clear-btn { background: rgba(226, 64, 59, 0.08); color: #c0392b; border-color: rgba(226, 64, 59, 0.25); }
.draw-clear-btn:hover { box-shadow: 0 0 0 1px rgba(226, 64, 59, .5) inset; }
.draw-clear-btn .tlbl { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.draw-clear-btn .clr-ic { font-size: 14px; }
.draw-clear-btn .tkbd { background: rgba(226, 64, 59, 0.12); color: #c0392b; border-color: rgba(226, 64, 59, 0.22); }

.tabpane { display: none; }
.tabpane.is-active { display: block; }

/* Info box (reklám-névjegy – prémium) */
.premium-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: linear-gradient(120deg, #f5b301, #ff7a59); color: #3a2a00; font-size: 12px; font-weight: 800; margin: 4px 0 10px; }
.info-intro { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.info-logo-btn { width: 100%; text-align: center; }
.info-logo-hint { font-size: 11px; color: var(--muted); margin: 6px 0 0; text-align: center; }
.info-logo-preview { display: block; max-width: 100%; max-height: 80px; margin: 2px auto 4px; object-fit: contain; border-radius: 8px; }
.info-note { font-size: 11px; color: var(--muted); margin: 12px 0 0; font-style: italic; }

/* Névjegy-előnézet az Info box fülön – kitölti a fül magasságát; a kártya méret-konténer,
   így a logó a tényleges rendelkezésre álló helyhez tud igazodni (cqw/cqh egységek). */
.ib-card { border: none; border-radius: 0; background: transparent; padding: 0; box-shadow: none; flex: 1 1 auto; min-height: 0; container-type: size; display: flex; flex-direction: column; align-items: center; }
.ib-logo { cursor: pointer; flex: 0 0 auto; width: 100%; display: flex; justify-content: center; }
/* ChessPixel 1:1 logó placeholder + „LOGÓD HELYE" felirat a kép alján – nagy, keret nélkül.
   A logó négyzet (aspect-ratio), szélessége = min(kártyaszélesség, elérhető magasság − csíkhely):
   ha a csík alatt marad hely, a logó a gombok széléig szélesedik; ha kevés a hely, lekicsinyül,
   hogy a kúszó csík mindig kiférjen alatta. A felirat a négyzet alján, vele azonos szélességben. */
.ib-logo-ph { position: relative; display: block; width: min(100cqw, calc(100cqh - 46px)); aspect-ratio: 1 / 1; margin: 0 auto; border-radius: 14px; overflow: hidden; }
.ib-logo-ph img,
.ib-logo.has-logo img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
/* „LOGÓD HELYE" sáv – fel-le pásztáz a logó aljától a tetejéig (a wrapper levágja a lekerekített sarkoknál) */
.ib-logo-cap { position: absolute; left: 0; right: 0; top: 0; text-align: center; font-size: 13px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; color: #fff; background: rgba(20,24,50,.78); padding: 6px 0; animation: ib-cap-scan 4s ease-in-out infinite alternate; will-change: transform; }
@keyframes ib-cap-scan { from { top: 0; transform: translateY(0); } to { top: 100%; transform: translateY(-100%); } }
@media (prefers-reduced-motion: reduce) { .ib-logo-cap { animation: none; top: auto; bottom: 0; transform: none; } }
/* Futó szalag a logó alatt */
.ib-marquee { flex: 0 0 auto; width: 100%; overflow: hidden; white-space: nowrap; margin-top: 12px; padding: 7px 0; border-radius: 9px; background: linear-gradient(120deg, var(--accent), var(--blue)); color: #fff; }
.ib-marquee-track { display: inline-block; white-space: nowrap; will-change: transform; animation: ib-scroll linear infinite; font-size: 12px; font-weight: 700; letter-spacing: .2px; }
.ib-marquee-track span { padding: 0; }
@keyframes ib-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ib-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 16px; }
.ib-ic { text-decoration: none; line-height: 0; }
.ib-ic-badge { display: inline-block; }
.ib-ic-badge svg { width: 46px; height: 46px; display: block; border-radius: 11px; box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.ib-ic.teaser { cursor: default; }
.ib-ic.teaser .ib-ic-badge { opacity: .4; }
.ib-ic:not(.teaser):hover .ib-ic-badge { transform: translateY(-2px); transition: transform .12s ease; }
.ib-cta { width: 100%; margin-top: 14px; }
.ib-cta.is-premium { background: var(--grad); }

/* Info box beállító modal */
.ib-modal { position: fixed; inset: 0; z-index: 1600; display: flex; align-items: center; justify-content: center; background: rgba(11,13,24,.55); backdrop-filter: blur(4px); }
.ib-modal.hidden { display: none; }

/* Túllépés-jelzés (ingyenes limit / lejárt előfizetés) – a tárhely-modal fölött is megjelenik */
.upg-modal { position: fixed; inset: 0; z-index: 2200; display: flex; align-items: center; justify-content: center; background: rgba(11,13,24,.55); backdrop-filter: blur(4px); }
.upg-modal.hidden { display: none; }
.upg-box { width: min(380px, 92vw); background: #fff; border-radius: 18px; padding: 26px 24px 20px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.upg-badge { width: 46px; height: 46px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 22px; color: #3a2a00; background: linear-gradient(120deg, #f5b301, #ff7a59); box-shadow: 0 6px 18px rgba(245,179,1,.4); }
.upg-box h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.upg-msg { margin: 0 0 18px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.upg-cta { display: block; width: 100%; text-align: center; text-decoration: none; margin-bottom: 8px; }
.upg-later { display: block; width: 100%; padding: 9px; border: none; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 10px; }
.upg-later:hover { background: rgba(31,38,80,.06); }
.ib-box { width: min(460px, 94vw); max-height: 92vh; display: flex; flex-direction: column; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.ib-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--ink); color: #fff; }
.ib-head-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.ib-head h2 { margin: 0; font-size: 18px; }
.ib-head .premium-badge { margin: 0; }
.ib-close { border: none; background: rgba(255,255,255,.15); color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 16px; cursor: pointer; }
.ib-close:hover { background: rgba(255,255,255,.28); }
.ib-mbody { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.ib-mbody input { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 13px; background: #fff; color: var(--ink); }
.info-fields-host { display: flex; flex-direction: column; gap: 8px; }
/* Átrendezhető névjegy-mező sorok (fel/le gomb + input) */
.info-row { display: flex; align-items: stretch; gap: 6px; }
.info-row input { width: auto; flex: 1 1 auto; min-width: 0; }
.info-reorder { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.info-up, .info-down { width: 24px; flex: 1 1 0; min-height: 0; padding: 0; line-height: 1; border: 1px solid var(--hairline); background: rgba(31,38,80,.05); color: var(--accent); border-radius: 6px; font-size: 9px; cursor: pointer; }
.info-up:hover, .info-down:hover { background: rgba(109,75,255,.14); }
.info-up:active, .info-down:active { transform: translateY(1px); }
.ib-foot { padding: 14px 18px; border-top: 1px solid var(--hairline); }
.ib-foot .btn { width: 100%; }

/* Stílusok lista */
#style-name { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid var(--hairline); border-radius: 8px; font-size: 13px; margin-bottom: 8px; }
.style-hint { font-size: 11px; color: var(--muted); margin: 8px 0 0; }
.style-list { display: flex; flex-direction: column; gap: 6px; }
.style-list:empty::after { content: attr(data-empty); color: var(--muted); font-size: 13px; }
.style-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--hairline); border-radius: 9px; background: rgba(109,75,255,.05); }
.style-row .style-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--ink); }
.style-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.style-acts button { border: 1px solid var(--hairline); background: rgba(109,75,255,.08); color: var(--accent); border-radius: 7px; font-size: 11px; padding: 5px 8px; cursor: pointer; }
.style-acts .del { color: var(--danger); }

/* Paletta fejléc + lakat */
.palette-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  opacity: .85;
}
.lockbtn {
  border: 1px solid var(--hairline);
  background: rgba(109, 75, 255, 0.08);
  color: var(--accent);
  width: 34px; height: 30px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}
.lockbtn[aria-pressed="true"] { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 0 14px rgba(6,182,212,.4); }
.lockbtn:hover { filter: brightness(1.05); }

/* Dropzone */
.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 2px dashed rgba(6, 182, 212, 0.5);
  border-radius: 12px;
  background: rgba(6, 182, 212, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  margin-bottom: 12px;
  text-align: left;
}
.dropzone:hover, .dropzone.is-drag {
  background: rgba(6, 182, 212, 0.14);
  border-color: var(--cyan);
}
.dropzone.disabled {
  display: none;
}
.dropzone__icon { font-size: 26px; line-height: 1; }
.dropzone__text { font-size: 14px; font-weight: 600; }
.dropzone__text small { font-weight: 400; color: var(--muted); font-size: 12px; }

/* Paletta */
.palette {
  display: grid;
  /* Az oszlopszám beállítható (2–6); a csempék az oszlopszélességgel négyzetesek,
     így több oszlop = kisebb csempék (helytakarékos). Sok figuránál a paletta görget. */
  grid-template-columns: repeat(var(--palette-cols, 3), minmax(0, 84px));
  grid-auto-rows: auto;
  justify-content: center;
  align-content: start;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  border-radius: 12px;
  background: rgba(31, 38, 80, 0.05);
  border: 1px solid rgba(31, 38, 80, 0.08);
  margin-bottom: 0;
  transition: background .15s ease, border-color .15s ease;
}
.palette:empty::after {
  content: "Húzz ide képeket, vagy a + gombbal tölts be";
  grid-column: 1 / -1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  align-self: center;
  padding: 18px 6px;
}
.palette.is-drag { border: 1px dashed var(--cyan); background: rgba(6, 182, 212, 0.12); }
.palette.locked { outline: 2px solid var(--cyan); outline-offset: 2px; box-shadow: 0 0 16px rgba(34,211,238,.3); }

.palette__item {
  position: relative;
  width: 100%;
  aspect-ratio: 1;                         /* négyzet csempe (az oszlopszélesség alapján) */
  min-height: 0;
  border-radius: 10px;
  overflow: visible;
  background: transparent;                 /* háttérmentes figurák */
  border: 1px solid rgba(31, 38, 80, 0.12);
}
/* Zárolt konténer: csak a csupasz, háttérmentes figurák látszanak */
.palette.locked .palette__item { border-color: transparent; }
.palette.locked .gearbtn { display: none; }
.palette.locked .palette__img { box-shadow: none; }
.palette__img {
  width: 100%;
  height: 100%;                            /* kitölti az elemet; a figura background-size:contain miatt arányos marad */
  border-radius: 9px;
  padding: 10%;
  background-origin: content-box;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  cursor: grab;
  touch-action: none;
}
.palette__img:active { cursor: grabbing; }

/* Fogaskerék (figura-meghatározás) a jobb felső sarokban */
.gearbtn {
  position: absolute;
  top: -7px; right: -7px;
  width: 21px; height: 21px;
  display: grid; place-items: center;
  border: 1px solid var(--hairline);
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  font-size: 11px; line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(31, 38, 80, 0.25);
  z-index: 2;
}
.gearbtn:hover { filter: brightness(1.05); }
.palette__item[data-type]:not([data-type=""]) .palette__img {
  box-shadow: inset 0 0 0 2px var(--cyan);
}

/* Figura-meghatározó popup – 12 sakkfigura ikonrács */
.piece-popup {
  position: fixed;
  z-index: 1000;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(31, 38, 80, 0.28);
}
.piece-popup.hidden { display: none; }
.pp-free {
  width: 100%;
  margin-bottom: 8px;
  padding: 6px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: rgba(109, 75, 255, 0.07);
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.pp-grid {
  display: grid;
  grid-template-columns: repeat(6, 34px);
  gap: 5px;
}
.promo-grid { grid-template-columns: repeat(4, 38px); }

/* Index szövegbeviteli mező */
.index-input {
  position: fixed;
  z-index: 1000;
  border: 2px solid var(--accent);
  border-radius: 5px;
  padding: 0 2px;
  text-align: center;
  font-weight: 700;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(31, 38, 80, 0.3);
}
.index-input.hidden { display: none; }
.knight-hint { pointer-events: none; }
.pp-role {
  width: 34px; height: 34px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background-color: #eef1fb;
  background-size: 84%;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}
.pp-role:hover { background-color: #dfe5fb; }
.pp-free.is-selected, .pp-role.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Húzott "szellem" figura */
.drag-ghost {
  position: fixed;
  width: 60px; height: 60px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: .85;
  z-index: 9999;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.45));
}

.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 8px 0 0; }

/* Mezők / beállítások */
.group-title {
  margin: 18px 0 10px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  border-top: 1px solid var(--hairline);
  padding-top: 14px;
}
/* Az első csoportcím (pl. a Rajzeszközök panel tetején) ne kapjon felesleges elválasztó vonalat */
.panel--draw .group-title:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
}
.field label { flex: 1; }
.field input[type="color"] {
  width: 44px; height: 30px;
  border: 2px solid var(--hairline);
  border-radius: 8px;
  background: none; padding: 0; cursor: pointer;
}
.field input[type="range"] { flex: 0 0 130px; accent-color: var(--cyan); }
.field select {
  flex: 0 0 150px;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  font-size: 13px;
  background: #ffffff; color: var(--ink);
  cursor: pointer;
}

/* Koordináta-kép feltöltő rács */
.coord-uploader { margin-top: 12px; }
.coord-uploader h4 { margin: 10px 0 6px; font-size: 12px; opacity: .85; }
.coord-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}
.coord-slot {
  aspect-ratio: 1;
  border-radius: 7px;
  background: rgba(109,75,255,.07) center/70% no-repeat;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid var(--hairline);
}
.coord-slot.has-img { color: transparent; }

/* Gombok */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 10px;
}
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; margin-bottom: 10px; }
.btn--primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(79,124,255,.3); }
.btn--ghost { background: rgba(109,75,255,.08); color: var(--accent); border: 1px solid var(--hairline); }
.btn:hover { filter: brightness(1.05); }

/* Gyors akció ikonok */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}
.iconbtn {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
  box-shadow: 0 6px 16px rgba(79,124,255,.32);
}
.iconbtn:hover { filter: brightness(1.1); }
.iconbtn:active { transform: translateY(1px); }
.iconbtn--danger { background: var(--danger); box-shadow: 0 6px 16px rgba(255,59,107,.35); }

/* ============ TÁBLA ============ */
.stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;           /* a canvas/tábla NEM görgethető */
}
.board-wrap {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;        /* a tábla középen */
  justify-content: center;
}

/* Tábla alatti gombsor – képes ikongombok */
.board-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.icon-tool {
  width: 58px;
  height: 58px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 15px;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, opacity .15s ease;
}
.icon-tool img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.icon-tool:hover { transform: translateY(-3px); filter: drop-shadow(0 6px 12px rgba(31, 38, 80, 0.3)); }
.icon-tool:active { transform: translateY(0); }
.icon-tool:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.5); transform: none; }

.board-frame {
  display: grid;
  grid-template-columns: var(--coord-strip) auto var(--coord-strip);
  grid-template-rows: var(--coord-strip) auto var(--coord-strip);
  background: var(--frame);
  border-radius: var(--frame-corner-radius);
}
/* Keret 0 → nincs látható keret (a keretszínű sávok átlátszók) */
.board-frame.frameless,
.board-frame.frameless .corner,
.board-frame.frameless .coords { background: transparent; }

.corner { background: var(--frame); position: relative; }
/* A keret külső sarkainak lekerekítése (a sarokcellákon, hogy ne kelljen overflow:hidden) */
.corner.tl { border-top-left-radius: var(--frame-corner-radius); }
.corner.tr { border-top-right-radius: var(--frame-corner-radius); }
.corner.bl { border-bottom-left-radius: var(--frame-corner-radius); }
.corner.br { border-bottom-right-radius: var(--frame-corner-radius); }

.coords {
  display: grid;
  background: var(--frame);
  color: var(--coord-color);
  font-size: var(--coord-size);
  font-weight: var(--coord-weight);
  font-family: var(--coord-font);
  user-select: none;
}
.coords--top, .coords--bottom {
  grid-template-columns: repeat(8, var(--square));
}
.coords--left, .coords--right {
  grid-template-rows: repeat(8, var(--square));
}
.coords span {
  display: grid;
  place-items: center;
}
.coords img {
  max-width: 80%;
  max-height: calc(var(--coord-size) + 6px);
  object-fit: contain;
}
/* Képes koordináta-ikon: valódi kép (mindig látszik), canvas-szal színezve */
.coords .coord-img-el {
  display: block;
  width: calc(var(--coord-size) + 8px);
  height: calc(var(--coord-size) + 8px);
  object-fit: contain;
}

/* Koordináta-stílusok: a betűtípus/vastagság a beállításból jön */
.coord-capital span { text-transform: uppercase; }

/* Ki lép? jelölő – a keret jobb felső sarkában */
.turn-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: calc(var(--coord-strip) * 0.6);
  height: calc(var(--coord-strip) * 0.6);
  min-width: 16px; min-height: 16px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.turn-dot[data-side="white"] { background: #ffffff; border: 2px solid #111111; }
.turn-dot[data-side="black"] { background: #111111; border: 2px solid #ffffff; }

.board-area {
  position: relative;
  width: calc(var(--square) * 8);
  height: calc(var(--square) * 8);
}
/* Tábla megfordítása (sötét oldaláról nézve): a tartalom 180°, a figurák visszafordítva állnak */
.board-area.flipped { transform: rotate(180deg); }
.board-area.flipped .piece { transform: translate(-50%, -50%) rotate(180deg); }
/* Free vízjel a táblán (b6, d4, h4, f6) – a figurák fölött, halványan */
.wm-layer { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
.wm-text { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: calc(var(--square) * 0.5); font-weight: 800; user-select: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.board-area.flipped .wm-text { transform: translate(-50%, -50%) rotate(180deg); }
.board {
  display: grid;
  grid-template-columns: repeat(8, var(--square));
  grid-template-rows: repeat(8, var(--square));
  width: 100%; height: 100%;
  border-radius: calc(var(--corner-radius) * 0.6);
  overflow: hidden;            /* lekerekített tábla-sarkok (a figurákat nem vágja) */
}
.square { width: var(--square); height: var(--square); }
.square.light { background: var(--light); }
.square.dark { background: var(--dark); }

.pieces-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Rajzrétegek (figurák alatt: kitöltés/keret/fal; felett: nyilak) */
.draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
/* A fal/kitöltés/keret réteget a táblaterület levágja, hogy a fal vége ne lógjon a keretre */
.draw-under { overflow: hidden; }
.draw-over.is-drawing {
  pointer-events: auto;
  cursor: crosshair;
}
.piece {
  position: absolute;
  width: calc(var(--square) * var(--piece-scale));
  height: calc(var(--square) * var(--piece-scale));
  background-size: contain;           /* arányhelyes: minden elem azonos befoglaló méret */
  background-position: center;
  background-repeat: no-repeat;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transform: translate(-50%, -50%);
  filter: var(--piece-shadow, drop-shadow(0 3px 4px rgba(0,0,0,.35)));
  transition: filter .1s ease;
}
.piece.dragging {
  cursor: grabbing;
  z-index: 50;
  filter: var(--piece-shadow-drag, drop-shadow(0 8px 12px rgba(0,0,0,.5)));
}

/* Reszponzív: szűk nézeten egymás alá kerülnek */
@media (max-width: 900px) {
  body { display: block; }
  .app {
    width: 100%;
    height: auto;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    gap: 16px;
  }
  .panel { width: min(100%, 480px); max-height: none; overflow: visible; }
  .side--left, .side--right { width: min(100%, 480px); height: auto; }
  .panel--left { display: block; }            /* stackelt nézetben ne flexeljen, az oldal görögjön */
  .palette { flex: none; max-height: none; overflow: visible; margin-bottom: 10px; } /* természetes magasság, az oldal görget */
  .stage { width: 100%; height: 72vh; }
  /* Stackelt nézetben az Info kártya sima blokk-folyam (nincs méret-konténer), fix négyzet logó */
  .side--right .panel--right { display: block; }
  .ib-card { container-type: normal; display: block; }
  .ib-logo { display: block; }
  .ib-logo-ph { width: min(100%, 240px); }
}

/* ===== Magasság-alapú igazítás (asztali nézet) – hogy alacsony kijelzőn is elférjen minden, a futó csíkkal együtt ===== */
/* Közepes magasság (pl. ~1080p tényleges böngésző-magasság): kicsit kisebb logó + tömörebb rajzpanel */
@media (min-width: 901px) and (max-height: 980px) {
  .panel--draw { padding: 14px; }
  .draw-colors-row { margin-bottom: 9px; }
  .draw-swatch, .color-gear { height: 32px; }
  .tools { gap: 6px; margin-bottom: 8px; }
  .tool-btn { padding: 8px 8px; }
}
/* Alacsony (pl. 1366×768 maximalizált böngésző, vagy 1080p nagyítással): kompakt logó + szorosabb rajzpanel */
@media (min-width: 901px) and (max-height: 850px) {
  .panel--draw { padding: 12px; }
  .group-title { margin: 10px 0 6px; padding-top: 8px; }
  .draw-swatch, .color-gear { height: 28px; }
  .tool-btn { padding: 6px 8px; font-size: 12px; }
  .palette__head, .set-bar { margin-bottom: 8px; }
}
/* Nagyon alacsony (pl. 1280×720 / erős nagyítás): a logó tovább zsugorodik, de a csík így is látszik */
@media (min-width: 901px) and (max-height: 720px) {
  .draw-swatch, .color-gear { height: 26px; }
  .tool-btn { padding: 5px 7px; }
}
