@font-face { font-family: "Clash Display"; font-weight: 500; font-display: swap; src: url("/fonts/clash-display-500.woff2") format("woff2"); }
@font-face { font-family: "Clash Display"; font-weight: 600; font-display: swap; src: url("/fonts/clash-display-600.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 400; font-display: swap; src: url("/fonts/dm-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "DM Sans"; font-weight: 500; font-display: swap; src: url("/fonts/dm-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("/fonts/poppins-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("/fonts/poppins-latin-500-normal.woff2") format("woff2"); }

:root {
  --bg: #161819;
  --surface: #1e2021;
  --field: #27282a;
  --field-hover: #303436;
  --line: #2b2e30;
  --text: #ececec;
  --muted: #939b9f;
  --soft: #c9cdcf;
  --green: #6db542;
  --orange: #d8823b;
  --red: #b42d28;
  --display: "Clash Display", "Arial Black", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --modal: "Poppins", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

.sprite { position: absolute; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

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

/* ---------- Kopf ---------- */

.topbar {
  display: flex; justify-content: flex-end; gap: 4px;
  padding: 12px 16px 0;
}

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 4px; background: none; color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--field); }
.icon-btn svg { width: 22px; height: 22px; }

.game {
  width: 100%; max-width: 640px;
  margin: 0 auto; padding: 0 16px 48px;
}

.title {
  margin: 4px 0 40px;
  font: 600 72px/1 var(--display);
  letter-spacing: -1.8px;
  text-align: center;
}

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

.controls { display: flex; gap: 8px; }

.search { position: relative; flex: 1; margin: 0; }

.search input {
  width: 100%; height: 48px;
  padding: 0 64px 0 42px;
  border: 0; border-radius: 4px;
  background: var(--field); color: var(--text);
  font: 500 18px var(--display); letter-spacing: 0.9px;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; box-shadow: inset 0 0 0 1px #3a3e41; }

.search-icon {
  position: absolute; left: 12px; top: 50%;
  width: 20px; height: 20px; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

.game-no {
  position: absolute; right: 12px; top: 50%; margin: 0;
  transform: translateY(-50%);
  font: 500 18px var(--display); letter-spacing: 0.9px;
  color: var(--muted); pointer-events: none;
}

.menu { position: relative; }

.menu-btn {
  display: grid; place-items: center;
  width: 48px; height: 48px; padding: 0;
  border: 0; border-radius: 4px;
  background: var(--field); color: var(--soft);
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--field-hover); }
.menu-btn svg { width: 20px; height: 20px; }

.menu-list {
  position: absolute; right: 0; top: calc(100% + 16px); z-index: 10;
  display: flex; flex-direction: column;
  min-width: 220px; padding: 6px;
  border: 1px solid #2f3234; border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
}
.menu-list[hidden] { display: none; }
.menu-list button {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border: 0; border-radius: 4px;
  background: none; text-align: left; white-space: nowrap;
  font: 400 17px var(--body); color: var(--text);
}
.menu-list button:hover, .menu-list button:focus-visible { background: var(--field); outline: none; }
.menu-list button:disabled { color: var(--muted); cursor: default; background: none; }
.menu-list svg { width: 18px; height: 18px; flex: none; }
.menu-list .confirm { color: #ff8a80; }

/* ---------- Status und Liste ---------- */

.status { min-height: 56px; margin-top: 24px; }

.message {
  margin: 0; padding: 0 16px;
  font: 400 18px var(--body); color: var(--muted);
}
.message.is-error { color: var(--text); }
.message:empty { display: none; }

#last:not(:empty) { margin-top: 0; }
.message:not(:empty) + #last:not(:empty) { margin-top: 12px; }

.divider { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }

.guesses {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}

.row {
  position: relative; overflow: hidden;
  height: 48px; border-radius: 6px;
  background: var(--surface);
}

.bar {
  position: absolute; inset: 0 auto 0 0;
  width: max(8px, var(--w, 0%));
  background: var(--c, var(--red));
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.row--green { --c: var(--green); }
.row--orange { --c: var(--orange); }
.row--red { --c: var(--red); }
.row--win { --c: var(--green); --w: 100%; height: 64px; }

.row-content {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 100%; padding: 0 16px;
}
.row-word {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 600 20px var(--display); letter-spacing: 1px;
}
.row--win .row-word { font-size: 28px; letter-spacing: 0.5px; }
.row-rank { font: 600 20px var(--display); font-variant-numeric: tabular-nums; }
.row-icon { width: 24px; height: 24px; flex: none; }
.row-hint { width: 22px; height: 22px; flex: none; margin-right: -4px; }

.row.is-latest { box-shadow: inset 0 0 0 2px var(--text); }

@keyframes pop { from { transform: scale(0.97); opacity: 0.4; } }
.row.is-new { animation: pop 0.25s ease-out; }

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

.result {
  margin-top: 24px; padding: 28px 24px 24px;
  border-radius: 12px; background: var(--surface);
  text-align: center;
}
.result h2 { margin: 0 0 8px; font: 600 40px/1.1 var(--display); letter-spacing: -0.5px; }
.result p { margin: 0 0 4px; font: 400 17px var(--modal); color: var(--muted); }
.result strong { color: var(--text); font-weight: 500; }
.result-stats {
  display: flex; justify-content: center; gap: 20px;
  margin: 16px 0 20px; font: 600 18px var(--display);
}
.result-stats span { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 0; border-radius: 6px;
  background: var(--field); font: 500 16px var(--body);
}
.btn:hover { background: var(--field-hover); }
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: #79c24d; }
.btn svg { width: 18px; height: 18px; }
.countdown { margin-top: 16px !important; font-size: 15px !important; }

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

.modal {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  padding: 40px 24px 24px;
  border: 0; border-radius: 12px;
  background: var(--surface); color: var(--text);
  text-align: center;
}
.modal::backdrop { background: rgb(0 0 0 / 0.36); }
.modal h2 { margin: 0 0 12px; font: 500 36px/1.1 var(--modal); }
.modal-lead { margin: 0 0 20px; font: 400 16px/1.45 var(--modal); color: var(--muted); }
.modal-foot { margin: 20px 0 0; font: 400 14px var(--body); color: var(--muted); }
.modal-close {
  position: absolute; top: 12px; right: 12px;
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 4px; background: none; color: var(--soft);
}
.modal-close:hover { background: var(--field); }
.modal-close svg { width: 20px; height: 20px; }

.example {
  display: flex; flex-direction: column; gap: 8px;
  padding: 24px; border-radius: 16px; background: var(--bg);
  text-align: left;
}
.example .row { height: 34px; }
.example .row--win { height: 50px; }
.example .row-content { padding: 0 8px; }
.example .row-word { font: 500 15px var(--display); letter-spacing: 0.5px; }
.example .row--win .row-word { font: 600 22px var(--display); }
.example .row-rank { font: 500 15px var(--display); }
.example .row-icon { width: 20px; height: 20px; }
.example .row-content { padding: 0 10px; }

.archive-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px;
  max-height: 60vh; overflow-y: auto;
  margin: 8px 0 0; padding: 0; list-style: none;
}
.archive-list a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border-radius: 6px;
  background: var(--field); color: var(--text); text-decoration: none;
  font: 600 17px var(--display);
}
.archive-list a:hover { background: var(--field-hover); }
.archive-list a[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--text); }
.archive-list small { font: 400 12px var(--body); color: var(--muted); }
.archive-list .won small { color: var(--green); }
.archive-list .lost small { color: #e0645c; }

/* ---------- Kleinkram ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 20;
  transform: translateX(-50%);
  padding: 10px 16px; border-radius: 6px;
  background: var(--text); color: var(--bg);
  font: 500 15px var(--body);
}
.toast[hidden] { display: none; }

.footer {
  padding: 0 16px 24px; text-align: center;
  font: 400 12px var(--body); color: #6b7276;
}
.footer a { color: inherit; }

@media (max-width: 560px) {
  .title { font-size: 48px; letter-spacing: -1.2px; margin-bottom: 28px; }
  .row-word, .row-rank { font-size: 17px; }
  .search input, .game-no { font-size: 16px; }
  .result h2 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar { transition: none; }
  .row.is-new { animation: none; }
}

.modal h2:focus { outline: none; }
.result .guesses { margin-top: 20px; text-align: left; }
.status[hidden] { display: none; }
