:root {
  --bg-deep: #05070f;
  --bg-mid: #0d1730;
  --ink: #f2ecd9;
  --ink-dim: #b9b3a0;
  --gold: #c9a227;
  --gold-dim: #8a7228;
  --verdigris: #4f7266;
  --stone: #14192a;
  --stone-line: rgba(201, 162, 39, 0.35);
  --canvas-white: #faf7ee;
  --alert: #b5482f;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1px 1px at 10% 20%, rgba(242,236,217,0.5) 0, transparent 60%),
    radial-gradient(1px 1px at 80% 15%, rgba(242,236,217,0.4) 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 60% 70%, rgba(242,236,217,0.3) 0, transparent 60%),
    radial-gradient(1px 1px at 30% 85%, rgba(242,236,217,0.35) 0, transparent 60%),
    radial-gradient(1px 1px at 92% 60%, rgba(242,236,217,0.3) 0, transparent 60%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 60%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 40px);
}

.title-block {
  text-align: center;
  margin-bottom: clamp(18px, 3vh, 32px);
}

.title-block .kicker {
  font-family: "Cinzel", serif;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin: 0 0 6px;
}

.title-block h1 {
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}

.title-block p {
  margin: 0;
  color: var(--ink-dim);
  font-size: clamp(1rem, 2vw, 1.15rem);
  max-width: 34ch;
  margin: 0 auto;
}

.stage {
  position: relative;
  width: min(92vw, 440px);
}

.view { display: flex; flex-direction: column; align-items: center; }
.hidden { display: none !important; }

#canvas-holder {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--canvas-white);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px var(--stone-line),
    0 0 0 8px var(--stone),
    0 0 0 9px var(--stone-line),
    0 20px 50px rgba(0,0,0,0.55);
}

#canvas-holder canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 2px;
  touch-action: none;
  cursor: crosshair;
}

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
#canvas-holder.shake { animation: shake 0.4s; }

.controls {
  display: flex;
  gap: 14px;
  margin-top: 20px;
  width: 100%;
  justify-content: center;
}

button {
  font-family: "Cinzel", serif;
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  padding: 12px 26px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stone-line);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--bg-deep);
  background: var(--gold);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

#btn-summon {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.status-line {
  margin-top: 16px;
  min-height: 1.4em;
  text-align: center;
  color: var(--ink-dim);
  font-style: italic;
  font-size: 1rem;
}

/* --- God card reveal --------------------------------------------------- */

@keyframes card-in {
  from { opacity: 0; transform: scale(0.9) rotateY(8deg); }
  to   { opacity: 1; transform: scale(1) rotateY(0deg); }
}

#card {
  width: 100%;
  perspective: 800px;
}

.card-frame {
  width: 100%;
  aspect-ratio: 1 / 1.35;
  background: linear-gradient(160deg, #11162a 0%, #0a0e1c 100%);
  border: 1px solid var(--gold-dim);
  outline: 1px solid rgba(201,162,39,0.2);
  outline-offset: 6px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: card-in 0.5s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .card-frame { animation: none; }
}

.card-glyph { font-size: clamp(3rem, 12vw, 4.2rem); line-height: 1; }

.card-tagline {
  font-family: "Cinzel", serif;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  color: var(--verdigris);
  margin-top: 10px;
}

.card-name {
  font-family: "Cinzel", serif;
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  color: var(--gold);
  margin: 6px 0 14px;
}

.card-power {
  font-size: clamp(1.02rem, 2.6vw, 1.2rem);
  line-height: 1.5;
  color: var(--ink);
  max-width: 32ch;
  margin: 0;
}

.card-homebrew {
  margin-top: 14px;
  font-family: "Cinzel", serif;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  border: 1px solid var(--stone-line);
  padding: 3px 10px;
}

.card-guess {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--ink-dim);
  font-style: italic;
}

.card-frame.mortal {
  border-color: var(--ink-dim);
  outline-color: rgba(185,179,160,0.15);
}
.card-frame.mortal .card-name,
.card-frame.mortal .card-tagline { color: var(--ink-dim); }

/* --- Loading overlay ----------------------------------------------------*/

#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 50;
  transition: opacity 0.4s ease;
}

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

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--stone-line);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-overlay p {
  font-family: "Cinzel", serif;
  letter-spacing: 0.18em;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

footer {
  margin-top: 28px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.78rem;
  max-width: 40ch;
  opacity: 0.7;
}
