@font-face {
  font-family: 'GodSerif';
  src: local('Georgia'), local('Times New Roman');
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'GodSerif', Georgia, 'Times New Roman', serif;
  background: #0a0e18;
  touch-action: none;
}

#scene {
  position: fixed; inset: 0; display: block; width: 100%; height: 100%;
}

.hidden { display: none !important; }

/* ---------- Pergament-Look ---------- */

.parchment-panel {
  background:
    radial-gradient(ellipse at 20% 20%, rgba(255,255,255,0.15), transparent 60%),
    linear-gradient(160deg, #e9d9ae 0%, #dcc48c 45%, #cbaf72 100%);
  border: 2px solid #7a5a2e;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45), inset 0 0 30px rgba(120,80,20,0.25);
  color: #3a2a12;
  padding: 12px 16px;
}

.parch-button {
  font-family: inherit;
  background: linear-gradient(180deg, #f0dfae, #cfa85e);
  border: 2px solid #7a5a2e;
  border-radius: 8px;
  color: #3a2410;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: 0 3px 0 #6b4d24, 0 4px 8px rgba(0,0,0,0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.parch-button:hover { filter: brightness(1.06); }
.parch-button:active { transform: translateY(2px); box-shadow: 0 1px 0 #6b4d24, 0 2px 4px rgba(0,0,0,0.3); }
.parch-button.small { padding: 6px 10px; font-size: 12px; }
.parch-button.big { font-size: 18px; padding: 14px 30px; }
.parch-button.active { background: linear-gradient(180deg, #ffe9a8, #e0a83f); box-shadow: 0 0 0 2px #ffdf7a, 0 3px 0 #6b4d24; }

.parch-input {
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 2px solid #7a5a2e;
  background: #fbf2d8;
  color: #3a2410;
  font-size: 14px;
  margin: 10px 0;
  width: 220px;
}

/* ---------- Overlays ---------- */

.parchment-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(20,14,4,0.55), rgba(5,4,2,0.88));
  z-index: 50;
}

.start-panel { max-width: 520px; text-align: center; }
.start-panel h1 {
  font-size: 42px; letter-spacing: 4px; margin: 0 0 6px;
  color: #4a3110; text-shadow: 0 2px 0 rgba(255,255,255,0.3);
}
.start-panel .subtitle { font-style: italic; margin-bottom: 20px; }
.start-panel .hint { font-size: 12px; opacity: 0.8; margin-top: 18px; line-height: 1.6; }

#end-panel .parchment-panel, #highscore-panel .parchment-panel { min-width: 320px; max-width: 90vw; text-align: center; }

/* ---------- HUD oben ---------- */

#hud-top {
  position: fixed; top: 10px; left: 10px; right: 10px;
  display: flex; align-items: flex-start; gap: 8px; z-index: 20;
  pointer-events: none;
}
#hud-top .parch-button { pointer-events: auto; }

.stat-panel {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; flex: 1;
  padding: 8px 14px;
  pointer-events: auto;
}
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 70px; }
.stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }
.stat .value { font-size: 18px; font-weight: 700; }

.bar {
  width: 100px; height: 12px; border-radius: 6px; overflow: hidden;
  background: rgba(60,40,10,0.35);
  border: 1px solid rgba(60,40,10,0.5);
}
.bar.small { width: 90px; height: 9px; }
.bar-fill { height: 100%; width: 50%; transition: width 0.3s ease; }
.bar-fill.balance { background: linear-gradient(90deg, #5aa03a, #8fd45a); }
.bar-fill.faith { background: linear-gradient(90deg, #b9862f, #ffd35f); }
.bar-fill.power { background: linear-gradient(90deg, #3a6bb0, #6fb8ff); }
.bar-fill.food { background: linear-gradient(90deg, #b0782f, #f2b95f); }
.bar-fill.energy { background: linear-gradient(90deg, #3a8f6b, #6fe0b0); }
.bar-fill.mood { background: linear-gradient(90deg, #b04f8f, #ff8fd4); }
.bar-fill.alignment { background: linear-gradient(90deg, #b03a3a, #cccccc 50%, #4a9ce0); }

/* ---------- Ereignisprotokoll ---------- */

#event-log {
  position: fixed; top: 74px; left: 10px; width: 260px;
  max-height: 150px; overflow: hidden; font-size: 12px; z-index: 15;
  pointer-events: none;
  padding: 8px 12px;
}
#event-log div { margin-bottom: 4px; opacity: 0.9; }

/* ---------- Dorf & Kreatur Panels ---------- */

#village-panel {
  position: fixed; top: 74px; right: 10px; width: 210px; z-index: 22;
}
#village-panel h3 { margin: 0 0 8px; font-size: 16px; }
.stat-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; align-items: center; }
#village-panel .parch-button { margin-top: 8px; width: 100%; }

#creature-panel {
  position: fixed; bottom: 96px; left: 10px; width: 210px; z-index: 22;
}
#creature-panel h3 { margin: 0 0 8px; font-size: 15px; }
.creature-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.creature-actions .parch-button { flex: 1; font-size: 11px; padding: 6px 4px; }

/* ---------- Wunder-Leiste ---------- */

#miracle-bar {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 25;
  background: linear-gradient(160deg, #e9d9ae, #cbaf72);
  border: 2px solid #7a5a2e;
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.miracle-btn {
  width: 56px; height: 56px;
  border-radius: 8px;
  border: 2px solid #7a5a2e;
  background: linear-gradient(180deg, #f0dfae, #cfa85e);
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  cursor: pointer;
}
.miracle-btn.active { background: linear-gradient(180deg, #ffe9a8, #e0a83f); box-shadow: 0 0 0 2px #ffdf7a inset; }
.miracle-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.miracle-btn .cost {
  position: absolute; bottom: 1px; right: 3px; font-size: 9px; font-weight: 700; color: #3a2410;
}
.miracle-btn .name {
  position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  font-size: 10px; white-space: nowrap; color: #ffe9a8; text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
.miracle-btn:hover .name { opacity: 1; }

#hand-actions {
  position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 24;
}
.hand-btn { font-size: 11px; padding: 6px 10px; }

/* ---------- Ladehinweis ---------- */

#loading-hint {
  position: fixed; bottom: 10px; right: 10px; font-size: 12px; z-index: 10;
  pointer-events: none;
}

/* ---------- Mobile Anpassungen ---------- */

@media (max-width: 720px) {
  .stat-panel { gap: 8px; }
  .stat { min-width: 56px; }
  .bar { width: 60px; }
  #village-panel, #creature-panel { width: 150px; font-size: 11px; }
  .miracle-btn { width: 46px; height: 46px; font-size: 18px; }
  .start-panel { padding: 20px; }
  .start-panel h1 { font-size: 30px; }
}
