/* =============================================================================
   Orgasms & Magic — stylesheet
   Same visual language as the Chaos Sphere Generator: black glass panels,
   monospace type, thin borders, backdrop blur. Accent here is ritual violet.
   Sections:
     1. Reset + body
     2. Gate (loader / start) + end screen
     3. Phase label overlay
     4. Header chip
     5. Transport (timeline)
     6. Buttons + corner links
     7. Modals (credits / help)
     8. Toast
     9. Mobile
   ========================================================================== */

/* ---- 1. Reset + body ----------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #eee;
  font-family: 'SF Mono', 'Fira Code', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  -webkit-text-size-adjust: 100%;
}

#ritualCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#ritualCanvas:active { cursor: grabbing; }

:root {
  --accent: #c04dff;
  --accent-soft: rgba(192, 77, 255, 0.35);
  --glass: rgba(0, 0, 0, 0.72);
  --line: rgba(255, 255, 255, 0.15);
}

body.ui-hidden #app-chip,
body.ui-hidden #transport,
body.ui-hidden #credits-btn,
body.ui-hidden #download-link,
body.ui-hidden #fullscreen-btn,
body.ui-hidden #know-more-link { opacity: 0; pointer-events: none; }

/* the cursor vanishes and returns together with the interface */
body.ui-hidden,
body.ui-hidden #ritualCanvas { cursor: none; }

#app-chip, #transport, #credits-btn, #download-link, #fullscreen-btn, #know-more-link {
  transition: opacity 0.5s ease;
}

/* ---- 2. Gate (loader / start) + end screen -------------------------------- */
#gate, #end-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(30, 0, 45, 0.92), rgba(0, 0, 0, 0.98));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 1.2s ease;
  padding: 20px;
}
#gate.leaving, #end-screen.leaving { opacity: 0; pointer-events: none; }

.gate-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  padding: 28px 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.8), 0 0 80px rgba(192, 77, 255, 0.08) inset;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.gate-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
.gate-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #222;
  transition: background 0.4s, box-shadow 0.4s, transform 0.4s;
}
.gate-dots span.lit { transform: scale(1.15); }
.gate-dots span:nth-child(1).lit { background: #ff2b2b; box-shadow: 0 0 12px #ff2b2b; }
.gate-dots span:nth-child(2).lit { background: #ff8c1a; box-shadow: 0 0 12px #ff8c1a; }
.gate-dots span:nth-child(3).lit { background: #ffd21a; box-shadow: 0 0 12px #ffd21a; }
.gate-dots span:nth-child(4).lit { background: #2eff5e; box-shadow: 0 0 12px #2eff5e; }
.gate-dots span:nth-child(5).lit { background: #2e8cff; box-shadow: 0 0 12px #2e8cff; }
.gate-dots span:nth-child(6).lit { background: #ffffff; box-shadow: 0 0 12px #ffffff; }
.gate-dots span:nth-child(7).lit { background: #c04dff; box-shadow: 0 0 16px #c04dff; }

.gate-title {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 4px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(192, 77, 255, 0.55), 0 0 60px rgba(192, 77, 255, 0.3);
}
.gate-sub {
  margin: 0 0 16px;
  color: #999;
  font-size: 12px;
  letter-spacing: 2px;
}
.gate-desc {
  margin: 0 0 14px;
  color: #bbb;
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
}
.gate-desc em { color: var(--accent); font-style: normal; }
.gate-warn {
  margin: 0 0 16px;
  color: #ff8c8c;
  font-size: 11px;
  letter-spacing: 1px;
}

.gate-progress {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 8px;
}
.gate-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ff2b2b, #ff8c1a, #ffd21a, #2eff5e, #2e8cff, #fff, #c04dff);
  transition: width 0.25s ease;
}
.gate-status {
  color: #777;
  font-size: 10px;
  letter-spacing: 1px;
  margin-bottom: 18px;
  min-height: 14px;
}

.gate-start {
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 3px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, rgba(192, 77, 255, 0.25), rgba(255, 43, 43, 0.18));
  border: 1px solid var(--accent-soft);
  border-radius: 10px;
  padding: 14px 34px;
  cursor: pointer;
  transition: all 0.25s;
  width: 100%;
}
.gate-start:disabled { opacity: 0.3; cursor: default; }
.gate-start:not(:disabled):hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-soft);
  transform: translateY(-1px);
}
.gate-hint {
  margin: 14px 0 0;
  color: #666;
  font-size: 10px;
  letter-spacing: 1px;
}

/* ---- 3. Phase label overlay ----------------------------------------------- */
#phase-label {
  position: fixed;
  top: 12vh;
  left: 0;
  right: 0;
  text-align: center;
  z-index: 9000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
#phase-label.visible { opacity: 1; transform: translateY(0) scale(1); }
#phase-label.pop { transition: none; transform: scale(1.12); }

#phaseTitle {
  margin: 0;
  font-size: clamp(30px, 7vw, 64px);
  letter-spacing: 0.22em;
  font-weight: bold;
  color: var(--phase-color, #fff);
  text-shadow:
    0 0 18px var(--phase-color, #fff),
    0 0 70px var(--phase-color, #fff);
}
#phaseSub {
  margin: 8px 0 0;
  font-size: clamp(11px, 2.2vw, 15px);
  letter-spacing: 0.28em;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
}
/* consecration only: a frosted pill so the subtitle survives the white column */
#phase-label.shield #phaseSub {
  display: table;
  margin: 8px auto 0;
  padding: 5px 16px;
  border-radius: 10px;
  background: rgba(5, 0, 12, 0.45);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95);
}

/* ---- 4. Header chip -------------------------------------------------------- */
.chip-panel {
  position: fixed;
  left: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  user-select: none;
  /* the whole chip is a button that opens the About modal */
  color: #eee;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.5s ease, border-color 0.2s, background 0.2s;
}
.chip-panel:hover { border-color: var(--accent-soft); background: rgba(20, 8, 30, 0.8); }
.chip-icon { color: var(--accent); font-size: 15px; }
.chip-label { font-weight: bold; font-size: 13px; }
.chip-help {
  margin-left: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #aaa;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  transition: all 0.15s;
}
.chip-panel:hover .chip-help { color: var(--accent); border-color: var(--accent-soft); }

#fullscreen-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  color: #aaa;
  font-family: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.5s ease, color 0.2s, border-color 0.2s;
}
#fullscreen-btn:hover { color: var(--accent); border-color: var(--accent-soft); }

/* ---- 5. Transport (timeline) ------------------------------------------------ */
#transport {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 42px;
  width: min(860px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  user-select: none;
}

.tp-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  border: 1px solid var(--accent-soft);
  background: rgba(192, 77, 255, 0.12);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tp-btn:hover { background: rgba(192, 77, 255, 0.28); box-shadow: 0 0 14px var(--accent-soft); }

.tp-time {
  color: #999;
  font-size: 11px;
  min-width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tp-track {
  position: relative;
  flex: 1;
  height: 22px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}
.tp-track:focus-visible { box-shadow: 0 0 0 1px var(--accent-soft); }

.tp-regions { position: absolute; inset: 0; }
.tp-region {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.32;
}
.tp-marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 2px;
  border-radius: 1px;
  opacity: 0.9;
}

.tp-progress {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.05));
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
.tp-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 8px #fff;
  pointer-events: none;
}

