@font-face {
  font-family: "Kedebideri";
  src: url("fonts/Kedebideri-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Kedebideri";
  src: url("fonts/Kedebideri-Bold.woff2") format("woff2");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "Kedebideri", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #fffdf3;
  --surface: #ffffff;
  --ink: #1d1d1b;
  --muted: #6d6a5c;
  --line: #e4dfc8;
  --honey: #f7da21;
  --honey-ink: #1d1d1b;
  --hex: #e9e6d6;
  --hex-active: #d7d3bd;
  --good: #1f7a3d;
  --bad: #b3261e;
  --pangram: #c47f00;
  --shadow: 0 6px 24px rgba(0, 0, 0, .15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171611;
    --surface: #24231b;
    --ink: #f3efdc;
    --muted: #a9a58f;
    --line: #3a3829;
    --hex: #3a3829;
    --hex-active: #4b4936;
    --good: #66d18a;
    --bad: #ff8a80;
    --pangram: #ffc84a;
    --shadow: 0 6px 24px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button, .hex { user-select: none; -webkit-user-select: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 8px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* ---------- Kop ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--line);
}
.top h1 {
  margin: 0;
  font: 700 1.6rem/1.1 var(--font);
  letter-spacing: -.01em;
}
.puzzle-label { grid-column: 1 / -1; grid-row: 2; color: var(--muted); font-size: .85rem; margin-top: 2px; }
.menu { grid-column: 2; grid-row: 1; display: flex; gap: 14px; align-self: center; }
.link-btn {
  background: none; border: 0; padding: 6px 0; font-size: .92rem; color: var(--ink);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line);
}
.link-btn:hover { text-decoration-color: var(--ink); }

/* ---------- Voortgang ---------- */
.progress { padding: 14px 0 6px; }
.rank-line { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.rank-line strong { font-size: 1.1rem; }
.score-text { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }

.track { position: relative; display: flex; justify-content: space-between; align-items: center; height: 26px; }
.track::before { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: var(--line); transform: translateY(-50%); }
.dot { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); z-index: 1; transition: background .3s, border-color .3s; }
.dot.done { background: var(--honey); border-color: var(--honey); }
.dot.current {
  width: auto; min-width: 30px; height: 26px; padding: 0 7px; border-radius: 13px;
  background: var(--honey); border-color: var(--honey); color: var(--honey-ink);
  font-size: .8rem; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.dot.last { border-radius: 4px; transform: rotate(45deg) scale(.85); }
.dot.last.current { transform: none; border-radius: 13px; }

/* ---------- Gevonden woorden ---------- */
.found { margin: 10px 0 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.found-head {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: none; border: 0; text-align: left;
}
.found-count { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.found-preview { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.chevron { transition: transform .2s; color: var(--muted); }
.found-head[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.found-list {
  list-style: none; margin: 0; padding: 4px 14px 14px;
  columns: 2; column-gap: 20px; max-height: 40vh; overflow: auto; border-top: 1px solid var(--line);
}
.found-list[hidden] { display: none; }
.found-list li { padding: 5px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.found-list li.pangram { font-weight: 700; color: var(--pangram); }
.found-list li.pangram::after { content: " ★"; }
.found-list li.missed { color: var(--muted); }
.found-list li.missed.pangram { color: var(--pangram); opacity: .75; }

/* ---------- Spel ---------- */
.game { display: flex; flex-direction: column; align-items: center; }

.toast {
  min-height: 34px; margin-top: 10px; display: flex; align-items: center; justify-content: center;
}
.toast span {
  display: inline-block; padding: 5px 14px; border-radius: 8px; font-weight: 700; font-size: .95rem;
  background: var(--ink); color: var(--bg); animation: pop .18s ease-out;
}
.toast span.good { background: var(--good); color: #fff; }
.toast span.pangram { background: var(--honey); color: var(--honey-ink); }
.toast span.bad { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

.input {
  min-height: 52px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  font: 700 2rem/1.2 var(--font); text-transform: uppercase; letter-spacing: .04em;
  max-width: 100%; word-break: break-all;
}
.input .c { color: #d6aa00; }
@media (prefers-color-scheme: dark) { .input .c { color: var(--honey); } }
.input .x { color: var(--muted); opacity: .6; }
.input::after {
  content: ""; width: 2px; height: 1.6rem; margin-left: 3px; background: var(--honey);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.input.shake { animation: shake .3s; }
@keyframes shake { 20% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 80% { transform: translateX(-4px); } }

.hive { position: relative; width: min(100%, 300px, 52dvh); aspect-ratio: 100 / 103.92; margin: 12px auto 18px; }
.hex {
  position: absolute; border: 0; padding: 0; background: var(--hex);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  font: 700 1.9rem/1 var(--font); text-transform: uppercase;
  display: grid; place-items: center; transition: transform .08s, background .15s;
}
.hex:active, .hex.press { transform: scale(.93); background: var(--hex-active); }
.hex.center { background: var(--honey); color: var(--honey-ink); }
.hex.center:active, .hex.center.press { background: #e5c800; }
.hex:focus-visible { outline: none; background: var(--hex-active); box-shadow: inset 0 0 0 3px var(--ink); }

.actions { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; }
.pill, .round {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  min-height: 48px; padding: 0 22px; transition: background .12s, transform .08s;
}
.pill:hover, .round:hover { background: var(--hex); }
.pill:active, .round:active { transform: scale(.96); }
.pill.primary { background: var(--honey); border-color: var(--honey); color: var(--honey-ink); font-weight: 700; }
.pill.wide { width: 100%; }
.round { width: 48px; padding: 0; display: grid; place-items: center; }

/* ---------- Voet ---------- */
.foot { max-width: 480px; margin: 0 auto; padding: 8px 16px 28px; text-align: center; }
.foot .link-btn { margin: 0 10px; }
.small { font-size: .8rem; color: var(--muted); }
.small a { color: inherit; }

/* ---------- Dialogen ---------- */
dialog {
  width: min(92vw, 440px); max-height: 86dvh; overflow: auto; padding: 22px 22px 24px;
  border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 6px; font: 700 1.5rem/1.2 var(--font); padding-right: 30px; }
dialog h3 { margin: 18px 0 6px; font-size: 1rem; }
dialog .lead { margin: 0 0 12px; color: var(--muted); }
dialog ul { padding-left: 20px; margin: 8px 0 14px; }
dialog li { margin: 4px 0; }
dialog .close {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; background: none;
  font-size: 1.8rem; line-height: 1; color: var(--muted);
}
dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
dialog .stack { display: grid; gap: 10px; margin-top: 12px; }
dialog ul.found-list { padding: 4px 0 0; max-height: none; border-top: 0; }
kbd { background: var(--hex); border-radius: 4px; padding: 1px 6px; font: inherit; font-size: .85em; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; text-align: center; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { font-weight: 700; color: var(--muted); }
th[scope="row"] { text-align: left; text-transform: uppercase; }
td.zero { color: var(--muted); }
.pairs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; text-transform: uppercase; }
.pairs b { color: var(--muted); font-weight: 600; }

.days { list-style: none; padding: 0 !important; margin: 6px 0 0 !important; }
.days li { margin: 0; }
.days button {
  width: 100%; display: flex; justify-content: space-between; gap: 10px; padding: 11px 4px;
  background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left;
}
.days button:hover { background: var(--hex); }
.days .when { text-transform: capitalize; }
.days .state { color: var(--muted); font-size: .9rem; }
.days .state.queen { color: var(--pangram); font-weight: 700; }

.goto { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.goto label { flex-basis: 100%; font-size: .9rem; color: var(--muted); }
.goto input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font: inherit;
}

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