/* Dragon Attack Teams – Stylesheet
   Farben: Schieferblau-Nacht mit Glut-Amber. Jedes Team bekommt ein eigenes
   Wappen in einer aus dem Namen abgeleiteten Farbe (--hue). */

:root {
  --bg: #151823;
  --bg-deep: #10121b;
  --surface: #1d2130;
  --raise: #262b3d;
  --line: #333a50;
  --text: #ece7dc;
  --muted: #9ba2b8;
  --ember: #f2a43a;
  --ember-strong: #ffb957;
  --ember-ink: #2a1a05;
  --danger: #e8615a;
  --ok: #63c393;
  --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius-s: 6px;
  --radius-m: 10px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(242, 164, 58, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.4em;
  letter-spacing: 0.005em;
}
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1em; }

a {
  color: var(--ember-strong);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--ember-strong);
  outline-offset: 2px;
}

.hidden,
[hidden] {
  display: none !important;
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 27, 0.7);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
}
.brand svg { width: 30px; height: 34px; }
.brand span small {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

/* ---------- Layout ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 3rem;
}

.page-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

section + section { margin-top: 2.75rem; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0; }

.notice {
  max-width: 1080px;
  margin: 1rem auto 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--ember);
  background: rgba(242, 164, 58, 0.08);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  width: calc(100% - 2rem);
}
.notice.lock { border-left-color: var(--danger); background: rgba(232, 97, 90, 0.08); }

/* ---------- Buttons & Formulare ---------- */

.btn {
  --b: var(--raise);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--b);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: #4a5372; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary {
  background: var(--ember);
  border-color: var(--ember);
  color: var(--ember-ink);
  font-weight: 650;
}
.btn.primary:hover { background: var(--ember-strong); border-color: var(--ember-strong); }
.btn.danger { color: #ffb4ae; border-color: rgba(232, 97, 90, 0.45); background: transparent; }
.btn.danger:hover { background: rgba(232, 97, 90, 0.12); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 32px; padding: 0.25rem 0.65rem; font-size: 0.85rem; }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #fff; font-weight: 600; }
.btn.discord:hover { background: #6b77f5; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

label { display: block; font-weight: 500; margin-bottom: 0.35rem; }
.field { margin-bottom: 1.1rem; }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.3rem; }

input[type='text'],
input[type='number'],
input[type='url'],
input[type='email'],
input[type='password'],
input[type='search'],
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #6c7390; }
input:focus, textarea:focus, select:focus { border-color: var(--ember); outline: none; box-shadow: 0 0 0 3px rgba(242, 164, 58, 0.18); }

.check {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-weight: 400;
  cursor: pointer;
}
.check input { margin-top: 0.3rem; accent-color: var(--ember); }

.choice-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.choice {
  position: relative;
  display: block;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg-deep);
  cursor: pointer;
  font-weight: 400;
  margin: 0;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice strong { display: block; font-weight: 600; }
.choice span { font-size: 0.85rem; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--ember); background: rgba(242, 164, 58, 0.07); }
.choice:has(input:focus-visible) { outline: 2px solid var(--ember-strong); outline-offset: 2px; }

.code-input {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-size: 1.1rem;
}

/* ---------- Wappen ---------- */

.crest { flex: none; display: block; }
.crest .shield { fill: hsl(var(--hue, 30) 38% 26%); stroke: hsl(var(--hue, 30) 62% 62%); stroke-width: 2.5; }
.crest .band { fill: hsl(var(--hue, 30) 45% 34%); }
.crest text {
  fill: hsl(var(--hue, 30) 85% 88%);
  font-family: var(--serif);
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}

/* ---------- Gäste-Startseite ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  padding: clamp(1rem, 5vw, 3rem) 0;
}
.hero p { font-size: 1.1rem; color: #cfd3e0; max-width: 34em; }
.hero-crests {
  position: relative;
  height: 280px;
}
.hero-crests .crest { position: absolute; filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.45)); }
.hero-crests .crest:nth-child(1) { width: 150px; left: 22%; top: 8%; z-index: 3; }
.hero-crests .crest:nth-child(2) { width: 110px; left: 2%; top: 38%; transform: rotate(-9deg); opacity: 0.85; }
.hero-crests .crest:nth-child(3) { width: 110px; left: 58%; top: 34%; transform: rotate(8deg); opacity: 0.85; }
.hero-crests .crest:nth-child(4) { width: 70px; left: 70%; top: 0; transform: rotate(14deg); opacity: 0.55; }
.invite-banner {
  margin-bottom: 1.25rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(242, 164, 58, 0.4);
  border-radius: var(--radius-s);
  background: rgba(242, 164, 58, 0.06);
}

@media (prefers-reduced-motion: no-preference) {
  .hero-crests .crest:nth-child(1) { animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  @keyframes rise {
    from { transform: translateY(18px) scale(0.96); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
}

/* ---------- Mein Team ---------- */

