/* capybara.hu – meta-UI (skinek, trófeák, profil, feloldás-ünneplés)
 * A játék meglévő CSS-változóira épül (--panel, --text, --accent…),
 * így a világos/sötét téma automatikusan érvényesül. */

/* ---------- nav-gombok a kezdő/game over kártyán ---------- */
.cm-navrow {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 2px;
}
.cm-navbtn {
  position: relative;
  flex: 1 1 0;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cm-navbtn:active { transform: scale(0.95); }
.cm-navicon { font-size: 20px; line-height: 1; }
.cm-dot {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ff4d6d;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 2px 6px var(--shadow);
}
.cm-dot.hidden { display: none; }

/* ---------- teljes képernyős meta-oldalak ---------- */
.cm-screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  /* a --panel enyhén áttetsző; szolid alap alá rétegezve nem dereng át a játék */
  background: linear-gradient(var(--panel), var(--panel)), var(--bg-bottom);
  color: var(--text);
}
.cm-screen.hidden { display: none; }
.cm-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 2px solid var(--panel-border);
}
.cm-back {
  width: 42px;
  height: 42px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  background: transparent url(../assets/arrow_back.png) center / 24px 24px no-repeat;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cm-back:active { transform: scale(0.92); }
.cm-title { flex: 1; font-size: 20px; font-weight: 800; }
.cm-count { font-size: 14px; font-weight: 800; opacity: 0.7; font-variant-numeric: tabular-nums; }
.cm-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 12px 14px calc(20px + env(safe-area-inset-bottom));
}
/* a skin-előnézetek canvasok, amikre a játék globális canvas-szabálya
   touch-action: none-t tenne — itt görgetni kell tudni rajtuk is */
.cm-body canvas { touch-action: pan-y; }

