/* Look angelehnt an AoE2: Pergament, Bronze/Gold, Spielerfarben Blau und Rot. */

:root {
  --bg: #e9dcbc;
  --bg-deep: #d9c69b;
  --surface: #f5ecd5;
  --surface-2: #efe2c2;
  --text: #2b2115;
  --muted: #74624a;
  --border: #b99c64;
  --gold: #a8791f;
  --gold-light: #e2bd62;
  --gold-text: #2b1d08;
  --accent: #8e2a1c;
  --blue: #2457a6;
  --red: #b0281c;
  --green: #3f7a2a;
  --header-bg: #2e2419;
  --header-text: #f0dfb4;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 2px 6px rgba(60, 40, 10, 0.18);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1610;
    --bg-deep: #120e0a;
    --surface: #2a2219;
    --surface-2: #322819;
    --text: #efe2c4;
    --muted: #b09d7d;
    --border: #6b5530;
    --gold: #d1a246;
    --gold-light: #f0cd7a;
    --gold-text: #20160a;
    --accent: #e0775c;
    --blue: #6f9ae8;
    --red: #ee6b5c;
    --green: #8cc46c;
    --header-bg: #0f0b08;
    --header-text: #f0dfb4;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font: 17px/1.5 "Alegreya Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at top, transparent 40%, rgba(80, 50, 10, 0.12) 100%),
    repeating-linear-gradient(115deg, rgba(120, 80, 20, 0.035) 0 2px, transparent 2px 7px),
    var(--bg);
  min-height: 100vh;
}

h1, h2, h3, h4, summary, button { font-family: "Cinzel", Georgia, serif; }

/* --- Kopfzeile --- */

.banner {
  background: linear-gradient(var(--header-bg), #1d160f);
  color: var(--header-text);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 0 #00000040;
}
.banner-inner { max-width: 680px; margin: 0 auto; padding: 18px 16px 14px; display: flex; align-items: center; gap: 14px; }
.crest { width: 44px; height: 52px; flex: none; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: 0.04em; font-weight: 700; }
h1 span { color: var(--gold-light); }
.banner .status { margin: 2px 0 0; font-size: 0.85rem; color: #cbb98f; }

main { max-width: 680px; margin: 0 auto; padding: 20px 16px 64px; }
h2, h3 { font-size: 1.05rem; margin: 0; white-space: nowrap; letter-spacing: 0.03em; }
h4 { font-size: 0.95rem; margin: 0 0 6px; }
.muted { color: var(--muted); font-weight: normal; }
section { margin-bottom: 20px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }

/* --- Spielerauswahl --- */

.players { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.players label {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; min-height: 48px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s;
}
.players label:hover { background: var(--surface-2); }
.players label:has(input:checked) { border-color: var(--gold); background: var(--surface-2); outline: 1px solid var(--gold); }
.players .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.players input { accent-color: var(--gold); width: 16px; height: 16px; }
.players .elo { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.group-elo { color: var(--gold); font-size: 0.78rem; font-weight: 700; }

.guest-form { display: flex; gap: 6px; margin-top: 8px; }
.guest-form input {
  min-width: 0; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
}
.guest-form #guest-name, .guest-form #add-id { flex: 2; }
.guest-form #guest-elo, .guest-form #add-name { flex: 1; }

/* --- Klappbereiche --- */

details.panel {
  margin-bottom: 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow);
}
details.panel summary { cursor: pointer; font-weight: 700; letter-spacing: 0.03em; }
details.panel summary::marker { color: var(--gold); }
details.panel label { display: block; margin-top: 10px; }
details.panel input[type="range"] { width: 100%; accent-color: var(--gold); }

/* --- Knöpfe --- */

button {
  font-size: 0.95rem; font-weight: 700; letter-spacing: 0.04em; cursor: pointer;
  color: var(--gold-text); border: 1px solid #6e4e12; border-radius: 4px;
  background: linear-gradient(var(--gold-light), var(--gold));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 2px 0 #5a3f0e;
  padding: 8px 14px;
}
button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #5a3f0e; }
button:disabled { opacity: 0.5; cursor: default; }
#suggest { width: 100%; padding: 13px; font-size: 1.1rem; margin-top: 4px; }

/* --- Ergebnisse --- */

.result {
  margin-top: 16px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  box-shadow: var(--shadow), 0 0 0 4px var(--surface) inset, 0 0 0 5px var(--border) inset;
}
.result .section-head { margin-bottom: 12px; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; }
.vs { align-self: center; font-family: "Cinzel", Georgia, serif; font-weight: 700; color: var(--gold); font-size: 1.1rem; }
.team { border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.team h4 { margin: 0; padding: 6px 10px; color: #fff; display: flex; justify-content: space-between; font-size: 0.9rem; }
.team h4 .muted { color: #ffffffcc; }
.team-0 h4 { background: var(--blue); }
.team-1 h4 { background: var(--red); }
@media (prefers-color-scheme: dark) {
  .team-0 h4 { background: #2457a6; }
  .team-1 h4 { background: #a8291e; }
}
.team ul { list-style: none; padding: 6px 10px; margin: 0; }
.team li { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.team li + li { border-top: 1px dotted var(--border); }

/* --- Rangliste --- */

.ranking { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.ranking th, .ranking td { padding: 5px 6px; text-align: right; border-top: 1px solid var(--border); }
.ranking th:first-child, .ranking td:first-child { text-align: left; }
.ranking th { color: var(--muted); font-weight: normal; }
.ranking td:nth-child(3) { color: var(--gold); font-weight: 700; }
.ranking .up { color: var(--green); }
.ranking .down { color: var(--red); }

/* --- Verwaltung --- */

.small { font-size: 0.85rem; margin: 8px 0 0; }
.admin-players { list-style: none; padding: 0; margin: 8px 0 0; }
.admin-players li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }
.admin-players button, .guest-form button, .backfill button { padding: 6px 12px; font-size: 0.85rem; }
.backfill { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }

@media (max-width: 420px) {
  .teams { grid-template-columns: 1fr; }
  .vs { justify-self: center; }
  h1 { font-size: 1.3rem; }
}
