@font-face {
  font-family: 'OpenDyslexic';
  src: url('fonts/OpenDyslexic-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  height: 100dvh;
  font-family: system-ui, sans-serif;
  background: #000;
  color: #eee;
  overflow: hidden;
}

/* -- Camera screen -- */
#camera-screen {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #000;
}

#viewfinder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#shutter-btn {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.8);
  background: rgba(180, 180, 180, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  transition: background 0.15s;
}

#shutter-btn:active {
  background: rgba(255, 255, 255, 0.7);
}

body.landscape #shutter-btn {
  bottom: auto;
  left: auto;
  transform: translateY(-50%);
  right: 32px;
  top: 50%;
}

/* -- Upload fallback -- */
#upload-fallback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#file-input {
  display: none;
}

#upload-btn {
  display: inline-block;
  padding: 1.2rem 2.4rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  background: #4361ee;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#upload-btn:active {
  background: #3a56d4;
}

/* -- Progress bar with grey track -- */
#progress-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: rgba(200, 200, 200, 0.3);
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

#progress-track.active {
  opacity: 1;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: #4361ee;
  transition: width 0.2s ease;
}

/* -- Result screen -- */
#result-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  background: #000;
}

#canvas-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* Threshold slider hint — right edge */
#slider-hint {
  position: absolute;
  top: 0;
  right: 0;
  width: 5%;
  height: 100%;
  background: rgba(200, 200, 200, 0.20);
  pointer-events: none;
  z-index: 25;
}

#overlay-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  touch-action: none;
  transform-origin: center center;
}

#threshold-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}

#no-text-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 3rem));
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}

/* -- Auto-hiding nav bar -- */
#result-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: #111;
  flex-shrink: 0;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 25;
}

#result-actions.visible {
  transform: translateY(0);
}

#result-actions button {
  flex: 1;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#save-btn {
  background: #4361ee;
  color: #fff;
}

#save-btn:active {
  background: #3a56d4;
}

#retake-btn {
  background: #222;
  color: #ccc;
}

#retake-btn:active {
  background: #333;
}
