:root {
  --bg: #030303;
  --text: #fff8d9;
  --muted: rgba(255, 248, 217, 0.66);
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(10, 10, 10, 0.42);
  --gold: #ffe238;
  --gold-2: #ffb000;
  --danger: #ff5d66;
  --nav-h: calc(64px + env(safe-area-inset-bottom));
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 0%, rgba(255, 226, 56, 0.09), transparent 32%),
    #000;
}

.screen {
  position: absolute;
  inset: 0 0 var(--nav-h);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.995);
  transition: opacity 240ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.camera-screen {
  background: #000;
}

.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  opacity: 0;
  transition: opacity 260ms ease, filter 220ms ease, transform 220ms ease;
  will-change: filter, opacity;
}

.camera-video.ready {
  opacity: 1;
}

.camera-video.front {
  transform: scaleX(-1);
}

.hidden-canvas {
  display: none;
}

.camera-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, .38) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, .62), transparent 22%, transparent 67%, rgba(0, 0, 0, .7));
}

.letterbox {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 220ms ease;
}

.letterbox.active {
  opacity: 1;
}

.letterbox span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 12.5vh;
  background: #000;
}

.letterbox span:first-child {
  top: 0;
}

.letterbox span:last-child {
  bottom: 0;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.1%, rgba(255,255,255,.26) 33.3%, transparent 33.5%, transparent 66.4%, rgba(255,255,255,.26) 66.6%, transparent 66.8%),
    linear-gradient(to bottom, transparent 33.1%, rgba(255,255,255,.26) 33.3%, transparent 33.5%, transparent 66.4%, rgba(255,255,255,.26) 66.6%, transparent 66.8%);
}

.top-bar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
}

.icon-btn,
.rail-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .18);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  transition: transform 150ms ease, background 160ms ease, color 160ms ease;
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn:active,
.rail-btn:active,
.capture-btn:active,
.filter-pill:active {
  transform: scale(.92);
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ratio-strip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.ratio-btn {
  min-width: 30px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, .88);
  font-size: 11px;
  font-weight: 800;
}

.ratio-btn.active {
  background: var(--gold);
  color: #111;
}

.side-rail {
  position: absolute;
  right: 12px;
  top: 38%;
  display: grid;
  gap: 14px;
  z-index: 10;
}

.rail-btn {
  background: rgba(0,0,0,.1);
}

.rail-btn.active {
  color: var(--gold);
}

.status-pill {
  position: absolute;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 11;
  min-height: 30px;
  max-width: min(84vw, 360px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 750;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-pill.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.status-pill.error {
  color: #fff;
  background: rgba(128, 0, 12, .7);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(255, 226, 56, .45);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(255, 226, 56, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 226, 56, 0); }
}

.start-card {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  z-index: 15;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .96);
  color: #050505;
  box-shadow: 0 20px 60px rgba(0,0,0,.34);
}

.start-card.hidden {
  display: none;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: #050505;
  font-weight: 900;
}

.start-btn svg {
  width: 17px;
  height: 17px;
}

.start-card p {
  margin: 0;
  font-size: 12px;
  color: rgba(0,0,0,.64);
  font-weight: 750;
}

.pro-panel {
  position: absolute;
  left: 14px;
  right: 64px;
  bottom: 214px;
  z-index: 16;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(18px);
}

.pro-panel label {
  display: grid;
  grid-template-columns: 82px 1fr;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.82);
  font-size: 12px;
  font-weight: 800;
  margin: 8px 0;
}

.pro-panel input {
  width: 100%;
  accent-color: var(--gold);
}

.capture-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  z-index: 12;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding-bottom: 0;
}

.filter-name {
  height: 18px;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  text-shadow: 0 1px 8px rgba(0,0,0,.55);
}

.filter-carousel {
  width: 100%;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding: 0 max(22px, calc(50vw - 36px));
  scrollbar-width: none;
}

