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

:root {
  --bg: #0d0b0a;
  --bg2: #1a1612;
  --parchment: #2a2118;
  --parchment-light: #3a3020;
  --gold: #c9a84c;
  --gold-dim: #8a7030;
  --ember: #e85d26;
  --ember-glow: #ff6b35;
  --text: #d4c5a9;
  --text-dim: #8a7d6b;
  --rune-color: #e8d5a3;
  --border: #3d3225;
  --shadow: rgba(0,0,0,0.6);
}

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: 'Cinzel', serif;
  background: var(--bg);
  color: var(--text);
}

#bgParticles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  margin: 20px 0 10px;
}

.title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 4em;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(201,168,76,0.4), 0 0 60px rgba(201,168,76,0.2);
  letter-spacing: 0.15em;
  animation: titleGlow 4s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0% { text-shadow: 0 0 20px rgba(201,168,76,0.3), 0 0 40px rgba(201,168,76,0.1); }
  100% { text-shadow: 0 0 40px rgba(201,168,76,0.6), 0 0 80px rgba(201,168,76,0.3), 0 4px 8px rgba(0,0,0,0.5); }
}

.subtitle {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1em;
  color: var(--text-dim);
  margin-top: 8px;
  letter-spacing: 0.1em;
}

/* Mode bar */
#modeBar {
  display: flex;
  gap: 8px;
  margin: 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-btn {
  font-family: 'Cinzel', serif;
  background: var(--parchment);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 0.85em;
}

.mode-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.mode-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201,168,76,0.1);
  box-shadow: 0 0 15px rgba(201,168,76,0.15);
}

/* Canvas area */
#drawArea, #nornDrawArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 500px;
}

#canvasFrame, #nornCanvasFrame {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1e1a14 0%, #141110 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5), 0 0 30px rgba(0,0,0,0.4);
}

/* Stone texture overlay */
#canvasFrame::before, #nornCanvasFrame::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

#drawCanvas, #nornCanvas {
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#canvasHint, #nornHint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  font-size: 1.2em;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.3s;
  z-index: 2;
  text-align: center;
}

#canvasHint.hidden, #nornHint.hidden { opacity: 0; }

/* Controls */
#drawControls, #nornControls {
  display: flex;
  gap: 12px;
}

.ctrl-btn {
  font-family: 'Cinzel', serif;
  background: var(--parchment);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  transition: all 0.3s;
}

.ctrl-btn:hover {
  border-color: var(--gold-dim);
  background: var(--parchment-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, #2a2010, #3a2a15);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,0.15);
}

.ctrl-btn.primary:hover {
  background: linear-gradient(135deg, #3a2a15, #4a3a20);
  box-shadow: 0 0 30px rgba(201,168,76,0.25);
}

.share-btn {
  background: linear-gradient(135deg, #1a2a1a, #2a3a20);
  border-color: #4a7a4a;
  color: #8aba8a;
}

/* Result area */
#resultArea {
  width: 100%;
  max-width: 600px;
  text-align: center;
  position: relative;
  padding: 20px 0;
}

#resultParticles {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

#resultContent {
  position: relative;
  z-index: 1;
  background: linear-gradient(135deg, rgba(42,33,24,0.9), rgba(26,22,18,0.95));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: 0 0 40px rgba(0,0,0,0.4), inset 0 0 30px rgba(201,168,76,0.05);
}

#resultRune {
  font-size: 5em;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(201,168,76,0.5);
  margin-bottom: 10px;
  animation: runeReveal 1s ease-out;
}

@keyframes runeReveal {
  0% { transform: scale(0.3); opacity: 0; filter: blur(10px); }
  50% { transform: scale(1.2); filter: blur(0); }
  100% { transform: scale(1); opacity: 1; }
}

#resultName {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.8em;
  color: var(--gold);
  margin-bottom: 5px;
}

#resultMeaning {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.1em;
  color: var(--text-dim);
  margin-bottom: 20px;
}

#resultLore {
  font-family: 'MedievalSharp', cursive;
  font-size: 0.95em;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 20px;
  padding: 15px;
  border-left: 3px solid var(--gold-dim);
  background: rgba(201,168,76,0.05);
  border-radius: 0 8px 8px 0;
  text-align: left;
  font-style: italic;
}

#resultProphecy {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.05em;
  color: var(--ember-glow);
  line-height: 1.7;
  padding: 15px;
  border: 1px solid rgba(232,93,38,0.2);
  border-radius: 8px;
  background: rgba(232,93,38,0.05);
  text-align: left;
}

#resultActions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
  position: relative;
  z-index: 1;
}

/* Norn area */
#nornArea {
  width: 100%;
  max-width: 700px;
  text-align: center;
}

