:root {
  --gold: #d8b46a;
  --gold-bright: #f2d492;
  --ink: #e9e2d0;
  --panel: rgba(18, 14, 26, 0.72);
  --panel-solid: rgba(18, 14, 26, 0.92);
  --border: rgba(216, 180, 106, 0.35);
  --slot-panel-1: rgba(74, 64, 86, 0.78);
  --slot-panel-2: rgba(52, 44, 65, 0.76);
  --slot-panel-3: rgba(34, 28, 45, 0.74);
  --slot-panel-4: var(--panel);
}

* { box-sizing: border-box; }

/* generic hide utility — used by #intro, #draw-btn, etc. */
.hidden { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05040a;
  color: var(--ink);
  font-family: "Cormorant Garamond", "Palatino Linotype", Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

#scene-container { position: fixed; inset: 0; }
#scene-container canvas { display: block; }

/* cinematic vignette: darkens the frame edges, drawing the eye to the table.
   above the canvas, below the HUD (z-index 10), and non-interactive. */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.55) 100%);
}

/* --- overlay layer: click-through except on actual panels --- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud .panel { pointer-events: auto; }

.title-bar {
  position: absolute; top: 22px; left: 0; right: 0;
  text-align: center;
}
.title-bar h1 {
  margin: 0; font-size: clamp(22px, 4vw, 40px); font-weight: 600;
  letter-spacing: 0.14em; color: var(--gold-bright);
  text-shadow: 0 0 18px rgba(216, 180, 106, 0.45);
}
.title-bar p {
  margin: 4px 0 0; font-size: 14px; letter-spacing: 0.32em;
  text-transform: uppercase; color: rgba(233, 226, 208, 0.55);
}
#logo {
  width: auto; height: auto; display: inline-block;   /* natural 86x118 */
  filter: drop-shadow(0 0 18px rgba(216, 180, 106, 0.35));
}

/* intro / question panel */
#intro {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  width: min(560px, 92vw);
  background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 24px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
#intro label {
  display: block; font-size: 15px; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(233,226,208,0.6); margin-bottom: 12px;
}
#question {
  width: 100%; background: rgba(0,0,0,0.35); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 18px; font-family: inherit; text-align: center;
  outline: none;
}
#question:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(216,180,106,0.25); }

.btn {
  font-family: inherit; cursor: pointer; user-select: none;
  background: linear-gradient(180deg, rgba(216,180,106,0.22), rgba(216,180,106,0.08));
  color: var(--gold-bright); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 22px; font-size: 16px;
  letter-spacing: 0.14em; text-transform: uppercase; transition: all 0.18s ease;
}
.btn:hover { background: rgba(216,180,106,0.28); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; }

/* slow golden pulse around the Draw button */
#draw-btn {
  margin-top: 16px; position: relative;
  animation: draw-pulse 3.6s ease-in-out infinite;
}
@keyframes draw-pulse {
  0%, 100% { box-shadow: 0 0 5px rgba(216, 180, 106, 0.22); border-color: var(--border); }
  50%      { box-shadow: 0 0 22px 3px rgba(242, 212, 146, 0.55); border-color: var(--gold); }
}
@media (prefers-reduced-motion: reduce) {
  #draw-btn { animation: none; }
}

/* top-right controls */
#controls {
  position: absolute; top: 20px; right: 20px; display: flex; gap: 10px;
}
#controls .btn { padding: 9px 16px; font-size: 13px; }
#controls.hidden { display: none; }

/* Keep "New Reading" on one line on every viewport. */
.mobile-br { display: none; }
@media (max-width: 640px) {
  #controls .btn { white-space: nowrap; text-align: center; }
}

/* persistent sound toggle, top-left */
#sound-btn {
  position: absolute; top: 20px; left: 20px;
  padding: 8px 12px; font-size: 16px; line-height: 1;
}

/* bottom readout: three spread slots */
#readout {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  /* reserve a fixed-height region and top-align, so the dots + card top stay
     steady and only the card's depth grows downward for longer interpretations */
  justify-content: flex-start; min-height: 185px;
}
#readout.hidden { display: none; }

/* row holding the arrows + the single active card */
.carousel-row { display: flex; align-items: center; justify-content: center; gap: 12px; }

