/* === Base reset & layout === */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: #FFF;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

/* Keep content clear of the topbar */
:root { --topbar-h: 56px; }
body { padding-top: var(--topbar-h); }

/* Video & canvas fill the screen under the topbar */
#videoElement, #canvasElement {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: calc(100% - var(--topbar-h));
  object-fit: cover;
  background: #000;
  z-index: 1; /* below overlays */
}

/* === Landing card === */
#landing {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 16px;
}
#landing .card {
  width: min(720px, 100%);
  background: rgba(0,0,0,.75);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 20px 18px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#landing h1 { margin: 0 0 8px; font-size: clamp(20px, 3.6vw, 28px); }
#landing p, #landing li { color: #ddd; }
#landing ul { margin: 10px 0 10px 18px; }
#landing .primary {
  height: 44px; padding: 0 16px;
  border-radius: 10px; border: none;
  background: #2563eb; color: #fff; cursor: pointer;
  font-weight: 600;
}
#landing .primary:hover { filter: brightness(1.08); }
#landing .privacy-note {
  margin: 10px 0 14px; padding: 10px; border-radius: 10px;
  background: rgba(37,99,235,.12); color: #cfe0ff;
}
#camError { margin-top: 8px; }

/* === Overlay gate === */
#overlay {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  z-index: 70;
  background: rgba(0,0,0,.6);
  color: #fff;
  text-align: center;
  font-size: clamp(16px, 4vw, 22px);
  cursor: pointer;
}

/* === Top bar === */
.topbar {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0; right: 0;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  z-index: 80;
  background: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,.25));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(18,18,18,.65);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); }
.icon-btn:active { transform: translateY(1px); }
.icon { width: 20px; height: 20px; display: block; }
.app-title { margin: 0; font-size: 16px; color: #fff; opacity: .9; text-align: center; }
.topbar .right { display: flex; gap: 8px; align-items: center; }

/* Labels hide on very small screens */
.label { display: none; }
@media (min-width: 560px) { .label { display: inline; } }

/* === Cookie banner quick polish === */
#cookie-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  z-index: 95;
  background: rgba(0,0,0,.85);
  color: #eee;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 12px;
  display: grid; gap: 8px;
}
#cookie-banner p { margin: 0; }
#cookie-banner button {
  height: 36px; border-radius: 8px; border: none; cursor: pointer;
}
#cookie-banner #accept-cookies { background: #16a34a; color: #fff; }
#cookie-banner #decline-cookies { background: #333; color: #eee; }

/* === Donation dialog === */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 98;
}

/* The dialog container centers content by default;
   we adjust per-orientation below. */
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 99;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

/* Panel defaults (desktop/tablet) */
.modal-panel {
  width: min(560px, calc(100% - 32px));
  max-height: min(80dvh, 640px);
  background: #0b0b0b;
  color: #fff;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  padding: 24px 20px 20px;
  position: relative;
  overflow: auto;                 /* prevent viewport overflow */
  -webkit-overflow-scrolling: touch;
  contain: content;
}

.modal .modal-close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: none; color: #bbb;
  font-size: 28px; line-height: 1; cursor: pointer;
}
.modal .modal-close:hover { color: #fff; }

.modal-panel h2 { margin: 0 0 6px; font-size: clamp(18px, 2.2vw, 22px); }
.modal-panel p  { color: #d6d6d6; font-size: clamp(14px, 1.8vw, 16px); }

/* Quick amounts layout */
.quick-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin: 14px 0 8px;
}
.amount-btn {
  height: 48px;
  border-radius: 10px;
  background: #141414;
  border: 1px solid rgba(255,255,255,.15);
  color: #fff; cursor: pointer;
  font-weight: 700;
  font-size: 16px;
}
.amount-btn:hover { background: #1b1b1b; }

/* Custom amount */
.custom-amount label { display: block; margin-top: 8px; margin-bottom: 6px; color: #e2e2e2; }
.custom-row {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 8px; align-items: center;
}
.custom-row .currency { text-align: center; color: #ddd; font-size: 16px; }
.custom-row input {
  height: 48px; padding: 0 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15); background: #111; color: #fff; font-size: 16px;
}
.custom-row .primary {
  height: 48px; padding: 0 16px; border-radius: 10px; border: none; background: #2563eb; color: #fff; cursor: pointer;
  font-weight: 700; font-size: 16px;
}
.custom-row .primary:hover { filter: brightness(1.1); }
.hint { color: #aaa; font-size: 12px; margin-top: 6px; }
.error { color: #ff8c8c; margin-top: 8px; }

/* === Mobile-first modal positioning === */
/* PORTRAIT phones: panel in the MIDDLE THIRD, no overflow */
@media (max-width: 768px) and (orientation: portrait) {
  .modal { place-items: center; }

  .modal-panel {
    width: min(680px, calc(100% - 24px));
    height: 34dvh;                /* about one third of viewport height */
    max-height: 50dvh;            /* just in case content grows */
    border-radius: 16px;
    border-left: 1px solid rgba(255,255,255,.12);
    border-right: 1px solid rgba(255,255,255,.12);
    padding: 20px 16px 16px;
    overflow: auto;               /* scroll inside panel if needed */
  }

  /* Bigger, thumb-friendly UI */
  .modal-panel h2 { font-size: clamp(20px, 5vw, 24px); }
  .modal-panel p  { font-size: clamp(16px, 4.5vw, 18px); }
  .amount-btn { height: 52px; font-size: clamp(18px, 5vw, 20px); }
  .custom-row input, .custom-row .primary { height: 52px; font-size: clamp(18px, 5vw, 20px); }
  .custom-row .currency { font-size: clamp(18px, 5vw, 20px); }
}

/* LANDSCAPE phones: LEFT HALF (full height), no overflow */
@media (max-width: 768px) and (orientation: landscape) {
  .modal { place-items: stretch; }

  .modal-panel {
    width: 50vw;
    height: 100dvh;
    border-radius: 0 16px 16px 0;
    border-top: none; border-bottom: none;
    padding: 20px 16px 16px;
    overflow: auto;               /* scroll inside panel if needed */
  }

  .modal-panel h2 { font-size: clamp(18px, 3.5vw, 22px); }
  .modal-panel p  { font-size: clamp(15px, 3vw, 18px); }
  .amount-btn { height: 50px; font-size: clamp(17px, 3.5vw, 19px); }
  .custom-row input, .custom-row .primary { height: 50px; font-size: clamp(17px, 3.5vw, 19px); }
  .custom-row .currency { font-size: clamp(17px, 3.5vw, 19px); }
}

/* === Utility === */
.error[hidden], [hidden] { display: none !important; }