/* ---------- közös elemek ---------- */
.cm-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 2px 8px;
}
.cm-group-title { font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.cm-group-count { font-size: 12px; font-weight: 700; opacity: 0.6; font-variant-numeric: tabular-nums; }

.cm-prog {
  height: 8px;
  border-radius: 4px;
  background: rgba(128, 110, 80, 0.22);
  overflow: hidden;
  margin-top: 6px;
}
.cm-prog-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.cm-prog-mini { height: 5px; margin-top: 4px; }
.cm-prog-num { font-size: 11px; font-weight: 700; opacity: 0.65; margin-top: 3px; font-variant-numeric: tabular-nums; }

.cm-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.cm-btn {
  margin-top: 8px;
  padding: 9px 18px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 10px var(--shadow);
  -webkit-tap-highlight-color: transparent;
}
.cm-btn:active { transform: translateY(2px); }
.cm-btn:disabled { opacity: 0.75; cursor: default; }
.cm-btn-done { background: #2ecc71; }
.cm-btn-ghost { background: transparent; color: var(--text); border: 2px solid var(--panel-border); box-shadow: none; }

/* ---------- skin-képernyő ---------- */
.cm-detail {
  /* görgetéskor a képernyő tetején marad, hogy a "Felveszem!" gomb
     lent kiválasztott skinnél is kéznél legyen */
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  /* átlátszatlan réteg-halom, hogy az alatta elgördülő rács ne derengjen át */
  background:
    linear-gradient(rgba(128, 110, 80, 0.07), rgba(128, 110, 80, 0.07)),
    linear-gradient(var(--panel), var(--panel)),
    var(--bg-bottom);
  box-shadow: 0 6px 16px var(--shadow);
  min-height: 120px;
}
.cm-detail-prev {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cm-detail-info { flex: 1 1 auto; min-width: 0; }
.cm-detail-name { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.cm-detail-desc { font-size: 12.5px; line-height: 1.45; opacity: 0.85; margin: 6px 0 2px; }
.cm-goal { font-size: 12.5px; font-weight: 700; margin-top: 6px; color: var(--accent); }

.cm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.cm-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px 8px;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cm-tile:active { transform: scale(0.96); }
.cm-tile.active { box-shadow: 0 0 0 3px var(--accent) inset; }
.cm-tile-name {
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  min-height: 25px;
  display: flex;
  align-items: center;
}
.cm-tile .cm-prog { width: 80%; }
.cm-tile-badge {
  position: absolute;
  top: -7px;
  right: -5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
  box-shadow: 0 2px 6px var(--shadow);
}
.cm-tile-lock { position: absolute; top: 4px; right: 6px; font-size: 12px; opacity: 0.8; }
.cm-tile.locked { opacity: 0.85; }
.cm-sil { filter: brightness(0) opacity(0.3); }
html[data-theme="dark"] .cm-sil { filter: brightness(0) invert(1) opacity(0.28); }
.cm-secret-q {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 800;
  opacity: 0.45;
}
.cm-detail-prev .cm-secret-q { font-size: 52px; width: 84px; height: 84px; }

/* ---------- trófea-képernyő ---------- */
.cm-ach-summary { padding: 4px 2px 2px; }
.cm-ach-sumtext { font-size: 13px; font-weight: 800; }
.cm-ach-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  margin-bottom: 8px;
}
.cm-ach-row.done { border-color: rgba(46, 204, 113, 0.65); background: rgba(46, 204, 113, 0.08); }
.cm-ach-row.secret { opacity: 0.7; }
.cm-ach-icon { flex: 0 0 auto; font-size: 26px; line-height: 1.2; width: 34px; text-align: center; }
.cm-ach-info { flex: 1 1 auto; min-width: 0; }
.cm-ach-name { font-size: 14px; font-weight: 800; }
.cm-tier { color: #ffb020; font-size: 12px; letter-spacing: 1px; }
.cm-ach-desc { font-size: 12px; line-height: 1.4; opacity: 0.8; margin-top: 2px; }
.cm-reward { font-size: 11px; font-weight: 700; margin-top: 4px; color: var(--accent); }
.cm-ach-done { flex: 0 0 auto; text-align: center; }
.cm-ach-check {
  width: 26px;
  height: 26px;
  margin: 0 auto;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-weight: 800;
  line-height: 26px;
}
.cm-ach-date { font-size: 9.5px; opacity: 0.6; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* ---------- profil ---------- */
.cm-prof-head {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 4px 14px;
}
.cm-prof-avatar {
  flex: 0 0 auto;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(128, 110, 80, 0.07);
}
.cm-prof-id { flex: 1 1 auto; min-width: 0; }
.cm-prof-nick { font-size: 19px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.cm-prof-skinname { font-size: 12px; font-weight: 700; opacity: 0.65; margin: 2px 0 8px; }

/* becenév-szerkesztés a profilban */
.cm-prof-nickrow { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cm-prof-nickrow .cm-prof-nick { min-width: 0; }
.cm-prof-edit {
  flex: 0 0 auto;
  border: 1px solid var(--panel-border);
  background: rgba(128, 128, 128, 0.10);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 5px 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cm-prof-edit:active { transform: scale(0.92); }
.cm-prof-editrow { display: flex; align-items: center; gap: 6px; }
.cm-prof-editrow .cm-btn { margin-top: 0; padding: 8px 12px; white-space: nowrap; }
.cm-nick-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: 16px;   /* 16px alatt az iOS rázoomolna fókuszkor */
  font-weight: 700;
  color: var(--text);
  background: rgba(128, 128, 128, 0.12);
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  padding: 7px 10px;
}
.cm-nick-input:focus { outline: none; border-color: var(--accent); }
.cm-nick-msg { font-size: 12px; font-weight: 700; margin: 4px 0 6px; color: #2e9b57; }
.cm-nick-msg.err { color: var(--accent); }
html[data-theme="dark"] .cm-nick-msg { color: #6fe0a0; }
html[data-theme="dark"] .cm-nick-msg.err { color: var(--accent); }
.cm-select {
  width: 100%;
  max-width: 240px;
  padding: 7px 10px;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}
.cm-prof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cm-prof-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
}
.cm-prof-ic { font-size: 20px; }
.cm-prof-tx { min-width: 0; }
.cm-prof-val { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-prof-lab { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; opacity: 0.6; }
.cm-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-badge {
  width: 86px;
  padding: 8px 4px;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  text-align: center;
}
.cm-badge-ic { font-size: 24px; }
.cm-badge-name { font-size: 9.5px; font-weight: 700; margin-top: 3px; line-height: 1.25; }

/* ---------- toastok ---------- */
.cm-toast-wrap {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 380px);
}
.cm-toast {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 8px 24px var(--shadow);
  opacity: 0;
  transform: translateY(-16px) scale(0.95);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cm-toast.show { opacity: 1; transform: translateY(0) scale(1); }
.cm-toast-ic { font-size: 24px; flex: 0 0 auto; }
.cm-toast-title { font-size: 13.5px; font-weight: 800; }
.cm-toast-sub { font-size: 11px; font-weight: 700; opacity: 0.7; margin-top: 1px; }

/* ---------- skin-feloldás ünneplés ---------- */
.cm-unlock {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 14, 6, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.cm-unlock.hidden { display: none; }
.cm-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cm-unlock-card {
  position: relative;
  max-width: min(88vw, 360px);
  padding: 22px 26px 24px;
  border: 2px solid var(--panel-border);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  animation: cmPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cmPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.cm-unlock-kicker {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 10px;
}
.cm-unlock-prev {
  width: 158px;
  height: 158px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(128, 110, 80, 0.1);
  animation: cmFloat 2.4s ease-in-out infinite;
}
@keyframes cmFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.cm-unlock-name { font-size: 21px; font-weight: 900; margin-bottom: 6px; }
.cm-unlock-desc { font-size: 12.5px; line-height: 1.45; opacity: 0.85; margin-top: 10px; }
.cm-unlock-btns { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }

@media (max-width: 380px) {
  .cm-grid { grid-template-columns: repeat(3, 1fr); }
  .cm-prof-grid { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .cm-unlock-prev { animation: none; }
  .cm-unlock-card { animation: none; }
}
