:root {
  --bg-color: #0c0c0e;
  --accent-color: #ffc800;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --viewfinder-ratio: 3/4;
}

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

.hide {
  display: none !important;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: "Space Grotesk", sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-container {
  width: 100%;
  max-width: 500px;
  height: 100vh;
  height: 100dvh; /* Use dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  padding: 10px 20px;
  position: relative;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 20px;
}

.logo {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -1px;
}

.logo span {
  color: var(--accent-color);
}

.stats {
  text-align: right;
  font-weight: 700;
}

.stats small {
  display: block;
  font-size: 0.6rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
}

#photo-count {
  color: var(--accent-color);
  font-size: 1.2rem;
}

/* Viewfinder */
.viewfinder-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
  overflow: hidden; /* Prevent dragging/scrolling */
  min-height: 0; /* Important for flex children to shrink */
}

.viewfinder {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: var(--viewfinder-ratio);
  background: #1a1a1c;
  border-radius: 24px;
  overflow: hidden;
  position: relative;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.4),
    inset 0 0 100px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--glass-border);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.3s ease;
}

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

/* Overlays */
.overlay-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.177) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.177) 1px, transparent 1px);
  background-size: 33.33% 33.33%;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.timestamp {
  position: absolute;
  bottom: 25px; /* Adjusted for frame */
  right: 25px; /* Adjusted for frame */
  color: #ffb700f5;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9rem;
  font-weight: bold;
  opacity: 0.8;
  text-shadow: 0 0 5px rgba(255, 183, 0, 0.5);
  z-index: 6;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  background-image: url('frame_1.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 5;
}

.filter-label {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid var(--glass-border);
}

/* Controls */
.controls {
  padding: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0; /* Don't allow controls to be squeezed */
}

.filter-selector {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 5px;
  scrollbar-width: none;
}

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

.filter-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn.active {
  background: var(--text-primary);
  color: var(--bg-color);
  border-color: var(--text-primary);
  transform: translateY(-2px);
}

.main-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
}

.shutter-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--text-primary);
  border: none;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.1s active;
}

.shutter-btn:active {
  transform: scale(0.92);
}

.shutter-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--bg-color);
}

.icon-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 50px;
  height: 50px;
  border-radius: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
}

.gallery-preview {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  overflow: hidden;
  background: #1a1a1c;
  border: 2px solid var(--glass-border);
  cursor: pointer;
}

.preview-box {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

/* Flash Effect */
.flash {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.427);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}

.flash.active {
  animation: flashAnim 0.4s ease-out;
}

@keyframes flashAnim {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Filters Implementation */
.filter-vintage {
  filter: sepia(0.3) contrast(1.1) brightness(0.9) hue-rotate(-10deg);
}
.filter-mono {
  filter: grayscale(1) contrast(1.2);
}
.filter-lush {
  filter: saturate(1.2) contrast(1.1) hue-rotate(5deg) brightness(0.95);
}
.filter-disposable {
  filter: sepia(0.1) contrast(1.1) brightness(1.05) saturate(1.4) hue-rotate(-5deg);
}

/* Modal Gallery */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s;
  visibility: hidden;
}

.modal.active {
  display: flex !important;
  opacity: 1;
  visibility: visible;
}

#lightbox {
  z-index: 1100; /* Ensure lightbox is always above gallery */
}

/* Custom Confirm Modal */
.confirm-modal-overlay {
    z-index: 2000 !important;
    justify-content: center;
    align-items: center;
}

.confirm-card {
    background: #1a1a1c;
    border: 1px solid var(--glass-border);
    padding: 30px;
    border-radius: 24px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .confirm-card {
    transform: scale(1);
}

.confirm-card h3 {
    font-family: 'Syne', sans-serif;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.alert-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.confirm-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.cancel-btn {
    background: var(--glass);
    color: var(--text-primary);
    border: 1px solid var(--glass-border) !important;
}

.confirm-btn {
    background: #ff4444;
    color: white;
}

.confirm-btn:active {
    transform: scale(0.95);
    background: #cc0000;
}


.modal-content {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  height: 100%;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.modal-header h2 {
  font-family: 'Syne', sans-serif;
  letter-spacing: 2px;
  font-size: 1.2rem;
}

.close-btn {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
}

.gallery-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: min-content;
  gap: 15px;
  overflow-y: auto;
  padding-bottom: 40px;
  align-content: start;
}

.gallery-item {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #1a1a1c;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  position: relative;
  display: block;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-footer {
  padding-top: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--glass-border);
}

/* Lightbox Specifics */
.lightbox-content {
    justify-content: center;
    position: relative;
}

.lightbox-image-container {
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.lightbox-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.close-btn.top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.lightbox-actions {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.download-btn {
    background: var(--text-primary);
    border: none;
    color: var(--bg-color);
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.download-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.delete-btn {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.2);
    color: #ff4444;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:active {
    background: rgba(255, 0, 0, 0.3);
    transform: scale(0.95);
}


