:root {
  --ink: #1d1a26;
  --brand: #543C8A;                    /* HRUC primary purple */
  --brand-tint: rgba(84, 60, 138, 0.10);
  --ink-soft: #5a5470;
  --line: rgba(29, 26, 38, 0.10);
  --pink: #ff5fa2;
  --turq: #20c5c0;
  --amber: #ffb547;
  --green: #28c76f;
  --red: #ff5d6c;
  --panel-bg: rgba(255, 255, 255, 0.78);
  --card-bg: #ffffff;
  --radius: 16px;
  --shadow: 0 18px 50px -22px rgba(40, 30, 60, 0.45);
  --header-h: 58px;
  --footer-h: 46px;
  --surface: #f8f4f1;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Raleway", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #f4f1f6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; height: 100vh;
}

/* ---------- Fixed header / footer ---------- */
.site-header,
.site-footer {
  position: relative; z-index: 40;
  flex: 0 0 auto;
  display: flex; align-items: center;
  background: var(--surface);
  padding: 0 22px;
}
.site-header { height: var(--header-h); border-bottom: 1px solid var(--line); }
.site-footer { height: var(--footer-h); border-top: 1px solid var(--line); justify-content: flex-end; }

.site-header__logo { flex: 0 0 auto; display: inline-flex; align-items: center; text-decoration: none; }
.site-header__logo .hruc { height: 40px; width: auto; display: block; }
.site-header__title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-weight: 800; font-size: 18px; letter-spacing: -0.01em;
  color: var(--brand); white-space: nowrap; pointer-events: none;
}
.header-flogo { height: 16px; width: auto; display: block; }
.header-badge {
  margin-left: auto; flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
  color: #F8F4F1;
  background: #2B0326;
  border: none; text-decoration: none;
  border-radius: 11px; padding: 6px 13px; white-space: nowrap;
  transition: opacity .15s ease;
}
.header-badge:hover { opacity: 0.88; }

.made-with {
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--ink-soft); margin-right: 10px;
}
.footer-copyright {
  margin-right: auto;                 /* sits in the bottom-left corner */
  font-size: 13.5px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--ink-soft);
}
.site-footer__logo { display: inline-flex; align-items: center; text-decoration: none; transition: opacity .2s ease; }
.site-footer__logo:hover { opacity: 0.78; }
.site-footer__logo .f3d { height: 24px; width: auto; display: block; }

/* ---------- Layout ---------- */
.app {
  display: flex; width: 100%;
  flex: 1 1 auto; min-height: 0;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(120% 90% at 18% 8%, #ffe6f1 0%, rgba(255,230,241,0) 55%),
    radial-gradient(120% 100% at 95% 100%, #d8f5f3 0%, rgba(216,245,243,0) 55%),
    linear-gradient(160deg, #fbf7fb 0%, #eef3fb 100%);
  overflow: hidden;
}
#scene { display: block; width: 100%; height: 100%; }

/* ---------- Stage chrome ---------- */
.stage-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 18px 22px;
  pointer-events: none;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 15px; letter-spacing: -0.01em;
  color: var(--ink);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  padding: 9px 15px; border-radius: 999px;
  box-shadow: var(--shadow);
}
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--turq));
}

.progress-wrap {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  padding: 10px 14px; border-radius: 999px;
  box-shadow: var(--shadow);
}
.progress-dots { display: flex; gap: 7px; }
.pdot {
  width: 11px; height: 11px; border-radius: 50%;
  background: rgba(29,26,38,0.14);
  transition: background .35s ease, transform .35s ease;
}
.pdot.is-next { background: var(--brand); box-shadow: 0 0 0 4px rgba(84,60,138,0.22); }
.pdot.is-done { background: linear-gradient(135deg, var(--pink), var(--turq)); transform: scale(1.05); }

