:root {
  --c-rojo: #dc2626;
  --c-blanco: #e5e7eb;
  --c-azul: #2563eb;
  --c-amarillo: #ca8a04;
  --c-verde: #16a34a;
  
  --bg-dark: #0a0a0a;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #d97706; /* amber */
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Poppins', sans-serif;
  overflow: hidden; 
  /* We use Three.js canvas full screen, so no scroll */
}

/* UI Overlay */
#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to canvas by default */
  z-index: 10;
  display: flex;
  flex-direction: column;
}

/* Header */
.templo-header {
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: auto;
}

.templo-title h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.templo-title p {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.btn-back {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

/* Canvas Container */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Modal / Panel for Seal */
.seal-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  backdrop-filter: blur(20px);
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  z-index: 20;
}

@keyframes magicalGlow {
  0% { box-shadow: 0 0 30px rgba(217, 119, 6, 0.2); }
  50% { box-shadow: 0 0 60px rgba(217, 119, 6, 0.5); }
  100% { box-shadow: 0 0 30px rgba(217, 119, 6, 0.2); }
}

.seal-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  animation: magicalGlow 3s infinite alternate;
}

.seal-panel::-webkit-scrollbar {
  width: 6px;
}
.seal-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.seal-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.seal-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.2));
}

.seal-info h2 {
  font-size: 1.5rem;
  color: var(--c-rojo); /* dynamic later */
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.seal-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.seal-section {
  margin-bottom: 2rem;
}

.seal-section h3 {
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 0.5rem;
}

.seal-section p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-main);
  font-weight: 300;
}

.input-area {
  width: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 1rem;
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 80px;
  resize: vertical;
  margin-top: 0.5rem;
}

.input-area:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: rgba(17, 24, 39, 0.6);
  color: var(--accent);
  border: 1px solid rgba(255, 215, 0, 0.3);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s;
  width: 100%;
  margin-top: 1rem;
}

.btn-primary:hover {
  background: #f59e0b;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(217, 119, 6, 0.4);
}

.btn-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.3s;
}

.btn-close:hover {
  color: #fff;
}

/* Badge Notification */
.badge-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.9), rgba(180, 83, 9, 0.9));
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 30;
}

.badge-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}

.badge-icon {
  font-size: 1.5rem;
}

.badge-text strong {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.badge-text span {
  font-weight: 600;
}

/* Tooltip / Hint on Canvas */
#canvas-hint {
  position: absolute;
  bottom: 6rem;
  width: 100%;
  text-align: center;
  pointer-events: none;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Castle Menu */
.castle-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 90%;
  max-width: 600px;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  padding: 2rem;
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  backdrop-filter: blur(20px);
  pointer-events: auto;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 15;
}

.castle-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  animation: magicalGlow 3s infinite alternate;
}

.btn-close-text {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  transition: color 0.3s;
}

.btn-close-text:hover {
  color: #fff;
}

.castle-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

.castle-desc {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 2rem;
}

.castle-seals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.seal-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.seal-card:hover {
  background: rgba(255,255,255,0.15);
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 15px rgba(217,119,6,0.3);
  border-color: rgba(217,119,6,0.5);
}

.seal-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.seal-card.locked:hover {
  transform: none;
  background: rgba(255,255,255,0.05);
}

.seal-card-img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 5px rgba(255,255,255,0.2));
}

.seal-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.seal-card-status {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

/* Wavespells Styles */
.wavespells-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.wavespell-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.4s ease;
}

.wavespell-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
  border-left: 4px solid var(--accent);
  box-shadow: -5px 0 15px rgba(217,119,6,0.2);
}

