:root {
  --bg: #0f1729;
  --bg-soft: #182238;
  --card: #1c2941;
  --line: #2c3d5c;
  --text: #eaf0fb;
  --muted: #93a4c4;
  --accent: #4f8dfd;
  --accent-dim: #2a4a86;
  --good: #35c489;
  --good-bg: #123a2c;
  --bad: #f26a6a;
  --bad-bg: #3d1d21;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1100px 620px at 50% -12%, #23325a 0%, var(--bg) 60%) no-repeat, var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  padding: clamp(16px, 4vw, 40px);
  display: flex;
  justify-content: center;
}

/* Muss !important sein: die #id-Regeln unten setzen display und wuerden
   diese Regel sonst per Spezifitaet aushebeln. */
[hidden] { display: none !important; }

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 30px);
}

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 22px;
  cursor: pointer;
  transition: background .12s, transform .06s, border-color .12s;
}

.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: #6ba0ff; }

.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--ghost:hover { border-color: var(--accent); color: var(--text); }

.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.linkish:hover { color: var(--text); }

kbd {
  font: inherit;
  font-size: 12px;
  opacity: .75;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 5px;
  padding: 0 5px;
}

/* ------------------------------------------------------------- Anmeldung */

#screen-login {
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 320px);
  gap: 22px;
  align-items: start;
  align-content: center;
  justify-content: center;
  width: 100%;
  max-width: 780px;
  min-height: calc(100vh - 80px);
}

.card--login { text-align: center; }

.logo {
  font-size: clamp(30px, 5vw, 40px);
  background: linear-gradient(92deg, #7fb0ff, #c9a4ff 60%, #ff9ec4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub { color: var(--muted); margin: 10px 0 24px; }

#login-form { display: flex; flex-direction: column; gap: 12px; }

#login-form input {
  font: inherit;
  font-size: 17px;
  text-align: center;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
}
#login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 141, 253, .22);
}
#login-form input::placeholder { color: #6c7f9f; }

#btn-register { margin-top: 2px; }

.error { color: var(--bad); font-size: 14px; margin: 12px 0 0; }
.note { color: var(--good); font-size: 14px; margin: 12px 0 0; }

.mode {
  display: flex;
  gap: 8px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.mode label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 14px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
}
.mode label:has(input:checked) {
  border-color: var(--accent);
  background: rgba(79, 141, 253, .13);
  color: var(--text);
}
.mode input { accent-color: var(--accent); margin: 0; }

.mode-hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; min-height: 1.5em; }

/* ------------------------------------------------------------- Rangliste */

.card--board h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }

.board {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 15px;
}
.board li:nth-child(odd) { background: rgba(255, 255, 255, .035); }

.board__rank { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.board__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board__score { font-weight: 650; font-variant-numeric: tabular-nums; }
.board__empty { display: block; color: var(--muted); font-size: 14px; background: none !important; }

.board li.is-me { background: rgba(79, 141, 253, .18); box-shadow: inset 0 0 0 1px var(--accent-dim); }
.board li:nth-child(1) .board__rank { color: #f2c14e; }
.board li:nth-child(2) .board__rank { color: #c7d0dd; }
.board li:nth-child(3) .board__rank { color: #d09a63; }

/* ------------------------------------------------------------------ Quiz */

#screen-quiz {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-areas: "bar bar" "quiz side";
  gap: 20px;
  width: 100%;
  max-width: 1080px;
  align-content: start;
}

.bar {
  grid-area: bar;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 22px;
}

.bar__player { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.bar__name { font-weight: 650; font-size: 18px; }

.bar__stats { display: flex; gap: 26px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.stat__val { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.btn--danger { background: var(--bad); color: #2c0d0d; }
.btn--danger:hover { background: #ff8484; }

.confirm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  font-size: 14px;
  background: var(--bad-bg);
  border: 1px solid var(--bad);
  border-radius: var(--radius);
}
.confirm__actions { display: flex; align-items: center; gap: 14px; }
.confirm .btn { padding: 8px 16px; font-size: 14px; }

.quiz { grid-area: quiz; display: flex; flex-direction: column; gap: 18px; }

.flagbox {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  justify-content: center;
}

.badge {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #ffd479;
  background: rgba(242, 193, 78, .13);
  border: 1px solid rgba(242, 193, 78, .38);
  border-radius: 999px;
  padding: 4px 11px;
}

.flag {
  width: 100%;
  max-width: 430px;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: contain;
  border-radius: 6px;
  /* Weiße und sehr helle Flaggen brauchen eine Kante gegen den dunklen Grund */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 8px 22px rgba(0, 0, 0, .4);
  transition: opacity .15s;
}
.flag.is-loading { opacity: 0; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  font: inherit;
  font-size: 16px;
  text-align: left;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .06s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: #223354; }
.opt:active:not(:disabled) { transform: translateY(1px); }
.opt:disabled { cursor: default; }

.opt__key {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.opt.is-correct { border-color: var(--good); background: var(--good-bg); }
.opt.is-correct .opt__key { background: var(--good); border-color: var(--good); color: #06231a; }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.is-wrong .opt__key { background: var(--bad); border-color: var(--bad); color: #2c0d0d; }
.opt.is-faded:disabled { opacity: .42; }

.feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}
.feedback__text { margin: 0; font-size: 16px; }
.feedback__text.is-good { color: var(--good); font-weight: 600; }
.feedback__text.is-bad { color: var(--bad); }
.feedback__text .name { color: var(--text); font-weight: 650; }

.card--side { grid-area: side; align-self: start; position: sticky; top: 20px; }

/* --------------------------------------------------------------- Schmal */

@media (max-width: 860px) {
  #screen-login { grid-template-columns: minmax(0, 460px); min-height: 0; }
  #screen-quiz { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "quiz" "side"; }
  .card--side { position: static; }
  .options { grid-template-columns: 1fr; }
  .bar__stats { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
