:root {
  --bg: #07090e;
  --surface: #10141e;
  --surface-border: #1e2638;
  --gold: #f4b41a;
  --gold-glow: rgba(244, 180, 26, 0.4);
  --cyan: #00d2ff;
  --text-main: #ffffff;
  --text-muted: #8b9bb4;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  background: radial-gradient(circle at center top, #141b2d 0%, var(--bg) 70%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.view-panel {
  display: none;
  width: 100%;
  max-width: 1080px;
  animation: fadeIn 0.3s ease forwards;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card / Login */
.login-modal {
  max-width: 420px;
  margin: 0 auto;
  background: rgba(16, 20, 30, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  padding: 40px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.badge {
  display: inline-block;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(244, 180, 26, 0.15);
  color: var(--gold);
  border: 1px solid var(--gold-glow);
  border-radius: 100px;
  margin-bottom: 16px;
}

.desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 6px;
  margin-bottom: 24px;
}

.input-field {
  text-align: left;
  margin-bottom: 16px;
}

.input-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-field input {
  width: 100%;
  background: #090c12;
  border: 1px solid var(--surface-border);
  color: #fff;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
  transition: 0.2s border-color;
}

.input-field input:focus {
  border-color: var(--gold);
}

.auth-error {
  color: #ff5252;
  font-size: 0.85rem;
  margin-top: 12px;
}

/* Template Grid (4 Square Tiles) */
.header-tag {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-align: center;
}

.view-title {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  margin-top: 4px;
}

.view-sub {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 780px;
  margin: 0 auto;
}

@media(min-width: 720px) {
  .grid-layout { grid-template-columns: repeat(4, 1fr); }
}

.poster-tile {
  background: var(--surface);
  border: 2px solid var(--surface-border);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
}

.poster-tile:hover {
  border-color: var(--gold);
  transform: translateY(-6px);
  box-shadow: 0 12px 30px var(--gold-glow);
}

.tile-aspect {
  aspect-ratio: 1;
  overflow: hidden;
}

.tile-aspect img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-bar {
  padding: 12px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  background: #0d1017;
  color: #cbd5e1;
}

/* Camera Stage */
.camera-stage {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 9/16;
  max-height: 560px;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid var(--surface-border);
}

video, #captureFreeze {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video { transform: scaleX(-1); }

.portrait-guide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.oval-head {
  width: 60%;
  height: 65%;
  border: 2px dashed rgba(244, 180, 26, 0.6);
  border-radius: 50%;
}

.portrait-guide span {
  margin-top: 12px;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 14px;
  border-radius: 100px;
  color: var(--gold);
}

#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7rem;
  font-weight: 900;
  color: #fff;
  background: rgba(0,0,0,0.5);
}

.stage-footer {
  margin-top: 20px;
}

.button-group {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Processing Modal */
.ai-processing-modal {
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 14, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 20px;
  padding: 24px;
  z-index: 20;
}

.pulse-ring {
  width: 54px;
  height: 54px;
  border: 4px solid var(--gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Showcase / Result */
.showcase-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 40px;
  margin-top: 24px;
}

.frame-poster {
  width: 320px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--surface-border);
}

.frame-poster img {
  width: 100%;
  display: block;
}

.qr-pod {
  background: #ffffff;
  color: #090c12;
  padding: 28px;
  border-radius: 20px;
  text-align: center;
  max-width: 280px;
}

.qr-pod h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.qr-frame {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.qr-pod p {
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 18px;
}

/* Buttons */
.action-btn {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}

.action-btn:active { transform: scale(0.97); }

.gold-btn {
  background: var(--gold);
  color: #000;
}

.glow-btn {
  background: linear-gradient(135deg, #f4b41a, #ff7a00);
  color: #000;
  box-shadow: 0 4px 20px var(--gold-glow);
}

.gray-btn {
  background: #242c3d;
  color: #fff;
}

.outline-btn {
  background: transparent;
  border: 2px solid #000;
  color: #000;
  width: 100%;
}

.hidden { display: none !important; }