.stage-hint {
  position: absolute; left: 50%; top: 76px; transform: translateX(-50%);
  max-width: min(560px, 80%);
  text-align: center;
  font-size: 14.5px; font-weight: 600; line-height: 1.45;
  padding: 11px 18px; border-radius: 14px;
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.stage-hint.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.stage-hint.ok { color: #167a48; }
.stage-hint.bad { color: #c83246; }
.stage-hint .why { display: block; font-weight: 500; color: var(--ink-soft); font-size: 13px; margin-top: 3px; }

.stage-tools {
  position: absolute; left: 22px; bottom: 20px;
  display: flex; gap: 9px; flex-wrap: wrap;
}
.tool-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 700; color: var(--ink);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 15px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s ease, background .2s ease;
}
.tool-btn:hover { transform: translateY(-1px); background: #fff; border-color: var(--brand); }
.tool-btn:active { transform: translateY(0); }
.tool-btn[hidden] { display: none; }
.tool-btn svg { color: var(--brand); }

.stage-error {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 320px; text-align: center;
  font-size: 14px; font-weight: 600; color: #c83246;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 20px; box-shadow: var(--shadow);
}
.stage-error[hidden] { display: none; }

.stage-orbit {
  position: absolute; right: 18px; bottom: 16px; margin: 0;
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  background: rgba(255,255,255,0.6);
  padding: 6px 12px; border-radius: 999px;
}

/* ---------- Panel ---------- */
.panel {
  flex: 0 0 380px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 24px 22px 18px;
  overflow-y: auto;
  gap: 22px;
}
.panel-title {
  margin: 0 0 7px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--brand);
}
.panel-sub { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.panel-sub strong { color: var(--brand); }

.group { display: flex; flex-direction: column; gap: 11px; }
.group-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-soft);
}
.counter { color: var(--brand); font-weight: 800; }

/* component cards */
.cards { display: flex; flex-direction: column; gap: 9px; }
.card-wrap { position: relative; }
.card {
  width: 100%;
  display: flex; align-items: center; gap: 13px;
  background: var(--card-bg);
  border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 44px 12px 14px; cursor: pointer; text-align: left;
  font-family: inherit;
  transition: transform .14s ease, border-color .2s ease, box-shadow .2s ease;
  box-shadow: 0 6px 18px -14px rgba(40,30,60,0.5);
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: 0 14px 30px -18px rgba(40,30,60,0.55); }
.card:active { transform: translateY(0); }
.card.shake { animation: shake .42s cubic-bezier(.36,.07,.19,.97); border-color: #D6455C !important; }
@keyframes shake {
  10%,90% { transform: translateX(-2px); }
  20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-7px); }
  40%,60% { transform: translateX(7px); }
}
.swatch {
  flex: 0 0 auto;
  width: 34px; height: 34px; border-radius: 9px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.card-text { min-width: 0; }
.card-name { display: block; font-size: 14.5px; font-weight: 700; line-height: 1.2; color: var(--brand); }
.card-cat { display: block; font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-top: 2px; }
.card.hinted { border-color: var(--amber); box-shadow: 0 0 0 4px rgba(255,181,71,0.22); }

/* per-card "?" help button + popover */
.card-help {
  position: absolute; top: 50%; right: 12px; transform: translateY(-50%); z-index: 2;
  width: 24px; height: 24px; border-radius: 50%; padding: 0; border: none; cursor: pointer;
  display: grid; place-items: center;
  font-family: inherit; font-size: 14px; font-weight: 800; line-height: 1;
  color: #fff; background: var(--brand);
  transition: opacity .15s ease;
}
.card-help:hover { opacity: 0.85; }
.card:hover ~ .card-help { transform: translateY(calc(-50% - 2px)); }
.card-pop {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  background: var(--brand); color: #fff;
  border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 18px 40px -16px rgba(40,30,60,0.55);
  animation: pop .18s ease;
}
.card-pop[hidden] { display: none; }
.card-pop__text { margin: 0; padding-right: 20px; font-size: 13px; font-weight: 500; line-height: 1.45; }
.card-pop__x {
  position: absolute; top: 8px; right: 10px;
  width: 20px; height: 20px; padding: 0; border: none; background: none; cursor: pointer;
  color: #fff; font-size: 19px; line-height: 1; font-weight: 700;
}
.card-pop__x:hover { opacity: 0.8; }

/* installed sequence */
.sequence { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.seq-empty { font-size: 13px; color: var(--ink-soft); font-style: italic; line-height: 1.4; }
.seq-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--line);
  cursor: pointer;
  animation: pop .35s ease;
}
.seq-row:hover { background: #fff; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.seq-num {
  flex: 0 0 auto;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 800; color: #fff;
  background: var(--brand);
}
.seq-swatch { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }
.seq-name { font-size: 13.5px; font-weight: 700; color: var(--brand); }