/* ---- 6. Buttons + corner links ---------------------------------------------- */
#know-more-link {
  position: fixed;
  bottom: 12px;
  right: 16px;
  color: rgba(255, 255, 255, 0.35);
  font-family: inherit;
  font-size: 11px;
  text-decoration: none;
  z-index: 10000;
  transition: color 0.2s;
}
#know-more-link:hover { color: var(--accent); }

#download-link {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.35);
  font-family: inherit;
  font-size: 11px;
  text-decoration: none;
  z-index: 10000;
  transition: color 0.2s;
}
#download-link:hover { color: var(--accent); }

#credits-btn {
  position: fixed;
  bottom: 12px;
  left: 16px;
  z-index: 10000;
  font-family: inherit;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s;
}
#credits-btn:hover { color: var(--accent); }

/* ---- 7. Modals ----------------------------------------------------------------- */
#credits-modal, #help-modal {
  position: fixed;
  inset: 0;
  z-index: 15000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}

.modal-card {
  position: relative;
  max-width: 430px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: rgba(8, 4, 14, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 26px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.8);
  scrollbar-width: thin;
}
.modal-card h2 {
  margin: 0 0 10px;
  font-size: 17px;
  letter-spacing: 3px;
  color: var(--accent);
}
.modal-intro { color: #bbb; font-size: 12px; line-height: 1.65; }
.modal-foot { color: #777; font-size: 11px; margin-top: 16px; text-align: center; }
.modal-foot a { color: var(--accent); text-decoration: none; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: #aaa;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
}
.modal-close:hover { color: #fff; border-color: var(--accent-soft); }

.credit-rows { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.credit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}
.credit-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
}
.credit-name { color: #eee; font-size: 12px; }
.credit-role { margin-left: auto; color: #888; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; text-align: right; }

.help-keys { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.help-keys div { display: flex; align-items: center; gap: 10px; color: #aaa; font-size: 11px; }
.help-keys kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 10px;
  color: #ddd;
  min-width: 46px;
  text-align: center;
}

/* ---- 8. Toast --------------------------------------------------------------------- */
#toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #ddd;
  font-size: 11px;
  padding: 8px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 16000;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 9. Mobile -------------------------------------------------------------------- */
@media (max-width: 600px) {
  .chip-panel { left: 10px; top: 10px; padding: 6px 10px; }
  .chip-label { font-size: 11px; }
  #fullscreen-btn { top: 10px; right: 10px; width: 32px; height: 32px; font-size: 15px; }

  #transport {
    bottom: 34px;
    width: calc(100vw - 20px);
    padding: 8px 10px;
    gap: 7px;
  }
  .tp-time { min-width: 32px; font-size: 10px; }
  .tp-btn { width: 30px; height: 30px; flex-basis: 30px; }

  #phase-label { top: 10vh; }
  .gate-card { padding: 20px 16px; }
  .gate-title { font-size: 18px; letter-spacing: 3px; }
  .gate-desc { font-size: 11px; }

  #credits-btn { bottom: 10px; left: 12px; }
  #download-link { bottom: 10px; font-size: 10px; }
  #know-more-link { bottom: 10px; right: 12px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  #transport { bottom: 12px; }
  #phase-label { top: 6vh; }
}
