/* NRWdle — Benka Arcade */

:root {
  --bg: #0e1116;
  --bg-soft: #161b23;
  --card: #1b222d;
  --line: #2a3342;
  --text: #e8edf4;
  --muted: #93a0b4;
  --accent: #58a6ff;
  --hit: #2fbf71;   /* richtig */
  --close: #e8c547; /* 50–74 % */
  --near: #f2845c;  /* 25–49 % */
  --miss: #e5534b;  /* unter 25 % */
  --radius: 14px;
  /* heller Untergrund hinter Wappen-Miniaturen: dunkle Konturen müssen sichtbar bleiben */
  --coat-chip: #f2efe6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 50% -100px, #1a2333 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* ---------- Header ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.35rem;
  letter-spacing: 0.25em;
  margin: 0;
  font-weight: 800;
  background: linear-gradient(90deg, #58a6ff, #2fbf71, #e8c547, #f2845c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.modes {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}

.mode-btn.active {
  background: var(--accent);
  color: #08111f;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.streak {
  font-size: 0.85rem;
  font-weight: 700;
  color: #ffb454;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.icon-btn:hover { border-color: var(--accent); }

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

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

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

/* ---------- Wappen-Karte (quadratisch) ---------- */

#coat-card {
  position: relative;
  max-width: 460px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 18px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  background: var(--card);
}

#coat-canvas,
#cover-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#cover-canvas { z-index: 1; }

#coat-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  font-weight: 800;
  color: var(--muted);
  z-index: 2;
  pointer-events: none;
}

/* ID-Selektor schlägt das UA-Stylesheet — hidden muss hier explizit gewinnen */
#coat-lock[hidden] { display: none; }

#coat-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* ---------- Raten-Reihen ---------- */

#guesses {
  list-style: none;
  margin: 0 auto 18px;
  padding: 0;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 52px;
  animation: pop-in 0.25s ease;
}

@keyframes pop-in {
  from { transform: scale(0.96); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.guess .g-coat {
  width: 42px;
  flex: 0 0 42px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--coat-chip);
}

.guess .g-coat img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.guess .g-body { flex: 1; min-width: 0; }
.guess .g-name { font-weight: 700; display: block; }

.guess .g-pct {
  font-size: 0.95rem;
  font-weight: 800;
  flex: 0 0 auto;
  color: var(--muted);
}

.guess.p-win  { border-left-color: var(--hit); }
.guess.p-win .g-pct  { color: var(--hit); }
.guess.p-high { border-left-color: var(--hit); }
.guess.p-high .g-pct { color: var(--hit); }
.guess.p-mid  { border-left-color: var(--close); }
.guess.p-mid .g-pct  { color: var(--close); }
.guess.p-low  { border-left-color: var(--near); }
.guess.p-low .g-pct  { color: var(--near); }
.guess.p-zero { border-left-color: var(--miss); }
.guess.p-zero .g-pct { color: var(--miss); }

#guesses.shake { animation: shake 0.4s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---------- Eingabe ---------- */

#input-area {
  position: relative;
  max-width: 540px;
  margin: 0 auto;
}

.input-row { display: flex; gap: 8px; }

#guess-input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 1rem;
  outline: none;
}

#guess-input:focus { border-color: var(--accent); }

button.primary {
  background: var(--accent);
  border: 0;
  color: #08111f;
  font-weight: 700;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: 1rem;
  cursor: pointer;
}

button.primary:disabled { opacity: 0.45; cursor: default; }

#btn-guess:hover:not(:disabled) { filter: brightness(1.1); }

.sub-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- Autocomplete ---------- */

#autocomplete {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  z-index: 30;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
  max-height: 280px;
  overflow-y: auto;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
}

.ac-item img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--coat-chip);
}

.ac-item.selected, .ac-item:hover { background: rgba(88, 166, 255, 0.15); }

/* ---------- Ergebnis ---------- */

#result {
  max-width: 540px;
  margin: 0 auto;
  text-align: center;
}

.result-emoji { font-size: 3rem; line-height: 1; margin-bottom: 6px; }

#result h2 { margin: 0 0 18px; font-size: 1.5rem; }

#result-coat-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  text-align: left;
  margin-bottom: 12px;
}

#result-coat {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--coat-chip);
  padding: 4px;
}

#result-city { font-size: 1.25rem; font-weight: 800; }

#result-points { font-size: 1.05rem; margin-bottom: 16px; }
#result-points strong { color: var(--hit); }

.share-grid {
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: 0.18em;
  margin-bottom: 18px;
  user-select: all;
}

.result-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.result-buttons button {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.result-buttons button.primary { background: var(--accent); border-color: transparent; color: #08111f; }

/* ---------- Dialoge ---------- */

dialog {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 440px;
  width: calc(100% - 32px);
  padding: 22px;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }

dialog h2 { margin-top: 0; }

dialog .primary { width: 100%; margin-top: 8px; }

.legend { list-style: none; padding: 0; }

.legend li { display: flex; align-items: center; gap: 10px; margin: 8px 0; }

.scores-list { padding-left: 22px; }
.scores-list li { margin: 6px 0; font-size: 1.02rem; }
.scores-list .pts { color: var(--hit); font-weight: 700; }

#name-dialog .input-row { margin-bottom: 12px; }
#name-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

/* ---------- Konfetti & Toast ---------- */

#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 60;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- Mobil ---------- */

@media (max-width: 480px) {
  .logo { font-size: 1.1rem; letter-spacing: 0.18em; }
  .mode-btn { padding: 6px 10px; }
  .guess .g-pct { font-size: 0.85rem; }
  #coat-card { max-width: 100%; }
}