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

/* ── THEME TOKENS ──────────────────────────────────────────── */
:root {
  --bg: #f7f4ef;
  --bg2: #eeeae2;
  --surface: rgba(255, 255, 255, 0.85);
  --glass: rgba(247, 244, 239, 0.78);
  --text: #0f0e0c;
  --muted: rgba(15, 14, 12, 0.38);
  --faint: rgba(15, 14, 12, 0.12);
  --accent: #e84b1a;
  --accent2: #f5a623;
  --gold: #c49a2e;
  --success: #16a34a;
  --border: rgba(15, 14, 12, 0.1);
  --shadow: rgba(15, 14, 12, 0.12);
  --panel-blur: 18px;
}

[data-theme="dark"] {
  --bg: #0e0c09;
  --bg2: #161410;
  --surface: rgba(20, 18, 14, 0.85);
  --glass: rgba(14, 12, 9, 0.82);
  --text: #f0ede7;
  --muted: rgba(240, 237, 231, 0.38);
  --faint: rgba(240, 237, 231, 0.1);
  --border: rgba(240, 237, 231, 0.1);
  --shadow: rgba(0, 0, 0, 0.35);
}

/* ── BASE ──────────────────────────────────────────────────── */
html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  cursor: none;
  transition: background 0.6s ease, color 0.4s ease;
}

/* ── LOAD BAR ──────────────────────────────────────────────── */
#loadbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 9999;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

/* ── CURSOR ────────────────────────────────────────────────── */
#cd {
  position: fixed;
  z-index: 8000;
  pointer-events: none;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.18s, height 0.18s, background 0.3s;
}

#cr {
  position: fixed;
  z-index: 7999;
  pointer-events: none;
  width: 36px;
  height: 36px;
  border: 1.5px solid rgba(232, 75, 26, 0.4);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.25s, opacity 0.3s;
}

#trail {
  position: fixed;
  inset: 0;
  z-index: 7998;
  pointer-events: none;
}

/* ── 3D CANVAS ─────────────────────────────────────────────── */
#cv {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* ── OVERLAYS ──────────────────────────────────────────────── */
#grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.022;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
  mix-blend-mode: multiply;
  animation: gS 0.45s steps(1) infinite;
}

[data-theme="dark"] #grain {
  mix-blend-mode: screen;
  opacity: 0.028;
}

@keyframes gS {
  0% {
    background-position: 0 0;
  }

  25% {
    background-position: -30px 16px;
  }

  50% {
    background-position: 12px -12px;
  }

  75% {
    background-position: -14px 24px;
  }
}

#vig {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

[data-theme="light"] #vig {
  background: radial-gradient(ellipse 76% 66% at 50% 50%, transparent 0%, transparent 40%, rgba(232, 228, 220, 0.45) 70%, rgba(220, 215, 206, 0.85) 100%);
}

[data-theme="dark"] #vig,
html:not([data-theme]) #vig {
  background: radial-gradient(ellipse 76% 66% at 50% 50%, transparent 0%, transparent 40%, rgba(8, 7, 5, 0.45) 70%, rgba(5, 4, 3, 0.88) 100%);
}

/* ── NAV ───────────────────────────────────────────────────── */
#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 36px;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.55s, transform 0.55s;
}

#nav.on {
  opacity: 1;
  transform: translateY(0);
}

.nlogo {
  font-family: "DM Mono", monospace;
  font-size: 13px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.6;
  transition: color 0.4s;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nbadge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--text);
  color: var(--bg);
  padding: 7px 16px 7px 12px;
  border-radius: 100px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  transition: background 0.4s, color 0.4s;
}

.bdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bp 2s ease infinite;
  flex-shrink: 0;
}

@keyframes bp {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(232, 75, 26, 0.5);
  }

  50% {
    opacity: 0.6;
    box-shadow: 0 0 0 5px rgba(232, 75, 26, 0);
  }
}

#theme-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: border-color 0.25s, background 0.25s, transform 0.2s;
  color: var(--text);
}

#theme-btn:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

/* ── FLOATING PANEL ────────────────────────────────────────── */
#panel {
  position: fixed;
  top: 50%;
  right: 28px;
  z-index: 30;
  transform: translateY(-50%) translateX(16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.6s ease 1.8s, transform 0.6s ease 1.8s;
  max-height: 92vh;
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: none;
  padding: 4px 0;
}

#panel::-webkit-scrollbar {
  display: none;
}

#panel.on {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.p-title {
  text-align: right;
  font-family: "DM Mono", monospace;
  font-size: 7.5px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  padding-right: 1px;
}