.norn-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.4em;
  color: var(--gold);
  margin-bottom: 4px;
}

.norn-subtitle {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  margin-bottom: 20px;
}

#nornSlots {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.norn-slot {
  background: var(--parchment);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  min-width: 140px;
  transition: all 0.5s;
}

.norn-slot.active {
  border-color: var(--gold);
  box-shadow: 0 0 25px rgba(201,168,76,0.2);
}

.norn-slot.filled {
  border-color: var(--ember);
  background: linear-gradient(135deg, rgba(232,93,38,0.1), var(--parchment));
}

.norn-label {
  font-family: 'Cinzel Decorative', serif;
  color: var(--gold-dim);
  font-size: 0.85em;
  margin-bottom: 8px;
}

.norn-rune {
  font-size: 2.5em;
  color: var(--rune-color);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.norn-time {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  font-size: 0.8em;
  margin-top: 8px;
}

#nornDrawArea {
  margin: 0 auto;
}

#nornResult {
  margin-top: 24px;
  background: linear-gradient(135deg, rgba(42,33,24,0.9), rgba(26,22,18,0.95));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
  text-align: left;
}

.norn-reading {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.norn-reading:last-child { border-bottom: none; }

.norn-reading-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.norn-reading-rune {
  font-size: 2em;
  color: var(--gold);
}

.norn-reading-info h3 {
  font-family: 'Cinzel Decorative', serif;
  color: var(--gold);
  font-size: 1.1em;
}

.norn-reading-info span {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  font-size: 0.85em;
}

.norn-reading p {
  font-family: 'MedievalSharp', cursive;
  line-height: 1.6;
  color: var(--text);
}

.norn-reading .prophecy-text {
  color: var(--ember-glow);
  margin-top: 8px;
  padding: 10px;
  background: rgba(232,93,38,0.05);
  border-radius: 6px;
  border-left: 3px solid var(--ember);
}

/* Collection */
#collectionArea {
  width: 100%;
  max-width: 800px;
  text-align: center;
}

.collection-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 1.5em;
  color: var(--gold);
  margin-bottom: 4px;
}

.collection-subtitle {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  margin-bottom: 24px;
}

#collectionGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.collection-item {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  transition: all 0.3s;
}

.collection-item:hover {
  border-color: var(--gold-dim);
  transform: translateY(-3px);
}

.collection-item.locked {
  opacity: 0.3;
  filter: grayscale(1);
}

.collection-item .rune-char {
  font-size: 2.2em;
  color: var(--gold);
  display: block;
  margin-bottom: 6px;
}

.collection-item .rune-name {
  font-size: 0.75em;
  color: var(--text-dim);
}

.collection-item.locked .rune-char { color: var(--text-dim); }

#collectionEmpty {
  font-family: 'MedievalSharp', cursive;
  color: var(--text-dim);
  padding: 40px;
}

/* Vegvisir easter egg */
#vegvisirResult {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
}

.vegvisir-symbol {
  font-size: 8em;
  color: var(--gold);
  text-shadow: 0 0 50px rgba(201,168,76,0.6);
  animation: vegvisirSpin 20s linear infinite;
  margin-bottom: 20px;
}

@keyframes vegvisirSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.vegvisir-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 2em;
  color: var(--gold);
  margin-bottom: 20px;
}

.vegvisir-text {
  font-family: 'MedievalSharp', cursive;
  font-size: 1.2em;
  color: var(--ember-glow);
  max-width: 500px;
  line-height: 1.8;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid rgba(232,93,38,0.3);
  border-radius: 12px;
  background: rgba(232,93,38,0.05);
}

.vegvisir-lore {
  font-family: 'MedievalSharp', cursive;
  color: var(--text);
  max-width: 500px;
  line-height: 1.7;
  margin-bottom: 30px;
}

/* Utilities */
.hidden { display: none !important; }

/* Footer */
footer {
  margin-top: auto;
  padding: 30px 0 10px;
  color: var(--text-dim);
  font-size: 0.8em;
}

footer a {
  color: var(--gold-dim);
  text-decoration: none;
}

footer a:hover { color: var(--gold); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.5s ease-out; }

/* Responsive */
@media (max-width: 600px) {
  .title { font-size: 2.8em; }
  #canvasFrame, #nornCanvasFrame { max-width: 320px; }
  .norn-slot { min-width: 100px; padding: 12px; }
  .norn-rune { font-size: 2em; min-height: 45px; }
  #resultContent { padding: 25px 18px; }
  #resultRune { font-size: 3.5em; }
  .mode-btn { padding: 8px 14px; font-size: 0.8em; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
