:root {
  --navy: #032e51;
  --navy-deep: #02223d;
  --gold: #f6b332;
  --red: #de5a48;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 8, 16, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy-deep);
  font-family: var(--font);
  overscroll-behavior: none;
}

#viewer {
  position: fixed;
  inset: 0;
  background: var(--navy-deep);
}

/* ---------- top bar ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(to bottom, rgba(2, 24, 43, 0.92), rgba(2, 24, 43, 0.75) 70%, transparent);
  pointer-events: none;
  z-index: 20;
}
.topbar > * { pointer-events: auto; }

.brand { flex: 1 1 auto; min-width: 0; }
.brand-title {
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-title span { color: var(--gold); }
.brand-sub {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- search ---------- */
.search {
  position: relative;
  flex: 0 1 420px;
  min-width: 240px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--red);
  pointer-events: none;
}
#search-input {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 44px 0 42px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  font-family: var(--font);
  background: var(--white);
  color: #1c2b3a;
  box-shadow: var(--shadow);
  outline: none;
}
#search-input::placeholder { color: #8290a0; }
#search-input:focus { box-shadow: 0 0 0 3px rgba(246, 179, 50, 0.55), var(--shadow); }

#search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #eef1f5;
  color: #5b6b7c;
  font-size: 14px;
  cursor: pointer;
}
#search-clear:hover { background: #e2e7ee; }

#search-results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: min(46vh, 380px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#search-results li {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 15px;
  color: #1c2b3a;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
#search-results li mark {
  background: none;
  color: var(--red);
  font-weight: 700;
}
#search-results li.active,
#search-results li:hover { background: #f2f6fb; }
#search-results li .multi {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  background: rgba(246, 179, 50, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}
#search-results .empty {
  padding: 14px;
  color: #6a7887;
  font-size: 14px;
  cursor: default;
  justify-content: center;
}

/* ---------- viewer controls ---------- */
.controls {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}
.controls button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}
.controls button:hover { background: #c94b3a; transform: scale(1.06); }
.controls button:active { transform: scale(0.96); }
#ctl-share { background: var(--gold); color: var(--navy); }
#ctl-share:hover { background: #e3a422; }

/* ---------- overlays on the wall ---------- */
.name-box {
  border: 2px solid rgba(246, 179, 50, 0.95);
  border-radius: 6px;
  background: rgba(246, 179, 50, 0.18);
}
.name-box.scrim { box-shadow: 0 0 0 2000px rgba(2, 24, 43, 0.16); }
.name-ring { position: relative; }
.name-ring::before,
.name-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  width: 300%;
  padding-top: 300%;
  pointer-events: none;
}
.name-ring::before { border: 3px solid var(--gold); }
.name-ring::after {
  border: 14px solid var(--gold);
  opacity: 0.55;
  animation: ringPulse 1.8s ease-in-out infinite;
}
@keyframes ringPulse {
  0%, 100% { border-width: 14px; opacity: 0.55; }
  50% { border-width: 26px; opacity: 0.25; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--white);
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-width: calc(100vw - 32px);
  text-align: center;
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand { flex-basis: 100%; }
  .brand-title { font-size: 15px; }
  .brand-sub { display: none; }
  .search { flex: 1 1 100%; }
  #search-results { max-height: 42vh; }
}