.cat-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-right: 1px;
  margin-bottom: 2px;
}

.cat-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name {
  font-family: "DM Mono", monospace;
  font-size: 7px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.65;
}

.anim-btn {
  font-family: "DM Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 7px 13px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: none;
  text-align: right;
  white-space: nowrap;
  transition: background 0.22s, color 0.22s, border-color 0.22s, box-shadow 0.28s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.anim-btn .kh {
  font-size: 7px;
  opacity: 0.4;
  letter-spacing: 0.05em;
  min-width: 10px;
  text-align: center;
}

.anim-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(-2px);
}

.anim-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  box-shadow: 0 4px 18px var(--shadow);
}

.anim-btn.active .kh {
  opacity: 0.35;
}

/* ── KEYBOARD HINT ─────────────────────────────────────────── */
#kbd-hint {
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-family: "DM Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease 2.8s;
  display: flex;
  align-items: center;
  gap: 8px;
}

#kbd-hint.on {
  opacity: 1;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 9px;
  color: var(--muted);
}

/* ── MAIN UI ───────────────────────────────────────────────── */
#ui {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 32px;
  pointer-events: none;
}

/* ── BRAND LOGO ────────────────────────────────────────────── */
.brand-logo {
  display: block;
  max-width: 160px;
  width: 100%;
  height: auto;
  margin: 0 auto 28px;
  object-fit: contain;
  opacity: 0;
  transform: translateY(14px) scale(0.92);
  transition: opacity 0.65s ease 0.4s, transform 0.65s ease 0.4s, filter 0.4s ease;
  pointer-events: none;
  filter: none;
}

.brand-logo.in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── HEADINGS ──────────────────────────────────────────────── */
.hw {
  overflow: visible;
  line-height: 1;
  margin-bottom: 4px;
}

.hl {
  display: block;
  font-family: "Playfair Display", serif;
  font-weight: 900;
  font-size: clamp(58px, 9vw, 134px);
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.1;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.2s cubic-bezier(0.34, 1.56, 0.64, 1), transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.4s;
  /* Text visibility fix — ensure readable over 3D animation */
  text-shadow: 0 0 40px var(--bg), 0 0 80px var(--bg), 0 0 120px var(--bg);
}

.hl.in {
  opacity: 1;
  transform: translateY(0);
}

.hl em {
  font-style: italic;
  font-weight: 700;
  color: transparent;
  -webkit-text-stroke: 2px var(--text);
  transition: -webkit-text-stroke 0.4s;
}

[data-theme="dark"] .hl em {
  -webkit-text-stroke: 1.5px var(--text);
}

/* ── SUBTITLE ──────────────────────────────────────────────── */
.sub {
  font-family: "DM Sans", sans-serif;
  font-weight: 300;
  font-size: clamp(13px, 1.4vw, 15px);
  color: var(--muted);
  line-height: 1.8;
  max-width: 340px;
  margin-top: 22px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.65s ease 0.9s, transform 0.65s ease 0.9s, color 0.4s;
  text-shadow: 0 0 20px var(--bg), 0 0 40px var(--bg);
}

.sub.in {
  opacity: 1;
  transform: translateY(0);
}

/* ── RULE ──────────────────────────────────────────────────── */
.rule {
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 28px auto;
  opacity: 0;
  transition: width 0.85s ease 1.1s, opacity 0.85s ease 1.1s;
}

.rule.in {
  width: 130px;
  opacity: 1;
}

/* ── BOTTOM BAR ────────────────────────────────────────────── */
#bbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px 22px;
  opacity: 0;
  transition: opacity 0.5s ease 2.3s;
  pointer-events: none;
}

#bbar.on {
  opacity: 1;
}

.bb-left {
  display: flex;
  align-items: center;
  gap: 18px;
}

.bb-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

#anim-name {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  transition: opacity 0.3s, color 0.4s;
}

#anim-cat {
  font-family: "DM Mono", monospace;
  font-size: 7.5px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: border-color 0.3s, color 0.3s;
}

.sbar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sbl {
  font-family: "DM Mono", monospace;
  font-size: 7.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.sbt {
  width: 55px;
  height: 1.5px;
  background: var(--faint);
  border-radius: 2px;
  overflow: hidden;
}

.sbf {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 0.1s linear;
}

#rhythm {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

#rhythm.on {
  opacity: 1;
  animation: rhythmPulse 1.8s ease infinite;
}

@keyframes rhythmPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }

  50% {
    transform: scale(1.5);
    opacity: 1;
  }
}

