@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Space+Mono:wght@400;700&display=swap');

:root {
  --ink: #1a1410;
  --paper: #f4ede1;
  --wine: #6b1f2a;
  --gold: #c9a24b;
  --moss: #4a5942;
  --jade: #4e8577;
  --jade-dark: #2f5d51;
  --glass: rgba(26, 20, 16, 0.55);
}

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

body {
  font-family: 'Space Mono', monospace;
  background: var(--ink);
  color: var(--paper);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

h1, h2, .display {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---------- Stage / webcam ---------- */
#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
}

#webcam {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

#hud {
  position: absolute;
  top: 28px; right: 28px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(244,237,225,0.15);
  border-radius: 4px;
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: 0.03em;
  z-index: 5;
}

#hud span { color: var(--gold); font-weight: 700; }
#hud .hud-label { color: var(--paper); font-weight: 400; }

/* ---------- Hi screen — first thing you see ---------- */
#hi-screen {
  position: absolute;
  inset: 0;
  background: #F2E6B1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 25;
}

#hi-btn { text-transform: none; }

/* Shared 3D treatment for Hi + Start buttons */
#hi-btn, #start-btn {
  border-radius: 6px;
  box-shadow:
    0 5px 0 #4a141d,
    0 9px 14px rgba(26, 20, 16, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

#hi-btn:hover, #start-btn:hover {
  background: #82252f;
  transform: translateY(2px);
  box-shadow:
    0 3px 0 #4a141d,
    0 6px 10px rgba(26, 20, 16, 0.25);
}

#hi-btn:active, #start-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 0 0 #4a141d,
    0 3px 6px rgba(26, 20, 16, 0.2);
}

/* ---------- Start screen — cream ---------- */
/* Two-column layout at every size: title + eyes left, instructions + start
   right. A single centered column overflows short viewports and flex-centering
   clips the overflow where scrolling can't reach it. */
#start-screen {
  position: absolute;
  inset: 0;
  background: #F2E6B1;
  display: grid;
  grid-template-columns: auto minmax(0, 500px);
  grid-template-areas:
    "title intro"
    "eyes  steps"
    "eyes  btn";
  align-content: center;
  justify-content: center;
  column-gap: 48px;
  text-align: center;
  z-index: 20;
  padding: 40px;
  overflow: hidden auto;
}

/* Drifting dot pattern — steps() keeps the stop-motion feel */
#start-screen::before {
  content: "";
  position: absolute;
  inset: -180px;
  background-image:
    radial-gradient(rgba(107, 31, 42, 0.10) 3px, transparent 3px),
    radial-gradient(rgba(78, 133, 119, 0.14) 2.5px, transparent 2.5px);
  background-size: 90px 90px, 60px 60px;
  background-position: 0 0, 30px 30px;
  animation: dot-drift 16s steps(32) infinite;
  pointer-events: none;
}

@keyframes dot-drift {
  to { background-position: 90px 180px, 150px 90px; }
}

/* Slowly rotating dashed rings — echo the harmony discs */
.deco-disc {
  position: absolute;
  border: 2px dashed rgba(78, 133, 119, 0.35);
  border-radius: 50%;
  pointer-events: none;
  animation: disc-spin 40s steps(48) infinite linear;
}

.deco-disc::after {
  content: "";
  position: absolute;
  inset: 14%;
  border: 2px dashed rgba(107, 31, 42, 0.22);
  border-radius: 50%;
}

.deco-disc--left {
  width: 42vmin;
  height: 42vmin;
  left: -14vmin;
  bottom: -14vmin;
}

.deco-disc--right {
  width: 34vmin;
  height: 34vmin;
  right: -10vmin;
  top: -10vmin;
  animation-direction: reverse;
}

@keyframes disc-spin {
  to { transform: rotate(360deg); }
}

/* Keep content above the pattern layers */
#start-screen > h1,
#start-screen > canvas,
#start-screen > p,
#start-screen > ol,
#start-screen > button {
  position: relative;
  z-index: 1;
}

#instructions {
  grid-area: steps;
  max-width: 480px;
  text-align: left;
  font-size: 13px;
  line-height: 1.7;
  color: rgba(26, 20, 16, 0.65);
  margin: 0 0 32px;
  padding-left: 24px;
}

#instructions li { margin-bottom: 8px; }
#instructions li::marker { color: var(--wine); font-weight: 700; }
#instructions strong { color: var(--wine); }

#start-screen h1 {
  grid-area: title;
  justify-self: center;
  align-self: end;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: clamp(36px, 5vw, 64px);
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 8px;
}

#start-screen p {
  grid-area: intro;
  align-self: end;
  text-align: left;
  max-width: 480px;
  font-size: 14px;
  line-height: 1.7;
  color: rgba(26, 20, 16, 0.65);
  margin-bottom: 14px;
}

#start-btn {
  grid-area: btn;
  justify-self: start;
}

#start-screen strong { color: var(--wine); }

button {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--wine);
  color: var(--paper);
  border: none;
  padding: 16px 40px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

button:hover { background: #82252f; transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

#rotate-warning { display: none; }

/* Only block portrait phones — landscape is playable */
@media (max-width: 700px) and (orientation: portrait) {
  #rotate-warning {
    display: flex;
    position: absolute;
    inset: 0;
    background: var(--ink);
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    z-index: 30;
  }
}

/* ---------- Eyes canvas scales with the viewport ---------- */
#eye-canvas {
  grid-area: eyes;
  justify-self: center;
  align-self: start;
  max-width: min(400px, 40vw);
  height: auto;
}

/* ---------- Small landscape screens (phones held sideways) ---------- */
@media (max-height: 520px) {
  #start-screen {
    grid-template-columns: auto minmax(0, 400px);
    column-gap: 24px;
    padding: 16px;
  }

  #start-screen h1 {
    font-size: 30px;
    margin-bottom: 2px;
  }

  #eye-canvas { max-width: 190px; }

  #start-screen p {
    font-size: 11px;
    margin-bottom: 6px;
  }

  #instructions {
    font-size: 10.5px;
    line-height: 1.5;
    margin-bottom: 8px;
  }

  #instructions li { margin-bottom: 3px; }

  #start-btn, #hi-btn {
    font-size: 12px;
    padding: 10px 28px;
  }

  #hud {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 10px;
    line-height: 1.6;
  }

  #hindi-toggle {
    bottom: 10px;
    font-size: 10px;
    padding: 6px 16px;
  }
}

#hindi-toggle {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  padding: 14px 32px;
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: 4px;
  letter-spacing: 0.12em;
  z-index: 5;
  animation: toggle-beckon 2.2s ease-in-out infinite;
  transition: background 0.2s ease, color 0.2s ease;
}

#hindi-toggle:hover {
  background: #d9b25b;
  transform: translateX(-50%);
}

/* once you're in — quiet down, show the way back */
#hindi-toggle.active {
  background: var(--glass);
  color: var(--paper);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(244,237,225,0.2);
  font-size: 12px;
  padding: 10px 24px;
  animation: none;
}

@keyframes toggle-beckon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 162, 75, 0.55); }
  50%      { box-shadow: 0 0 0 12px rgba(201, 162, 75, 0); }
}