* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html {
  background: #0d1410;
}

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(143, 185, 106, 0.16), transparent 65%),
    linear-gradient(180deg, #0d1410 0%, #14201a 45%, #0d1410 100%);
  /* Kein "fixed" hier: auf mobilen Browsern (v.a. iOS/Android Chrome) rendert ein
     fixierter Hintergrund auf langen Seiten unzuverlässig und kann unterhalb der
     ersten Bildschirmhöhe verschwinden. Mit dem normalen Scroll-Verhalten deckt
     der Verlauf zuverlässig die komplette Seitenhöhe ab. */
  color: #e8dcc8;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg { max-width: 100%; }

a { color: #d4af37; }

/* ----- Kopfleiste ----- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(20, 15, 10, 0.85);
  padding: 10px 20px;
  border-bottom: 2px solid #d4af37;
  flex-wrap: wrap;
  gap: 10px;
}

.logo {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 1.5em;
  letter-spacing: 0.5px;
  color: #e8c860;
  text-shadow: 0 1px 0 #1b1410, 0 0 16px rgba(212, 175, 55, 0.35);
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-emblem { width: 20px; height: 20px; flex-shrink: 0; }
.logo-emblem svg { width: 100%; height: 100%; display: block; }

.userbar { display: flex; gap: 15px; font-size: 0.9em; flex-wrap: wrap; align-items: center; }

/* ----- Drei-Spalten-Grundgerüst (Menü / Inhalt / Vital-Info) ----- */

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
  flex-wrap: wrap;
  gap: 18px;
  padding: 18px;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.panel {
  background: rgba(20, 15, 10, 0.68);
  border: 1px solid #3a2a1a;
  border-top: 2px solid #8fb96a;
  border-radius: 8px;
}

.sidebar {
  background: rgba(20, 15, 10, 0.68);
  border: 1px solid #3a2a1a;
  border-top: 2px solid #8fb96a;
  border-radius: 8px;
  width: 210px;
  padding: 6px 12px 14px;
  flex-shrink: 0;
}

.sidebar .sec {
  color: #d4af37;
  text-align: center;
  font-weight: bold;
  font-size: 0.85em;
  letter-spacing: 0.3px;
  margin: 14px 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #5a4530;
}
.sidebar .sec:first-child { margin-top: 4px; }

.sidebar a,
.sidebar button.sidebar-action {
  display: block;
  width: 100%;
  color: #e8dcc8;
  text-decoration: none;
  padding: 5px 4px;
  font-size: 0.92em;
  border-radius: 4px;
  text-align: left;
}
.sidebar a:hover,
.sidebar button.sidebar-action:hover { background: rgba(58, 42, 26, 0.85); }
.sidebar a.hint { color: #ffd76a; }

/* Formulare für Orts-Aktionen (z.B. "Kämpfen" im Dämmerforst) sollen im
   Menü aussehen wie ein normaler Menüpunkt statt wie ein Formular/Button. */
.sidebar form { margin: 0; }
.sidebar button.sidebar-action {
  background: none;
  border: none;
  font-family: inherit;
  font-weight: normal;
  font-size: 0.92em;
  cursor: pointer;
  margin-top: 0;
}

.content {
  background: rgba(20, 15, 10, 0.62);
  border: 1px solid #3a2a1a;
  border-top: 2px solid #8fb96a;
  border-radius: 10px;
  padding: 24px;
  flex: 1 1 0;
  min-width: 280px;
}
.content.centered { text-align: center; }

/* Für Seiten mit einem Element, das die restliche Höhe ausfüllen soll (z.B.
   der Chat auf village.php) - das jeweilige Kind bekommt dafür "flex-fill". */
.content.content-fill {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 96px);
}
.content.content-fill .flex-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ----- Rechte Spalte: Vital-Info ----- */

.statbar {
  background: rgba(20, 15, 10, 0.68);
  border: 1px solid #3a2a1a;
  border-top: 2px solid #8fb96a;
  border-radius: 8px;
  width: 220px;
  padding: 6px 14px 14px;
  flex-shrink: 0;
  font-size: 0.9em;
}

.statbar .rlabel {
  color: #d4af37;
  font-weight: bold;
  margin: 14px 0 5px;
  padding-bottom: 3px;
  border-bottom: 1px solid #5a4530;
}
.statbar .rlabel:first-child { margin-top: 4px; }

.kv { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.kv .k { color: #a89578; }
.kv .v { color: #e8dcc8; text-align: right; font-variant-numeric: tabular-nums; }

.meter { height: 7px; background: rgba(0, 0, 0, 0.4); border: 1px solid #3a2a1a; border-radius: 3px; margin: 2px 0 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(#8fe06a, #4f9e3a); }
.meter.exp i { background: linear-gradient(#ffe08a, #d4af37); }

.statbar .hint-box {
  margin: 8px 0;
  padding: 6px 8px;
  background: rgba(58, 42, 10, 0.5);
  border-left: 3px solid #d4af37;
  border-radius: 4px;
  font-size: 0.95em;
}
.statbar .hint-box a { color: #ffd76a; font-weight: bold; }

/* ----- Allgemeine Elemente ----- */

h1 { color: #d4af37; border-bottom: 1px solid #5a4530; padding-bottom: 8px; }
h2 { color: #d4af37; margin-top: 30px; }

.error { color: #ff6b6b; font-weight: bold; }
.notice { color: #8fd694; font-weight: bold; }

form label { display: block; margin: 8px 0; }

input, select, button, textarea {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #5a4530;
  background: rgba(43, 30, 20, 0.7);
  color: #e8dcc8;
  font-family: inherit;
}

button {
  cursor: pointer;
  background: #d4af37;
  color: #1b1410;
  font-weight: bold;
  border: none;
  margin-top: 6px;
}
button:hover { background: #e8c860; }

.menu-list { list-style: none; padding: 0; }
.menu-list li { margin: 10px 0; }
.menu-list a {
  display: block;
  padding: 12px 16px;
  background: rgba(43, 30, 20, 0.65);
  border-radius: 6px;
  text-decoration: none;
  color: #e8dcc8;
  border-left: 4px solid #d4af37;
}
.menu-list a:hover { background: rgba(58, 42, 26, 0.85); }

/* ----- Automatischer Kampf: Ergebnis-Panel im Seiteninhalt ----- */

.auto-fight-result { margin: 16px 0; padding: 14px 18px; }
.auto-fight-result h2 { margin-top: 0; font-size: 1.05em; }
.auto-fight-log { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.auto-fight-log .battle-log { margin: 0 0 4px; }

/* ----- Chat (Normal / RP) ----- */

.chat-box {
  margin-top: 20px;
  border: 1px solid #3a2a1a;
  border-top: 2px solid #8fb96a;
  border-radius: 8px;
  background: rgba(15, 12, 8, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-announcements { border-bottom: 1px solid #3a2a1a; }
.chat-announcement {
  margin: 0;
  padding: 8px 14px;
  background: rgba(58, 42, 10, 0.55);
  border-left: 3px solid #d4af37;
  color: #ffd76a;
  font-weight: bold;
  font-size: 0.92em;
}
.chat-announcement + .chat-announcement { border-top: 1px dashed rgba(212, 175, 55, 0.3); }

.chat-tabs { display: flex; border-bottom: 1px solid #3a2a1a; }
.chat-tabs a {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  text-decoration: none;
  color: #a89578;
  font-weight: bold;
  border-bottom: 2px solid transparent;
}
.chat-tabs a:hover { color: #e8dcc8; }
.chat-tabs a.active { color: #d4af37; border-bottom-color: #d4af37; background: rgba(43, 30, 20, 0.5); }

.chat-hint {
  margin: 0;
  padding: 8px 14px;
  font-size: 0.85em;
  color: #8a7a62;
  font-style: italic;
  border-bottom: 1px solid #2a1e14;
}

.chat-messages {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  padding: 10px 14px;
}
.chat-message { margin: 0 0 8px; line-height: 1.5; }
.chat-message:last-child { margin-bottom: 0; }
.chat-author { color: #d4af37; font-weight: bold; margin-right: 4px; }
.chat-time { float: right; color: #6e5f49; font-size: 0.8em; margin-left: 10px; }

.chat-log-btn {
  flex: 0 0 auto;
  align-self: center;
  margin: 0 10px 0 auto;
  padding: 6px 10px;
  font-size: 0.82em;
  font-weight: normal;
  background: rgba(58, 42, 26, 0.85);
  color: #e8dcc8;
  border: 1px solid #5a4530;
}
.chat-log-btn:hover { background: #5a4530; }

.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #3a2a1a;
  flex-shrink: 0;
  /* Sitzt am unteren Rand der Chat-Box wie ein eigener Fußbereich. */
  background: rgba(20, 15, 10, 0.5);
}

.content.content-fill .chat-box {
  max-height: none;
}
.content.content-fill .chat-messages {
  max-height: none;
}

.chat-color-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82em;
  color: #a89578;
}
.chat-color-row label { display: flex; align-items: center; gap: 5px; margin: 0; }
.chat-color-row input[type="color"] {
  width: 32px;
  height: 26px;
  padding: 2px;
  cursor: pointer;
}
.chat-color-row input[type="checkbox"] { cursor: pointer; }

.chat-input-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1;
  resize: vertical;
  min-height: 38px;
  font-family: inherit;
}
.chat-input-row button { margin-top: 0; }

.battle-bars { display: flex; gap: 30px; margin: 20px 0; flex-wrap: wrap; }
.hp-bar { width: 220px; max-width: 100%; height: 18px; background: #3a2a1a; border-radius: 9px; overflow: hidden; margin: 6px 0; }
.hp-fill { height: 100%; background: #8fd694; }
.hp-fill.enemy { background: #ff6b6b; }
.battle-log { background: rgba(36, 26, 18, 0.7); padding: 8px 12px; border-left: 3px solid #d4af37; margin: 6px 0; }

.item-table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.item-table th, .item-table td { border: 1px solid #5a4530; padding: 8px; text-align: left; }

.stat-table td { padding: 6px 12px; border-bottom: 1px solid #3a2a1a; }

.talent-badge a {
  background: #5a3d0a;
  color: #ffd97a;
  padding: 4px 10px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: bold;
}
.talent-badge a:hover { background: #6f4b0d; }

.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 14px 0;
}
.class-card {
  display: block;
  background: rgba(36, 26, 18, 0.7);
  border: 2px solid #3a2a1a;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
}
.class-card:hover { border-color: #5a4530; }
.class-card.selected,
.class-card:has(input:checked) { border-color: #d4af37; }
.class-card input[type="radio"] { margin-bottom: 8px; }
.class-card p { margin: 6px 0 0; font-size: 0.9em; color: #cdbfa5; }
.class-stats { color: #d4af37 !important; }

.gender-choice { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 10px 0 20px; }
.gender-choice label { display: flex; align-items: center; gap: 6px; margin: 0; }

.pagefooter {
  text-align: center;
  padding: 14px;
  font-size: 0.8em;
  color: #7a6a52;
  border-top: 1px solid #3a2a1a;
}

/* ----- Startseite ----- */

.landing-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 620px) 240px;
  gap: 20px;
  align-items: start;
  width: 100%;
}

.landing-nav { display: flex; flex-direction: column; gap: 18px; }
.landing-nav-section h3 {
  color: #d4af37;
  font-size: 0.85em;
  letter-spacing: 0.3px;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #5a4530;
}
.landing-nav-section a {
  display: block;
  color: #e8dcc8;
  text-decoration: none;
  padding: 4px 2px;
  font-size: 0.92em;
}
.landing-nav-section a:hover { color: #ffd76a; }

.landing-main { text-align: center; }

.landing-side {
  background: rgba(20, 15, 10, 0.5);
  border: 1px solid #3a2a1a;
  border-radius: 8px;
  padding: 12px 14px;
}
.landing-side h3 {
  color: #d4af37;
  font-size: 0.9em;
  margin: 14px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #5a4530;
}
.landing-side h3:first-child { margin-top: 0; }

.tagline { color: #8fd694; font-weight: bold; font-size: 1.05em; }

.landing-stats {
  background: rgba(36, 26, 18, 0.6);
  border-radius: 8px;
  padding: 10px 16px;
  margin: 16px auto;
  display: inline-block;
  text-align: left;
}
.landing-stats p { margin: 4px 0; font-size: 0.92em; }

.emblem { margin: 18px auto; width: 100px; }
.emblem svg { width: 100%; height: auto; display: block; }

.login-form {
  max-width: 280px;
  margin: 14px auto;
  text-align: left;
}
.login-form button { width: 100%; margin-top: 10px; }

.landing-footnote {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid #3a2a1a;
  text-align: left;
}
.landing-footnote h2 { font-size: 1em; margin-bottom: 8px; margin-top: 0; }
.landing-footnote p { color: #cdbfa5; font-size: 0.92em; }

.landing-list { list-style: none; margin: 0; padding: 0; font-size: 0.95em; }
.landing-list li { padding: 3px 0; }
.muted { color: #8a7a62; font-size: 0.9em; }

/* ----- Responsive ----- */

@media (max-width: 980px) {
  .layout { justify-content: flex-start; }
  .content { max-width: none; }
  .landing-grid { grid-template-columns: 1fr; }
  .landing-nav { flex-direction: row; flex-wrap: wrap; gap: 20px; }
}

@media (max-width: 700px) {
  .layout { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar, .statbar { width: 100%; }
  .content { padding: 16px; order: -1; }
  .landing-nav { flex-direction: column; gap: 14px; }
  .item-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .item-table th, .item-table td { padding: 6px; font-size: 0.92em; }
  .topbar { padding: 8px 12px; }
  .logo { font-size: 1.15em; }
  .userbar { font-size: 0.82em; gap: 8px; }
  .emblem { width: 80px; }
  h1 { font-size: 1.3em; }
  h2 { font-size: 1.1em; }
  .chat-input-row { flex-direction: column; align-items: stretch; }
  .chat-messages { max-height: 260px; }
}

/* Größere Tippflächen auf Touch-Geräten (kein Hover verfügbar). */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .menu-list a, .sidebar a {
    min-height: 40px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  input, select { min-height: 40px; }
  .chat-form textarea { min-height: 44px; }
}