/* ── TRANSITION OVERLAY ────────────────────────────────────── */
#trans {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#trans.out {
  opacity: 1;
  pointer-events: all;
}

/* ── MOBILE HINT ───────────────────────────────────────────── */
#mob-hint {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

/* ── MOBILE ANIMATION DRAWER ──────────────────────────────── */
#mob-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--shadow);
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

#mob-toggle:hover,
#mob-toggle:active {
  transform: scale(1.1);
  border-color: var(--accent);
}

#mob-toggle.open {
  transform: rotate(45deg) scale(1.1);
}

#mob-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#mob-drawer-backdrop.show {
  opacity: 1;
}

#mob-drawer {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 39;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 28px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: none;
}

#mob-drawer::-webkit-scrollbar {
  display: none;
}

#mob-drawer.open {
  transform: translateY(0);
}

#mob-drawer .drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--faint);
  margin: 0 auto 16px;
}

#mob-drawer .drawer-title {
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

#mob-drawer .drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

#mob-drawer .mob-anim-btn {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

#mob-drawer .mob-anim-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

#mob-drawer .mob-anim-btn:active {
  transform: scale(0.96);
}

/* ── TOUCH DEVICES ─────────────────────────────────────────── */
@media (hover: none),
(pointer: coarse) {

  html,
  body {
    cursor: auto;
  }

  #cd,
  #cr,
  #trail {
    display: none !important;
  }

  .anim-btn,
  #theme-btn {
    cursor: pointer;
  }
}

/* ── TABLET ≤ 1024px ───────────────────────────────────────── */
@media (max-width: 1024px) {
  #panel {
    right: 14px;
    gap: 6px;
  }

  .anim-btn {
    padding: 6px 10px;
    font-size: 8px;
  }

  #nav {
    padding: 18px 24px;
  }
}

/* ── MOBILE ≤ 768px ────────────────────────────────────────── */
@media (max-width: 768px) {
  #panel {
    display: none;
  }

  #kbd-hint {
    display: none;
  }

  #mob-hint {
    display: block;
  }

  #mob-toggle {
    display: flex;
  }

  #mob-drawer,
  #mob-drawer-backdrop {
    display: block;
  }

  #nav {
    padding: 16px 20px;
  }

  .nlogo {
    font-size: 11px;
    letter-spacing: 0.24em;
  }

  .nbadge {
    font-size: 8px;
    padding: 5px 12px 5px 10px;
  }

  #ui {
    padding: 70px 24px;
  }

  .brand-logo {
    max-width: 120px;
    margin-bottom: 20px;
  }

  .sub {
    max-width: 300px;
    font-size: 13px;
  }

  .rule {
    margin: 20px auto;
  }

  #bbar {
    padding: 0 20px 16px;
  }

  .bb-right {
    display: none;
  }

  #anim-name {
    font-size: 8px;
  }

  #anim-cat {
    font-size: 7px;
  }
}

/* ── SMALL PHONE ≤ 480px ───────────────────────────────────── */
@media (max-width: 480px) {
  .hl {
    font-size: clamp(42px, 13vw, 64px);
  }

  .hl em {
    -webkit-text-stroke: 1.5px var(--text);
  }

  #ui {
    padding: 60px 16px;
  }

  .brand-logo {
    max-width: 100px;
    margin-bottom: 16px;
  }

  .sub {
    max-width: 260px;
    font-size: 12px;
    line-height: 1.7;
    margin-top: 16px;
  }

  .rule {
    margin: 16px auto;
  }

  #nav {
    padding: 14px 16px;
  }

  .nav-right {
    gap: 8px;
  }

  .nbadge {
    font-size: 7px;
    padding: 4px 10px 4px 8px;
  }

  #theme-btn {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  #bbar {
    padding: 0 16px 12px;
  }

  #mob-hint {
    font-size: 8px;
    bottom: 10px;
  }
}

/* ── VERY SMALL ≤ 360px ────────────────────────────────────── */
@media (max-width: 360px) {
  .hl {
    font-size: clamp(36px, 12vw, 54px);
  }

  .sub {
    font-size: 11px;
    max-width: 240px;
  }
}

/* ── LANDSCAPE MOBILE ──────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  #ui {
    padding: 40px 24px;
  }

  .hw {
    margin-bottom: 0;
  }

  .hl {
    font-size: clamp(32px, 6vh, 56px);
  }

  .brand-logo {
    max-width: 80px;
    margin-bottom: 10px;
  }

  .sub {
    margin-top: 10px;
  }

  .rule {
    margin: 10px auto;
  }

  #nav {
    padding: 10px 20px;
  }
}