:root {
  --bg-start: #1a0b2e;
  --bg-end: #0d1b3a;
  --card-bg: #2d1b4e;
  --card-border: #d4af37;
  --text-primary: #f4e4bc;
  --text-secondary: #b8a888;
  --accent: #d4af37;
  --button-bg: #4a2c6f;
  --button-hover: #6b3e9e;
}

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

/* Ensure the HTML `hidden` attribute always wins over display rules set by CSS */
[hidden] { display: none !important; }

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

header { text-align: center; margin-bottom: 3rem; }

h1 {
  font-size: 2.5rem;
  font-weight: normal;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-style: italic;
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.question-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 3rem;
}

.question-area label {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-style: italic;
}

#question {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 1rem;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}

#question:focus { outline: none; border-color: var(--accent); }

#question:disabled {
  cursor: not-allowed;
  resize: none;
  background: rgba(74, 44, 111, 0.5);     /* --button-bg at 50% alpha */
  color: var(--text-primary);             /* full-brightness text */
  border-color: rgba(212, 175, 55, 0.5); /* --accent at 50% alpha */
}

.button-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

#draw-button,
#new-reading-btn {
  background: var(--button-bg);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  padding: 0.9rem 2rem;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#draw-button:hover,
#new-reading-btn:hover { background: var(--button-hover); }

#draw-button:active,
#new-reading-btn:active { transform: translateY(1px); }

#draw-button:disabled { opacity: 0.5; cursor: not-allowed; }

#cooldown-msg {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#cooldown-msg.visible { opacity: 1; }

.spread {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 3rem;
}

@media (max-width: 600px) {
  .spread { grid-template-columns: 1fr; }
}

.card-slot {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
  aspect-ratio: 2 / 3;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.card-image {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border-radius: 3px;
}

.card-slot.revealed { animation: reveal 0.6s ease-out; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.position-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-secondary);
}

.card-name {
  font-size: 1.3rem;
  color: var(--accent);
}

.card-keywords {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-secondary);
  min-height: 1.5rem;
}

.reading {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 8px;
  padding: 2rem;
}

.reading h2 {
  color: var(--accent);
  margin-bottom: 1rem;
  font-weight: normal;
  letter-spacing: 0.1em;
}

#reading-text {
  white-space: pre-wrap;
  font-size: 1.05rem;
}

#pdf-row {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
}

#save-pdf-btn {
  background: var(--button-bg);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  padding: 0.9rem 2rem;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#save-pdf-btn:hover { background: var(--button-hover); }
#save-pdf-btn:active { transform: translateY(1px); }
#save-pdf-btn:disabled { opacity: 0.5; cursor: not-allowed; }