/* Wörtle – Stil */

@font-face {
  font-family: 'Archivo';
  src: url(fonts/archivo.woff2) format('woff2-variations'), url(fonts/archivo.woff2) format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face { font-family: 'Plex Mono'; src: url(fonts/plex-mono-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url(fonts/plex-mono-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Mono'; src: url(fonts/plex-mono-600.woff2) format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --ink: #111111;
  --paper: #ffffff;
  --line: #e2e2de;
  --muted: #5c5c58;
  --muted-2: #8a8a85;
  --key: #e4e4df;
  --key-active: #cfcfc9;
  --accent: #d7261e;
  /* Spielfarben: richtig, woanders, nicht drin */
  --c: #1f7a46;
  --p: #e3b11f;
  --a: #7d7d78;
  --radius: 4px;
  --sans: 'Archivo', system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --pad: 20px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

.app {
  max-width: 520px;
  margin: 0 auto;
  overflow-x: hidden;
  overflow-x: clip;
}
@media (min-width: 521px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.screen { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- Typo & Helfer ---------- */
.wordmark { font-weight: 800; font-stretch: 125%; font-size: 15px; letter-spacing: 1px; }
.title { font-weight: 700; font-stretch: 90%; font-size: 30px; line-height: 1.1; }
.lead { font-size: 15px; line-height: 1.5; color: #3f3f3b; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Leiste ---------- */
.topbar {
  height: 56px; flex-shrink: 0;
  padding: 0 8px 0 var(--pad);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--ink);
}
.top-actions { display: flex; justify-content: flex-end; }

.icon-btn {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: #f4f4f1; }

.btn {
  min-height: 52px; padding: 0 18px;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer;
  transition: background-color .12s, color .12s;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #333; }
.btn:focus-visible, .icon-btn:focus-visible, .key:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Spielfeld ---------- */
.board-wrap {
  flex: 1; min-height: 0;
  padding: 16px 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.board { display: grid; gap: var(--gap, 6px); }
.board-row { display: grid; grid-auto-flow: column; grid-auto-columns: var(--tile, 56px); gap: var(--gap, 6px); }

.tile {
  width: var(--tile, 56px); height: var(--tile, 56px);
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--tile, 56px) * .5); line-height: 1;
  user-select: none; -webkit-user-select: none;
}
.tile.is-filled { border-color: var(--ink); }
.tile.is-c { background: var(--c); border-color: var(--c); color: #fff; }
.tile.is-p { background: var(--p); border-color: var(--p); color: var(--ink); }
.tile.is-a { background: var(--a); border-color: var(--a); color: #fff; }

.tile.pop { animation: pop .1s ease-out; }
.tile.flip { animation: flip .5s ease-in-out; }
.tile.bounce { animation: bounce .9s ease; }
.board-row.shake { animation: shake .45s; }

@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(-90deg); } 100% { transform: rotateX(0); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
@keyframes bounce {
  0%, 20% { transform: translateY(0); }
  40% { transform: translateY(-30%); }
  50% { transform: translateY(5%); }
  60% { transform: translateY(-15%); }
  80% { transform: translateY(2%); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .tile, .board-row { animation: none !important; }
}

/* ---------- Tastatur ---------- */
.keyboard {
  flex-shrink: 0;
  padding: 10px 6px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 7px;
  border-top: 1px solid var(--line);
  user-select: none; -webkit-user-select: none;
}
.kb-row { display: flex; gap: 5px; }
.key {
  flex: 1 1 0; min-width: 0; height: 56px; padding: 0;
  border: 0; border-radius: var(--radius);
  background: var(--key); color: var(--ink);
  font-weight: 600; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s;
}
.key:active { background: var(--key-active); }
.key-wide { flex-grow: 1.6; font-size: 13px; }
.key.is-c { background: var(--c); color: #fff; }
.key.is-p { background: var(--p); color: var(--ink); }
.key.is-a { background: var(--a); color: #fff; }
@media (max-width: 360px) {
  .kb-row { gap: 4px; }
  .key { font-size: 15px; }
  .key-wide { font-size: 12px; }
}
@media (max-height: 640px) {
  .key { height: 48px; }
  .keyboard { gap: 6px; padding-top: 8px; }
}

/* ---------- Mini-Kacheln (Regeln, Lösung) ---------- */
.minis { display: flex; flex-wrap: wrap; gap: 4px; }
.mini {
  width: 34px; height: 34px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
.mini.is-c { background: var(--c); border-color: var(--c); color: #fff; }
.mini.is-p { background: var(--p); border-color: var(--p); color: var(--ink); }
.mini.is-a { background: var(--a); border-color: var(--a); color: #fff; }
.minis-big .mini { width: 38px; height: 38px; font-size: 21px; }
@media (max-width: 400px) {
  .minis-big .mini { width: 30px; height: 30px; font-size: 17px; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(17, 17, 17, .6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh;
  background: var(--paper); display: flex; flex-direction: column;
  border-top: 1px solid var(--ink);
}
@media (min-width: 600px) {
  .overlay { align-items: center; }
  .sheet { border: 1px solid var(--ink); border-radius: var(--radius); }
}
.sheet-top {
  height: 56px; flex-shrink: 0;
  padding: 0 8px 0 var(--pad);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.sheet-body {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px var(--pad) 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.sheet-actions {
  flex-shrink: 0;
  padding: 12px var(--pad) calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--line);
}
.sheet-actions .btn { flex: 1; }

.example { display: flex; flex-direction: column; gap: 6px; }

.solution { display: flex; flex-direction: column; gap: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.stat { padding: 12px 0 0; display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

.block { display: flex; flex-direction: column; gap: 8px; }
.block-head { font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding-bottom: 6px; border-bottom: 1px solid var(--ink); }
.dist { display: flex; flex-direction: column; gap: 5px; }
.dist-row { display: flex; align-items: center; gap: 10px; }
.dist-no { width: 12px; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.dist-track { flex: 1; min-width: 0; }
.dist-bar {
  min-width: 28px; width: fit-content; height: 24px; padding: 0 8px;
  background: var(--key); border-radius: 2px;
  display: flex; align-items: center; justify-content: flex-end;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
}
.dist-bar.is-me { background: var(--c); color: #fff; }

.countdown { display: flex; flex-direction: column; gap: 0; flex: 1; }
.countdown-time { font-size: 24px; font-weight: 500; line-height: 1.2; }

.toast {
  position: fixed; left: 50%; top: 72px; transform: translateX(-50%);
  z-index: 3000; max-width: calc(100% - 32px);
  padding: 12px 16px; background: var(--ink); color: var(--paper); border-radius: var(--radius);
  font-size: 15px; font-weight: 600; text-align: center;
  pointer-events: none;
}