/* show/hide-in-preview toggle */
.seq-toggle {
  margin-left: auto;
  flex: 0 0 auto;
  width: 40px; height: 22px; border-radius: 999px;
  background: #2B0326; border: none; padding: 0; cursor: pointer;
  position: relative;
  transition: background .2s ease;
}
.seq-toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform .2s ease;
}
.seq-toggle.on { background: var(--brand); }
.seq-toggle.on::after { transform: translateX(18px); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(30, 22, 44, 0.34);
  backdrop-filter: blur(6px);
  padding: 24px;
  animation: fade .35s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Intro variant — centred within the 3D stage, no dark backdrop or blur,
   so the wall and panel stay fully visible on first open. */
.overlay--instage {
  position: absolute; z-index: 20;
  background: transparent;
  backdrop-filter: none;
}
.overlay-card {
  width: min(460px, 92vw);
  background: #fff; border-radius: 22px;
  padding: 30px 30px 26px;
  box-shadow: 0 40px 90px -30px rgba(20,10,40,0.6);
  text-align: center;
}
/* Intro window uses the header/footer surface colour */
#intro .overlay-card { background: var(--surface); }
.intro-hruc { display: block; height: 40px; width: auto; margin: 0 auto 18px; }
.overlay-kicker {
  display: inline-block;
  font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--brand);
  background: var(--brand-tint);
  padding: 6px 12px; border-radius: 999px; margin-bottom: 16px;
}
.overlay-kicker--win { color: var(--turq); background: rgba(32,197,192,0.12); }
.overlay-card h2 { margin: 0 0 10px; font-size: 25px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand); }
.overlay-card p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--ink-soft); }
.overlay-card p strong { color: var(--brand); }
.overlay-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
/* completion CTA — actions row above a full-width Sign Up button */
.overlay-cta { display: inline-flex; flex-direction: column; gap: 20px; margin-top: 18px; }
.overlay-cta .overlay-actions { margin-top: 0; }
.overlay-btn.overlay-btn--signup {
  width: 100%; margin-top: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--brand); text-decoration: none;
}
.signup-wordmark { height: 18px; width: auto; display: block; }
.overlay-btn {
  font-family: inherit; font-size: 15px; font-weight: 800; color: #fff;
  background: var(--brand);
  border: none; border-radius: 999px;
  padding: 13px 26px; margin-top: 8px; cursor: pointer;
  box-shadow: 0 14px 30px -12px rgba(84, 60, 138, 0.7);
  transition: transform .15s ease;
}
.overlay-btn:hover { transform: translateY(-2px); }
.overlay-btn--ghost {
  background: #fff; color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  /* Mobile: fixed layout — the top 50% is the 3D canvas, all controls live in a
     scrollable bottom dock. No page scroll. (Desktop layout is unchanged.) */
  body { overflow: hidden; height: 100dvh; }
  .app { flex-direction: column; height: auto; min-height: 0; flex: 1 1 auto; }
  .stage { flex: 0 0 50%; height: auto; min-height: 0; }
  .panel {
    flex: 1 1 0; min-height: 0; width: 100%;
    border-left: none; border-top: 1px solid var(--line);
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 14px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    gap: 12px;
  }

  /* compact the panel head — hide the long intro line on mobile */
  .panel-title { font-size: 18px; margin-bottom: 0; }
  .panel-sub { display: none; }

  /* collapsible sections — tap the header to expand/collapse (chevron on the left) */
  .group { gap: 9px; }
  .group-label { cursor: pointer; user-select: none; justify-content: flex-start; gap: 8px; }
  .group-label::before {
    content: '⌄'; width: 12px; text-align: center; font-size: 15px; line-height: 1;
    color: var(--ink-soft); transition: transform .2s ease;
  }
  .group.collapsed .group-label::before { transform: rotate(-90deg); }
  .group-label .counter { margin-left: auto; }
  .group.collapsed > .cards,
  .group.collapsed > .sequence { display: none; }

  /* compact header so the logo, title and badge never clash */
  .site-header, .site-footer { padding: 0 14px; }
  .site-header__logo .hruc { height: 30px; }
  .site-header__title { font-size: 16px; }
  .header-flogo { height: 16px; }
  .badge-text { display: none; }
  .header-badge { padding: 6px 9px; }

  /* compact footer */
  .made-with { font-size: 12px; margin-right: 8px; }
  .footer-copyright { font-size: 12px; }
  .site-footer__logo .f3d { height: 20px; }

  /* stage chrome */
  .stage-orbit { display: none; }
  .stage-top { padding: 10px 12px; }
  .progress-wrap { padding: 7px 9px; }
  .pdot { width: 7px; height: 7px; }
  .stage-hint { top: 56px; font-size: 13px; max-width: 88%; }
  .stage-tools { left: 12px; bottom: 12px; gap: 7px; }
  .tool-btn { font-size: 12.5px; padding: 8px 12px; }

  /* intro becomes a full-screen modal (a 50%-height stage can't hold its card) */
  #intro.overlay--instage {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(30, 22, 44, 0.30); backdrop-filter: blur(4px);
  }
  /* overlays centre when they fit, scroll when taller than the screen */
  .overlay { align-items: safe center; overflow-y: auto; padding: 16px; }
}