.team-banner {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  align-items: center;
  padding: clamp(1.1rem, 3vw, 1.75rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background:
    linear-gradient(120deg, hsl(var(--hue, 30) 40% 22% / 0.55), transparent 55%),
    var(--surface);
}
.team-banner .crest { width: clamp(84px, 14vw, 120px); }
.team-banner h1 { margin-bottom: 0.2em; overflow-wrap: anywhere; }
.team-banner p { margin-bottom: 0.6rem; color: #d6d9e4; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--raise);
}
.badge.public { border-color: rgba(99, 195, 147, 0.5); color: #9fe2c0; }
.badge.private { border-color: rgba(242, 164, 58, 0.5); color: #ffd39a; }
.badge.owner { background: var(--ember); border-color: var(--ember); color: var(--ember-ink); font-weight: 600; }
.badge.full { border-color: rgba(232, 97, 90, 0.5); color: #ffb4ae; }

.team-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.panel {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.panel h3 { margin-bottom: 0.8rem; }
.panel + .panel { margin-top: 1.25rem; }

.member-list { list-style: none; margin: 0; padding: 0; }
.member {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.member:first-child { border-top: 0; padding-top: 0; }
.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--serif);
  background: hsl(var(--hue, 220) 30% 30%);
  color: hsl(var(--hue, 220) 80% 88%);
}
.member-name { flex: 1; min-width: 0; }
.member-name strong { display: block; overflow-wrap: anywhere; }
.member-name .handle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.member-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }

.copy-btn {
  border: 0;
  background: none;
  color: var(--ember-strong);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}
.copy-btn:hover { background: rgba(242, 164, 58, 0.12); }

.invite-code {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--ember-strong);
  margin: 0.2rem 0 0.8rem;
  user-select: all;
}
.invite-link {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  margin-bottom: 0.9rem;
}

/* ---------- Kein Team ---------- */

.start-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

/* ---------- Teamliste ---------- */

.toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input[type='search'] { width: 220px; min-height: 38px; }
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow: hidden;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
}
.seg button[aria-pressed='true'] { background: var(--raise); color: var(--text); }

.team-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.9rem;
}
.team-item {
  display: flex;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.team-item.mine { border-color: rgba(242, 164, 58, 0.6); }
.team-item .crest { width: 52px; }
.team-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.team-item h3 { font-size: 1.1rem; margin-bottom: 0.15rem; overflow-wrap: anywhere; }
.team-item p { font-size: 0.92rem; color: #cfd3e0; margin-bottom: 0.5rem; overflow-wrap: anywhere; }
.team-item .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

.capacity {
  display: flex;
  gap: 3px;
  align-items: center;
}
.capacity i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--line);
}
.capacity i.on { background: var(--ember); }

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
}

/* ---------- Dialog & Toast ---------- */

dialog {
  width: min(460px, calc(100% - 2rem));
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  padding: 1.4rem;
}
dialog::backdrop { background: rgba(8, 9, 14, 0.7); }
dialog h2 { font-size: 1.35rem; }
dialog .btn-row { justify-content: flex-end; margin-top: 1.2rem; }

.toast-wrap {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 0.5rem;
  z-index: 50;
  width: min(460px, calc(100% - 2rem));
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-s);
  background: var(--raise);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.error { border-left-color: var(--danger); }

/* ---------- Fußzeile ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Rechtstexte ---------- */

.legal h1 { margin-bottom: 0.3em; }
.legal h2 { font-size: 1.3rem; margin-top: 2rem; }
.legal h3 { font-size: 1.05rem; margin-top: 1.3rem; font-family: var(--sans); }
.legal p, .legal li { color: #d6d9e4; line-height: 1.7; }
.legal ul { padding-left: 1.2rem; }

/* ---------- Admin ---------- */

.admin-tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}
.admin-tabs a {
  padding: 0.6rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.admin-tabs a[aria-current='page'] { color: var(--text); border-bottom-color: var(--ember); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
}
.stat { padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
.stat b { display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 0.9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; background: var(--surface); }
tr:last-child td { border-bottom: 0; }

.admin-team { padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 0.9rem; }
.admin-team header { display: flex; gap: 0.9rem; align-items: center; flex-wrap: wrap; }
.admin-team header .crest { width: 44px; }
.admin-team header div { flex: 1; min-width: 200px; }
.admin-team details { margin-top: 0.8rem; }
.admin-team summary { cursor: pointer; color: var(--muted); }

.status-ok { color: var(--ok); }
.status-warn { color: var(--ember-strong); }
.status-err { color: var(--danger); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

/* ---------- Responsiv ---------- */

@media (max-width: 820px) {
  .hero, .team-grid, .start-grid { grid-template-columns: 1fr; }
  .hero-crests { height: 200px; order: -1; }
  .hero-crests .crest:nth-child(1) { width: 110px; left: 34%; }
  .hero-crests .crest:nth-child(2) { width: 80px; left: 10%; }
  .hero-crests .crest:nth-child(3) { width: 80px; left: 62%; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .team-banner { flex-direction: column; align-items: flex-start; }
  .choice-group { grid-template-columns: 1fr; }
  .member { flex-wrap: wrap; }
  .member-actions { width: 100%; justify-content: flex-start; padding-left: 52px; }
  .user-chip .name { display: none; }
  .toolbar input[type='search'] { width: 100%; }
}

/* ---------- Kleinteile ---------- */
.mt-1 { margin-top: 1rem; }
.fieldset-reset { border: 0; padding: 0; margin-left: 0; margin-right: 0; min-width: 0; }
.legend { font-weight: 500; margin-bottom: 0.35rem; padding: 0; }
.input-narrow { max-width: 140px; }
.team-item { align-items: flex-start; }
.team-item p.mt-1 { margin-top: 0.5rem; }
.start-grid > .panel + .panel { margin-top: 0; }
.brand span { white-space: nowrap; }
@media (max-width: 520px) { .topbar { padding-left: 0.8rem; padding-right: 0.8rem; } .user-area { gap: 0.4rem; } }
.member-name .badge { margin-left: 0.4rem; }
.team-grid { align-items: start; }
.team-grid > .panel + .panel { margin-top: 0; }
.hero p.small { font-size: 0.875rem; color: var(--muted); }