.wavespell-title {
  font-size: 1.1rem;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.wavespell-purpose {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.wavespell-details {
  display: none;
  margin-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
}

.wavespell-card.expanded .wavespell-details {
  display: block;
}

.wavespell-img {
  width: 100%;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.tones-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

.tone-icon {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  cursor: pointer;
  transition: transform 0.2s;
}

.tone-icon:hover {
  transform: scale(1.1);
}

/* 52-Kin Castle Geometry Map */
.castle-geometry-container {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 0;
  overflow: auto; /* Allow scrolling on small screens */
}

.castle-geometry-grid {
  display: grid;
  grid-template-columns: repeat(9, 40px);
  grid-template-rows: repeat(9, 40px);
  gap: 2px; /* Small gap to form the continuous path but keep separation */
  position: relative;
}

.geometry-cell {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  position: relative;
}

.geometry-cell img {
  width: 75%;
  height: 75%;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(255,255,255,0.4));
}

.geometry-cell:hover {
  transform: scale(1.2);
  z-index: 10;
  box-shadow: 0 5px 15px rgba(0,0,0,0.8), 0 0 10px rgba(255,255,255,0.5);
}

.geometry-cell.color-rojo { background: var(--c-rojo); border: 1px solid rgba(255,255,255,0.2); }
.geometry-cell.color-blanco { background: var(--c-blanco); border: 1px solid rgba(255,255,255,0.4); }
.geometry-cell.color-azul { background: var(--c-azul); border: 1px solid rgba(255,255,255,0.2); }
.geometry-cell.color-amarillo { background: var(--c-amarillo); border: 1px solid rgba(255,255,255,0.2); }

/* Center Hub (Sun/Heart of Castle) */
.geometry-center {
  grid-column: 5;
  grid-row: 5;
  background: radial-gradient(circle, #fcd34d 0%, #d97706 100%);
  border-radius: 50%;
  width: 100%;
  height: 100%;
  box-shadow: 0 0 20px rgba(217,119,6,0.6);
  animation: magicalGlow 3s infinite alternate;
}

/* Hover Energy Card */
.energy-card {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 350px;
    background: rgba(17, 24, 39, 0.70);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    color: #fff;
    z-index: 20;
    pointer-events: none; /* Let clicks pass through */
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.energy-card.hidden {
    opacity: 0;
    transform: translateY(-50%) translateX(20px);
}

.ec-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
}

.ec-kin {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.ec-castle {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9ca3af;
}

.ec-wavespell-section h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
}

.ec-purpose {
    margin: 0;
    font-size: 0.9rem;
    color: #cbd5e1;
    font-style: italic;
}

.ec-seal-tone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    background: rgba(0,0,0,0.3);
    padding: 1rem;
    border-radius: 12px;
}

.ec-icon-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ec-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.ec-name {
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}

/* Destiny Card specific layout */
.dc-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.dc-icon-box {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 1.2rem;
    padding: 1rem 1.25rem;
}

.glass-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: inset 0 0 10px rgba(255,255,255,0.02), 0 4px 15px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
}

.glass-box:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(217, 119, 6, 0.5);
    box-shadow: inset 0 0 10px rgba(255,255,255,0.05), 0 8px 25px rgba(0,0,0,0.4), 0 0 15px rgba(217,119,6,0.3);
    transform: translateY(-2px);
}

.ec-icon-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.ec-icon-text .ec-name {
    text-align: left;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: #fff;
    margin-bottom: 0.2rem;
}

.ec-subtext {
    font-size: 0.85rem;
    color: #cbd5e1;
    line-height: 1.4;
}

.ec-energy-section h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 1px;
}

.ec-energy-section p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #e2e8f0;
}

@media (max-width: 768px) {
    .energy-card {
        right: 10px;
        left: 10px;
        top: auto;
        bottom: 20px;
        transform: none;
        width: auto;
    }
    
    .energy-card.hidden {
        transform: translateY(20px);
    }
    
    #destiny-card {
        right: 50% !important;
        transform: translate(50%, -50%) !important;
        width: 90% !important;
    }
}

/* ── Camera Mode Controls ─────────────────────────────── */
#camera-controls {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 50;
  pointer-events: auto; /* Allow clicks through the ui-layer */
}

.btn-cam {
  background: rgba(10, 10, 20, 0.6);
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: rgba(255, 215, 0, 0.85);
  font-family: 'Georgia', serif;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.25s, border-color 0.25s, color 0.25s, box-shadow 0.25s;
}

.btn-cam:hover {
  background: rgba(20, 20, 40, 0.9);
  border-color: rgba(255, 215, 0, 0.7);
  color: #FFD700;
}

.btn-cam.active {
  background: rgba(255, 180, 0, 0.18);
  border-color: #FFD700;
  color: #FFD700;
  box-shadow: 0 0 12px rgba(255, 200, 0, 0.4);
}
