:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #1c1d26;
  --muted: #6b6f80;
  --border: #e3e5ec;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-text: #ffffff;
  --mine: #4f46e5;
  --mine-text: #ffffff;
  --theirs: #ffffff;
  --theirs-text: #1c1d26;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(20, 20, 50, .08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1016;
    --surface: #1a1b24;
    --text: #ecedf3;
    --muted: #9a9db0;
    --border: #2b2d3a;
    --primary: #6d66f0;
    --primary-hover: #7f79f5;
    --mine: #5b54e8;
    --theirs: #242634;
    --theirs-text: #ecedf3;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

/* ---------- képernyők ---------- */
/* ---------- oldalszerkezet: [mobil hirdetés] [bal | app | jobb] [mobil hirdetés] ---------- */
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.app { position: relative; height: 100%; min-height: 0; overflow: hidden; }

.screen { display: none; height: 100%; }
.screen.active { display: flex; }
#screen-join, #screen-waiting { overflow-y: auto; padding: 24px 16px; }
#screen-join .card, #screen-waiting .card { margin: auto; }   /* középre, de nem vágja le */

/* ---------- hirdetési helyek ---------- */
.ad-side, .ad-mobile { display: none; }
.ad-slot { overflow: hidden; margin: 0 auto; max-width: 100%; }
.ad-placeholder {
  display: grid; place-items: center; text-align: center;
  font-size: .8rem; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 8px;
  background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(127,127,127,.05) 10px 20px);
}

@media (max-width: 1199px) {
  .ads-on .ad-mobile { display: block; flex: none; background: var(--surface); padding: 4px 0; }
  .ads-on .ad-top { border-bottom: 1px solid var(--border); }
  .ads-on .ad-bottom { border-top: 1px solid var(--border); padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
}
@media (min-width: 1200px) {
  .ads-on .layout {
    grid-template-columns: minmax(180px, 320px) minmax(0, 820px) minmax(180px, 320px);
    justify-content: center;
    column-gap: 24px;
  }
  .ads-on .ad-side { display: flex; justify-content: center; align-items: flex-start; padding-top: 24px; }
}

.card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.card.center { text-align: center; }
h1 { margin: 0 0 4px; font-size: 1.8rem; }
h2 { margin: 16px 0 8px; font-size: 1.3rem; }
.lead { margin: 0 0 20px; color: var(--muted); }

/* ---------- űrlap ---------- */
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 10px; }

.seg { display: flex; gap: 8px; margin-bottom: 12px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  text-align: center;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: .15s;
  user-select: none;
}
.seg input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.field { display: block; }
.field span { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--muted); margin: 4px 0 16px; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

.form-error { color: var(--danger); min-height: 1.2em; margin: 0 0 10px; font-size: .9rem; }

/* ---------- gombok ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.small { padding: 7px 12px; font-size: .9rem; }

/* ---------- várakozás ---------- */
.wait-card h2 { margin-top: 0; }
.ad-square { margin: 14px auto 18px; }
.search-progress {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--border); margin: 0 auto 10px; max-width: 300px;
}
.search-bar { height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .25s linear; }
.search-bar.indeterminate { width: 35% !important; animation: slide 1.2s ease-in-out infinite; transition: none; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* ---------- 18+ popup ---------- */
.age-gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: var(--bg);
}
.age-card {
  width: 100%; max-width: 420px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow); padding: 32px 24px;
}
.age-badge {
  width: 72px; height: 72px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%; border: 4px solid var(--danger); color: var(--danger);
  font-weight: 800; font-size: 1.4rem;
}
.age-card h2 { margin: 0 0 8px; }
.age-card p { margin: 0 0 22px; }
.age-actions { display: grid; gap: 10px; }
.age-card .cookie-note { font-size: .82rem; color: var(--muted); margin: -10px 0 20px; }
.cookie-note a, .card-footer a { color: var(--primary); }
.link-btn {
  background: none; border: 0; padding: 4px; font: inherit; font-size: .85rem;
  color: var(--muted); text-decoration: underline; cursor: pointer;
}
.link-btn:hover { color: var(--primary); }
.card-footer { margin: 16px 0 0; text-align: center; font-size: .85rem; color: var(--muted); }

