/* === RESET & BASE === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #050505;
  --surface: #0A0A0A;
  --accent: #E8E832;
  --accent-glow: #FFFF00;
  --green: #33FF33;
  --text: #AAAAAA;
  --dim: #333333;
  --inactive: #222222;
  --danger: #FF3333;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

/* === SCREENS === */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* === LANDING === */
#landing {
  background: var(--surface);
  z-index: 100;
  transition: opacity 0.5s ease;
}

#landing.fade-out {
  opacity: 0;
  pointer-events: none;
}

.landing-content {
  text-align: center;
}

.logo {
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
  line-height: 1;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 60px rgba(232, 232, 50, 0.2), 0 0 120px rgba(232, 232, 50, 0.08);
}

.tagline {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: var(--dim);
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

/* === MODE SELECTOR === */
.mode-selector {
  display: flex;
  gap: 0;
  justify-content: center;
  margin-bottom: 2rem;
  border: 1px solid var(--inactive);
  border-radius: 4px;
  overflow: hidden;
}

.mode-btn {
  padding: 0.5rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dim);
  background: transparent;
  border: none;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.25s ease;
}

.mode-btn:not(:last-child) {
  border-right: 1px solid var(--inactive);
}

.mode-btn:hover {
  color: var(--text);
  background: rgba(232, 232, 50, 0.05);
}

.mode-btn.active {
  color: var(--accent);
  background: rgba(232, 232, 50, 0.1);
}

.btn-start {
  display: inline-block;
  padding: 1rem 3.5rem;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: 1.5px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.15em;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-start:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 40px rgba(232, 232, 50, 0.3), 0 0 80px rgba(232, 232, 50, 0.1);
  transform: scale(1.02);
}

.btn-start:active {
  transform: scale(0.98);
}

.browser-note {
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--dim);
}

/* === LANGUAGE SELECTOR === */
.lang-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 1.5rem;
}

.lang-btn {
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--inactive);
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  border-color: rgba(232, 232, 50, 0.3);
  color: var(--text);
}

.lang-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* === PERFORMANCE === */
#performance {
  background: var(--bg);
  justify-content: flex-start;
}

.app-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
}

.frame-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  width: 100%;
}

.video-container {
  position: relative;
  aspect-ratio: 9 / 16;
  height: min(90vh, calc(100vw * 16 / 9));
  max-height: calc(100vh - 80px);
  max-width: 100vw;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(232, 232, 50, 0.08);
  background: var(--surface);
}

#webcam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  /* filter applied dynamically via JS per preset */
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  object-fit: contain;
}

/* === HINTS === */
.hints {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  pointer-events: none;
}

.hint-text {
  font-size: 1rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.5s ease;
  white-space: nowrap;
}

.hint-text.visible {
  opacity: 0.5;
}

/* === ERROR OVERLAY === */
.error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.9);
  z-index: 50;
}

.error-overlay.hidden {
  display: none;
}

.error-overlay p {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-align: center;
  max-width: 400px;
}

.btn-retry {
  padding: 0.6rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-retry:hover {
  background: var(--accent);
  color: var(--bg);
}

/* === RECORDING INDICATOR (inside safe zone — visible in recorded video) === */
.rec-indicator {
  position: absolute;
  top: 16%;
  left: 5%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--danger);
}

.rec-indicator.hidden {
  display: none;
}

.rec-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-blink 1s infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* === CONTROLS BAR (outside frame — not recorded) === */
.controls-bar {
  height: 60px;
  width: 100%;
  max-width: 500px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Mobile portrait: canvas fills screen, controls overlay */
@media (max-aspect-ratio: 3/4) {
  .app-layout {
    padding: 0;
  }
  .video-container {
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
  .controls-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    z-index: 20;
    max-width: none;
    padding: 0 16px;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

.btn-record {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0;
  color: var(--danger);
  background: transparent;
  border: 3px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-record .rec-label {
  display: none;
}

.btn-record:hover {
  box-shadow: 0 0 20px rgba(232, 232, 50, 0.2);
  transform: scale(1.05);
}

.btn-record.recording {
  border-color: var(--danger);
  animation: pulse-border 1s infinite;
}

.record-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger);
  transition: all 0.2s;
}

.btn-record.recording .record-circle {
  border-radius: 4px;
  width: 20px;
  height: 20px;
  background: var(--danger);
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 51, 51, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255, 51, 51, 0); }
}

.btn-pause {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: -0.05em;
}

.btn-pause:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(232, 232, 50, 0.2);
}

.btn-pause.paused {
  border-color: var(--green);
  color: var(--green);
}

.btn-pause.paused:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(51, 255, 51, 0.2);
}

.pause-icon {
  font-size: 0.7rem;
  line-height: 1;
}

.session-timer {
  font-size: 0.85rem;
  color: var(--dim);
}

.preset-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--accent);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--inactive);
  border-radius: 4px;
  transition: border-color 0.2s;
}

.preset-selector:hover {
  border-color: rgba(232, 232, 50, 0.3);
}

.btn-preset-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
}

.btn-preset-nav:hover {
  background: var(--accent);
  color: var(--bg);
  box-shadow: 0 0 12px rgba(232, 232, 50, 0.2);
}

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

/* === PREVIEW === */
#preview {
  background: var(--bg);
  z-index: 80;
}

.preview-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 90%;
  max-width: 640px;
}

#preview-video {
  aspect-ratio: 9 / 16;
  max-height: 70vh;
  width: auto;
  border: 1px solid var(--inactive);
  border-radius: 8px;
}

.preview-actions {
  display: flex;
  gap: 1rem;
}

.btn-action {
  padding: 0.6rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--dim);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-action:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(0);
}

.btn-action.btn-share {
  color: #33FF33;
  border-color: #33FF33;
}

.btn-action.btn-share:hover {
  background: #33FF33;
  color: var(--bg);
}

.btn-action.btn-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-action.btn-primary:hover {
  background: var(--accent);
  color: var(--bg);
}

/* === SHARE MODAL === */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.share-modal.hidden {
  display: none;
}

.share-modal-inner {
  position: relative;
  width: 90%;
  max-width: 420px;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--inactive);
  border-radius: 8px;
}

.share-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.5rem;
  color: var(--dim);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  font-family: var(--font-mono);
}

.share-modal-close:hover {
  color: var(--text);
}

.share-state.hidden {
  display: none;
}

.share-title {
  font-size: 1rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}

.share-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--inactive);
  border-radius: 2px;
  overflow: hidden;
}

.share-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.2s ease;
}

.share-progress-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--dim);
  margin-top: 0.5rem;
}

.share-link-row {
  display: flex;
  gap: 0.5rem;
}

.share-link-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--inactive);
  border-radius: 4px;
  outline: none;
}

.share-link-input:focus {
  border-color: var(--accent);
}

.share-copy-btn {
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--green);
  background: transparent;
  border: 1px solid var(--green);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.share-copy-btn:hover {
  background: var(--green);
  color: var(--bg);
}

.share-copy-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
}

.share-extra-actions {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.share-error-title {
  color: var(--danger);
}

.share-error-msg {
  font-size: 0.85rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 1rem;
}