.filter-carousel::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  scroll-snap-align: center;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  border: 2px solid rgba(255,255,255,.18);
  box-shadow: inset 0 -18px 28px rgba(0,0,0,.18);
  transition: transform 180ms ease, border 180ms ease, box-shadow 180ms ease;
}

.filter-pill.active {
  transform: scale(1.12);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 226, 56, .25), inset 0 -18px 28px rgba(0,0,0,.2);
}

.capture-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  padding: 5px;
  background: transparent;
  border: 4px solid rgba(255,255,255,.88);
  box-shadow: 0 10px 40px rgba(0,0,0,.34);
}

.capture-btn span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
}

.capture-btn.busy span {
  background: conic-gradient(var(--gold), #fff, var(--gold));
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.bottom-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.92);
  z-index: 30;
}

.nav-btn {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  background: transparent;
  color: rgba(255,255,255,.66);
  font-size: 11px;
  font-weight: 700;
}

.nav-btn svg {
  width: 23px;
  height: 23px;
}

.nav-btn.active {
  color: var(--gold);
}

.panel-screen {
  overflow: auto;
  padding: calc(28px + env(safe-area-inset-top)) 16px 24px;
  background:
    radial-gradient(circle at 12% -10%, rgba(255,226,56,.16), transparent 34%),
    linear-gradient(180deg, #121212, #050505 46%, #000);
}

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-top h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.panel-subtitle {
  margin: 8px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.pill-btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  font-weight: 800;
}

.pill-btn.danger {
  color: #fff;
  background: rgba(255, 93, 102, .2);
}

.list {
  display: grid;
  gap: 10px;
}

.rank-row,
.profile-card {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.11);
  backdrop-filter: blur(16px);
}

.rank-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 12px;
}

.rank-medal {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,226,56,.15);
  color: var(--gold);
  font-weight: 950;
}

.rank-name {
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-meta,
.profile-muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.rank-count {
  color: var(--gold);
  font-weight: 950;
}

.profile-card {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.profile-stat {
  padding: 12px;
  border-radius: 16px;
  background: rgba(0,0,0,.26);
}

.profile-stat strong {
  display: block;
  font-size: 26px;
  color: var(--gold);
}

.preview-overlay,
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.9);
}

.preview-overlay[hidden],
.modal[hidden] {
  display: none;
}

.preview-overlay img {
  max-width: min(94vw, 520px);
  max-height: 72vh;
  object-fit: contain;
  border-radius: 22px;
  box-shadow: 0 18px 80px rgba(0,0,0,.5);
}

.preview-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.glass-btn,
.gold-btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 950;
}

.glass-btn {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
}

.gold-btn {
  color: #050505;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
}

.gold-btn.wide {
  width: 100%;
}

.sync-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.modal-card {
  width: min(92vw, 390px);
  padding: 20px;
  border-radius: 26px;
  background: rgba(16,16,16,.94);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 90px rgba(0,0,0,.6);
  backdrop-filter: blur(18px);
}

.modal-card h2 {
  margin: 0 0 8px;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.45;
}

.modal-card input {
  width: 100%;
  height: 48px;
  margin: 8px 0;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #fff;
  outline: none;
}

.text-btn {
  width: 100%;
  margin-top: 12px;
  background: transparent;
  color: rgba(255,255,255,.76);
  font-weight: 800;
}

.terms-card {
  max-height: 82vh;
  overflow: auto;
}

@media (min-width: 760px) {
  .app-shell {
    left: 50%;
    width: min(430px, 100vw);
    transform: translateX(-50%);
    border-left: 1px solid rgba(255,255,255,.12);
    border-right: 1px solid rgba(255,255,255,.12);
  }
}

@media (max-height: 650px) {
  .filter-pill {
    width: 50px;
    height: 50px;
  }

  .capture-btn {
    width: 66px;
    height: 66px;
  }

  .capture-dock {
    gap: 7px;
  }
}