.spinner {
  width: 54px; height: 54px; margin: 8px auto 0;
  border: 5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chat ---------- */
#screen-chat { flex-direction: column; height: 100%; max-width: 820px; margin: 0 auto; background: var(--bg); }

.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.partner { display: flex; align-items: center; gap: 10px; min-width: 0; }
.partner small { display: block; }
.avatar {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700;
}
.head-actions { display: flex; gap: 6px; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain;
}

.msg { max-width: 78%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 8px 12px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); border-bottom-right-radius: 4px; }
.msg.theirs .bubble { background: var(--theirs); color: var(--theirs-text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.media { padding: 4px; background: var(--surface) !important; border: 1px solid var(--border); }
.bubble.media img, .bubble.media video {
  display: block;
  max-width: min(320px, 70vw);
  max-height: 360px;
  border-radius: 12px;
  background: #000;
}
.bubble.media img { cursor: zoom-in; }
.msg time { font-size: .72rem; color: var(--muted); margin: 2px 6px 4px; }

.system {
  align-self: center;
  font-size: .85rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 999px;
  margin: 6px 0;
  text-align: center;
}

#screen-chat { position: relative; }
.new-msg-btn {
  position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%);
  z-index: 5;
  padding: 8px 16px;
  font: inherit; font-size: .9rem; font-weight: 600;
  color: var(--primary-text); background: var(--primary);
  border: 0; border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.new-msg-btn:hover { background: var(--primary-hover); }

.upload-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px; font-size: .85rem; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--border);
}
.upload-bar progress { flex: 1; height: 8px; accent-color: var(--primary); }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 14px;
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
}
.composer textarea:focus { border-color: var(--primary); }
.attach {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
}
.attach:hover { color: var(--primary); background: var(--bg); }
.attach input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.btn.send { width: 42px; height: 42px; padding: 0; border-radius: 50%; flex: none; }

.ended-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
[hidden] { display: none !important; }

/* ---------- értesítés ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: #1c1d26; color: #fff;
  padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: .9rem;
  z-index: 10;
}

/* ---------- nagyított kép ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .88);
  cursor: zoom-out;
}
.lightbox img { max-width: 95vw; max-height: 95vh; border-radius: 8px; }

@media (max-width: 480px) {
  .head-actions .btn.small { padding: 6px 9px; font-size: .82rem; }
  .msg { max-width: 88%; }
}

/* ---------- eltűnő kép / videó buborék ---------- */
.bubble.ephemeral {
  display: flex; align-items: center; gap: 10px;
  min-width: 220px; text-align: left;
  font: inherit; cursor: pointer;
  border: 1px solid var(--border);
}
.msg.theirs .bubble.ephemeral { background: var(--theirs); color: var(--theirs-text); }
.msg.mine .bubble.ephemeral { cursor: default; }
.bubble.ephemeral:not(:disabled):hover { border-color: var(--primary); }
.bubble.ephemeral:disabled { cursor: default; }
.bubble.ephemeral.expired { opacity: .65; }
.eph-icon {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(127, 127, 127, .15);
  font-size: 1.1rem;
}
.msg.theirs .bubble.ephemeral:not(.expired) .eph-icon { background: var(--primary); }
.eph-text { display: flex; flex-direction: column; line-height: 1.3; }
.eph-text strong { font-size: .92rem; }
.eph-text small { font-size: .8rem; opacity: .8; }

/* ---------- küldés előtti beállítás ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .5);
}
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }
.sheet {
  width: 100%; max-width: 420px;
  background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
@media (min-width: 640px) { .sheet { border-radius: 20px; } }
.sheet h3 { margin: 0 0 12px; font-size: 1.1rem; }
.sheet-preview { display: grid; place-items: center; background: #000; border-radius: 12px; overflow: hidden; }
.sheet-preview img, .sheet-preview video { display: block; max-width: 100%; max-height: 240px; }
.sheet-label { margin: 14px 0 8px; font-weight: 600; font-size: .95rem; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- eltűnő megtekintő ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  background: #000; color: #fff;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.viewer-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  font-weight: 600;
}
.viewer-close {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 1.1rem; cursor: pointer;
}
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; pointer-events: auto; }
.viewer-body img { pointer-events: none; }
.viewer-progress { height: 4px; background: rgba(255, 255, 255, .2); margin-bottom: env(safe-area-inset-bottom); }
.viewer-progress div { height: 100%; width: 0; background: #fff; }
