/* ═══════════════════════════════════════════════════════════════
   style.css — The Lost Tribe — Cave-Art UI Theme
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Cinzel+Decorative:wght@700&display=swap');

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sky:        #b8d0e0;
  --earth:      #c07838;
  --earth-dark: #7a4410;
  --ochre:      #d4932a;
  --ochre-glow: rgba(212, 147, 42, 0.35);
  --ink:        #2a1606;
  --ink-faint:  rgba(42, 22, 6, 0.60);
  --mural:      rgba(55, 72, 95, 0.25);
  --panel-bg:   rgba(24, 12, 4, 0.78);
  --border:     rgba(192, 120, 56, 0.30);
  --text:       #e8d8b8;
  --text-dim:   #a89070;
  --success:    #5a9a40;
  --danger:     #c83018;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0804;
  /* Cinzel for headings, serif fallback */
  font-family: 'Cinzel', Georgia, serif;
  color: var(--text);
}

/* ── App Root ─────────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
}

/* ── Game Container & Canvas ─────────────────────────────────── */
#gameContainer {
  position: absolute;
  inset: 0;
  line-height: 0;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: var(--sky);
}

/* ── Screen Overlays ─────────────────────────────────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  /* Aged parchment cave-wall overlay */
  background:
    radial-gradient(ellipse at 50% 0%,   rgba(160, 90, 20, 0.28) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(90,  50, 10, 0.35) 0%, transparent 55%),
    rgba(14, 8, 3, 0.82);
  color: var(--text);
  text-align: center;
  padding: 36px 28px;
  z-index: 10;
  line-height: normal;
  backdrop-filter: blur(3px);
}

.screen.hidden {
  display: none;
}

/* Decorative top border — like a cave ledge */
.screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    transparent,
    var(--ochre) 20%,
    var(--earth) 50%,
    var(--ochre) 80%,
    transparent
  );
  opacity: 0.55;
}

.screen h1 {
  font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--ochre);
  text-shadow:
    0 0 30px var(--ochre-glow),
    0 2px 0 var(--earth-dark),
    0 4px 12px rgba(0,0,0,0.6);
  /* Slight rough-edge feel */
  -webkit-text-stroke: 0.5px rgba(160, 90, 20, 0.4);
}

.screen h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--ochre);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.subtitle {
  color: var(--text-dim);
  font-family: Georgia, serif;
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  font-style: italic;
  letter-spacing: 0.5px;
}

/* ── Instruction list ─────────────────────────────────────────── */
.instructions {
  list-style: none;
  text-align: left;
  font-family: Georgia, serif;
  font-size: clamp(0.82rem, 1.6vw, 0.95rem);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(212, 147, 42, 0.07);
  border: 1px solid rgba(192, 120, 56, 0.25);
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 380px;
}

.instructions li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hint {
  font-family: Georgia, serif;
  font-size: 0.80rem;
  color: var(--text-dim);
  font-style: italic;
}

.hint a {
  color: var(--ochre);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.2s;
}

.hint a:hover {
  color: #f0b840;
}

/* ── Calibration Bar ──────────────────────────────────────────── */
#calibrationBar {
  width: 260px;
  height: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

#calibrationFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7a9a50, #a0c860);
  border-radius: 5px;
  transition: width 0.08s linear;
}

#calibrationStatus {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Buttons ──────────────────────────────────────────────────── */
button {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #1a0c03;
  background: linear-gradient(160deg, #e0a030, #c87820, #e0a030);
  background-size: 200% 200%;
  border: none;
  border-bottom: 3px solid var(--earth-dark);
  padding: 13px 32px;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow:
    0 4px 16px rgba(200, 120, 32, 0.35),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

button:hover {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow:
    0 6px 22px rgba(200, 120, 32, 0.50),
    inset 0 1px 0 rgba(255,255,255,0.2);
}

button:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
}

button:disabled {
  background: #3a2a18;
  color: var(--text-dim);
  border-bottom-color: #2a1a08;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  filter: none;
}

/* ── HUD — top bar ────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 7px 18px;
  background: linear-gradient(180deg, rgba(20,10,3,0.88) 0%, rgba(20,10,3,0.50) 100%);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  backdrop-filter: blur(4px);
}

#hud.hidden {
  display: none;
}

#scoreDisplay {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ochre);
  text-shadow: 0 0 10px var(--ochre-glow);
}

#debugLabel {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--text-dim);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-style: italic;
  letter-spacing: 0.5px;
}

#debugLabel input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--ochre);
}

/* ── Controls — bottom bar ────────────────────────────────────── */
#controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 7px 18px;
  background: linear-gradient(0deg, rgba(20,10,3,0.88) 0%, rgba(20,10,3,0.50) 100%);
  border-top: 1px solid var(--border);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-style: italic;
  z-index: 20;
  backdrop-filter: blur(4px);
}

#controls label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

#controls input[type="range"] {
  cursor: pointer;
  accent-color: var(--ochre);
  max-width: 200px;
  flex: 1;
  filter: sepia(0.4);
}

#sensitivityValue {
  color: var(--ochre);
  font-style: normal;
  font-weight: bold;
  min-width: 38px;
}

/* ── Webcam Corner Overlay ────────────────────────────────────── */
#webcamOverlay {
  position: fixed;
  bottom: 42px;
  right: 16px;
  width: 188px;
  background: #0c0604;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 22px rgba(0,0,0,0.75);
  z-index: 30;
  display: flex;
  flex-direction: column;
}

#webcamLabel {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 0 3px;
  background: rgba(212, 147, 42, 0.08);
  border-bottom: 1px solid var(--border);
}

#webcamPreview {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0604;
  overflow: hidden;
}

#webcamVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scaleX(-1);
}

#poseCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
}

/* Jump flash indicator */
#jumpIndicator {
  text-align: center;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #1a0c02;
  background: linear-gradient(90deg, #e09020, #d07010);
  padding: 3px 6px;
  opacity: 0;
  transition: opacity 0.08s ease;
  text-transform: uppercase;
}

#jumpIndicator.visible {
  opacity: 1;
}

/* Displacement bar */
#displacementBar {
  position: relative;
  height: 5px;
  background: rgba(20,10,3,0.80);
  width: 100%;
}

#displacementFill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width 0.05s linear;
  max-width: 100%;
}

#thresholdLine {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--ochre);
  left: 66.7%;
}

/* ── Score & Game Over ──────────────────────────────────────────── */
#finalScore {
  font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 700;
  color: var(--ochre);
  text-shadow: 0 0 20px var(--ochre-glow);
  letter-spacing: 3px;
}

#hiScoreDisplay {
  font-family: Georgia, serif;
  font-size: 0.90rem;
  color: var(--text-dim);
  font-style: italic;
}
