#heartline-container {
  position: relative;
  width: min(560px, 92vw);
  height: min(560px, 92vw);
  cursor: pointer;
  max-width: 100%;
}

.heartline-body {
  background: radial-gradient(circle at 25% 25%, rgba(255, 184, 74, 0.06), transparent 40%),
    radial-gradient(circle at 75% 20%, rgba(255, 90, 60, 0.04), transparent 40%),
    #0a0a0a;
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 1.6rem);
  font-family: "Century Gothic", sans-serif;
  color: #ffdb9a;
}

.heartline-stage {
  display: grid;
  justify-items: center;
  width: min(680px, 100%);
  gap: 1rem;
}

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

.ash-branch {
  position: absolute;
  background: linear-gradient(
    to bottom,
    rgba(255, 184, 74, 0.9),
    rgba(255, 184, 74, 0)
  );
  width: 4px;
  height: 0;
  opacity: 0;
  transition: height 0.4s ease-out, opacity 0.3s ease-out;
}

.ash-branch.north { left: 49.6%; top: 50%; transform-origin: bottom; }
.ash-branch.south { left: 49.6%; top: 50%; transform-origin: top; }
.ash-branch.east  { top: 49.6%; left: 50%; transform-origin: left; width: 0; height: 4px; }
.ash-branch.west  { top: 49.6%; left: 50%; transform-origin: right; width: 0; height: 4px; }

.ash-branch.north.grow { height: 34.4%; opacity: 1; }
.ash-branch.south.grow { height: 34.4%; opacity: 1; }
.ash-branch.east.grow  { width: 34.4%; opacity: 1; }
.ash-branch.west.grow  { width: 34.4%; opacity: 1; }

.ash-node {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.55);
  color: #ffdb9a;
  font-family: "Century Gothic", sans-serif;
  border-radius: 6px;
  border: 1px solid #ffb84a;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 0.5s ease, background 0.3s ease, border-color 0.3s ease;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  backdrop-filter: blur(4px);
}

.ash-node:hover {
  background: rgba(255, 184, 74, 0.2);
  border-color: #ffd280;
  color: #fff5e0;
}

.ash-node.reveal {
  opacity: 1;
}

/* Panel popup */
#ash-panel {
  position: fixed;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffb84a;
  padding: 16px 20px;
  border-radius: 10px;
  color: #ffdb9a;
  font-family: "Century Gothic", sans-serif;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 240px;
  box-shadow: 0 0 12px rgba(255, 184, 74, 0.5);
  z-index: 100;
}

#ash-panel.show {
  opacity: 1;
  pointer-events: auto;
}

#ash-panel.hidden {
  display: none;
}

/* Hidden nodes - unlocked via invocation */
.ash-node.hidden-node {
  border-color: #ff5a3c;
  background: rgba(255, 90, 60, 0.15);
  box-shadow: 0 0 8px rgba(255, 90, 60, 0.4);
}

.ash-node.hidden-node:hover {
  background: rgba(255, 90, 60, 0.3);
  border-color: #ff8a6c;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  .heartline-body {
    padding: clamp(0.75rem, 6vw, 1.2rem);
    align-items: start;
  }

  .heartline-stage {
    gap: 0.5rem;
  }

  #heartline-container {
    width: min(520px, 96vw);
    height: min(520px, 96vw);
  }

  .ash-node {
    padding: 5px 10px;
    font-size: 0.95rem;
    max-width: 70vw;
  }

  #ash-panel {
    max-width: min(220px, 80vw);
    padding: 14px 16px;
    font-size: 0.95rem;
  }

  .invoke-box {
    width: min(320px, 92vw);
    padding: 20px;
  }

  .invoke-title {
    font-size: 1.15rem;
  }

  #invoke-input {
    font-size: 1rem;
  }
}

@media (max-width: 400px) {
  #heartline-container {
    width: min(480px, 96vw);
    height: min(480px, 96vw);
  }

  .ash-node {
    padding: 4px 8px;
    font-size: 0.9rem;
    max-width: 80vw;
  }

  #ash-panel {
    max-width: min(200px, 86vw);
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .invoke-box {
    width: 90vw;
    max-width: 260px;
    padding: 16px;
  }
}

@media (max-width: 340px) {
  .invoke-title {
    font-size: 1rem;
  }

  .invoke-box {
    padding: 14px;
  }
}

/* Flicker animation for wrong phrase */
@keyframes ritual-flicker {
  0% { background: rgba(0, 0, 0, 0.85); }
  25% { background: rgba(255, 60, 40, 0.4); }
  50% { background: rgba(0, 0, 0, 0.9); }
  75% { background: rgba(255, 60, 40, 0.3); }
  100% { background: rgba(0, 0, 0, 0.85); }
}

#invoke-overlay.flicker {
  animation: ritual-flicker 0.4s ease;
}

/* Invocation overlay base styles */
#invoke-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 999;
}

#invoke-overlay.invoke-hidden {
  opacity: 0;
  pointer-events: none;
}

#invoke-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.invoke-box {
  background: rgba(0, 0, 0, 0.85);
  padding: 24px;
  border: 1px solid #ffb84a;
  border-radius: 10px;
  width: 320px;
  text-align: center;
  color: #ffdb9a;
  box-shadow: 0 0 15px rgba(255, 184, 74, 0.5);
}

.invoke-title {
  margin: 0 0 16px 0;
  font-size: 1.2rem;
  color: #ffd280;
  font-weight: normal;
}

#invoke-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #ffb84a;
  background: black;
  color: #ffdb9a;
  outline: none;
  box-sizing: border-box;
  font-size: 1rem;
}

#invoke-input::placeholder {
  color: rgba(255, 219, 154, 0.5);
}

.invoke-error {
  color: #ff5a3c;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* Hide error text initially */
.invoke-error.invoke-hidden {
  display: none;
}