/* pagination dots: ghost outline, active one filled */
.dots { display: flex; gap: 11px; align-items: center; }
.dot {
  width: 13px; height: 13px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  pointer-events: auto; cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.dot:hover { border-color: var(--gold-bright); transform: scale(1.25); }
.dot.dot-active { background: var(--gold-bright); border-color: var(--gold-bright); cursor: default; }
.dot.dot-active:hover { transform: none; }

/* carousel: one card at a time, flanked by arrow buttons */
.reading-cards { width: min(380px, 78vw); }
.col { display: none; flex-direction: column; align-items: stretch; gap: 8px; }
.col.active { display: flex; }
.show-btn { align-self: center; pointer-events: auto; padding: 7px 16px; font-size: 13px; }

.nav-arrow {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer; color: var(--gold-bright);
  background: rgba(216,180,106,0.12); border: 1px solid var(--border);
  transition: background 0.18s ease, transform 0.18s ease;
}
.nav-arrow:hover { background: rgba(216,180,106,0.28); }
.nav-arrow:active { transform: scale(0.92); }

.slot {
  position: relative;
  width: 100%; background: var(--panel); backdrop-filter: blur(8px);
  border: 1px solid rgba(216,180,106,0.18); border-radius: 12px;
  padding: 12px 14px; min-height: 78px; text-align: center;
  opacity: 0.45; transition: opacity 0.4s ease, border-color 0.4s ease;
}
.slot.slot-tone-1 { background: var(--slot-panel-1); }
.slot.slot-tone-2 { background: var(--slot-panel-2); }
.slot.slot-tone-3 { background: var(--slot-panel-3); }
.slot.slot-tone-4 { background: var(--slot-panel-4); }

/* circular "play interpretation" speaker button, top-right of a revealed box */
.speak-btn {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer; color: var(--gold-bright);
  background: rgba(216,180,106,0.12); border: 1px solid var(--border);
  transition: background 0.18s ease, transform 0.18s ease;
  overflow: visible;
}
.speak-btn:hover { background: rgba(216,180,106,0.28); }
.speak-btn:active { transform: scale(0.92); }
.speak-btn.interp-idle {
  border-color: rgba(242,212,146,0.88);
  box-shadow: 0 0 10px rgba(242,212,146,0.35);
}
.speak-btn.interp-idle::after {
  content: "";
  position: absolute; inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(242,212,146,0.78);
  box-shadow: 0 0 14px rgba(242,212,146,0.65);
  pointer-events: none;
  animation: speak-pulse 2s ease-in-out infinite;
}
@keyframes speak-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.86); }
  50% { opacity: 1; transform: scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .speak-btn.interp-idle::after { animation: none; opacity: 0.8; transform: none; }
}
.slot.revealed { opacity: 1; border-color: var(--border); }
.slot .pos {
  font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 4px;
}
.slot .name { font-size: 19px; color: var(--gold-bright); font-weight: 600; }
.slot .kw { font-size: 15px; color: rgba(233,226,208,0.75); margin-top: 2px; font-style: italic; }
.slot .hint { font-size: 14px; color: rgba(233,226,208,0.4); }

/* transient hint toast */
#toast {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 20px; font-size: 15px; letter-spacing: 0.08em;
  color: var(--ink); opacity: 0; transition: opacity 0.5s ease; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* the seeker's question, shown at the top in place of the logo during a reading */
#asked {
  max-width: min(680px, 92vw); margin: 0 auto; text-align: center; pointer-events: none;
  font-style: italic; font-size: clamp(18px, 2.4vw, 26px);
  color: var(--gold-bright); letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(216, 180, 106, 0.35), 0 2px 12px rgba(0, 0, 0, 0.8);
}
@media (max-width: 640px) {
  #asked {
    margin-top: 54px;
    max-width: min(520px, 88vw);
  }
}

#loader {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #05040a; z-index: 50; color: var(--gold); letter-spacing: 0.3em;
  text-transform: uppercase; font-size: 14px; transition: opacity 0.6s ease;
}
#loader.hidden { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  .slot .name { font-size: 16px; }
  #readout { gap: 8px; bottom: 14px; }
  .title-bar { top: 12px; }
}
