:root {
  --ink: #1a1a1a;
  --ink-muted: #6b6b6b;
  --ink-faint: #6d6d6d; /* was #b0b0b0 — failed WCAG contrast on white */
  --surface: #faf9f6;
  --surface-card: #ffffff;
  --surface-hover: #f2f0eb;
  --accent: #9b2226;
  --accent-light: #fce8e8;
  --correct: #2d6a4f;
  --correct-bg: #d8f0e6;
  --present: #8a6a00;
  --present-bg: #fef3cd;
  --absent: #686868;
  --absent-bg: #ebebeb;
  --border: rgba(26,26,26,0.1);
  --border-strong: rgba(26,26,26,0.2);
  --radius: 4px;
  --radius-lg: 12px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 249, 246, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.header-logo span { color: var(--accent); }
nav a {
  font-size: 0.875rem;
  color: var(--ink-muted);
  text-decoration: none;
  display: inline-block;
  padding: 10px 14px;
  border-radius: 100px;
  transition: all 0.2s var(--ease);
}
nav a:hover { color: var(--ink); background: var(--surface-hover); }

/* ── Hero ── */
.hero {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 48px 40px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.hero-eyebrow::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  line-height: 1.0;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}
.hero h1 em { font-style: italic; color: var(--accent); }
.hero-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink-muted);
  max-width: 520px;
  font-weight: 300;
}

.hero-rule {
  width: calc(100% - 96px);
  max-width: 764px;
  margin: 0 auto;
  height: 1px;
  background: linear-gradient(90deg, var(--border-strong) 0%, transparent 100%);
  position: relative;
  z-index: 1;
}

/* ── Game layout ── */
.game-layout {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Top bar ── */
.game-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar-controls { display: flex; gap: 8px; }
.topbar-toggles  { display: flex; gap: 16px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn-ghost {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  color: var(--ink-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  padding: 9px 14px;
  min-height: 36px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink); }

/* ── Toggle ── */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
/* Visually hidden but still keyboard-focusable (display:none removed it
   from the tab order) */
.toggle { position: relative; min-height: 32px; }
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.toggle input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.toggle-track {
  width: 34px;
  height: 18px;
  background: var(--border-strong);
  border-radius: 100px;
  position: relative;
  transition: background 0.2s var(--ease);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-track { background: var(--ink); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle-label { font-size: 0.8rem; color: var(--ink-muted); }

/* ── Info strip ── */
.info-strip {
  width: 100%;
  min-height: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.info-text {
  font-size: 0.9rem;
  color: var(--ink-muted);
  text-align: center;
}
.target-word {
  font-family: 'Amiri', serif;
  font-size: 2rem;
  color: var(--ink);
  direction: rtl;
  animation: fadeUp 0.3s var(--ease) both;
}
.hint-text { color: var(--present); }

/* ── Guess grid ── */
.guess-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.guess-row {
  display: flex;
  gap: 6px;
  direction: rtl;
  justify-content: center;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60%  { transform: translateX(-5px); }
  40%, 80%  { transform: translateX(5px); }
}
.guess-row.shake { animation: shake 280ms ease-in-out; }

/* ── Letter box ── */
.letter-box {
  /* Shrinks on narrow phones so a 7-letter row still fits at 360px */
  width: clamp(36px, 11vw, 52px);
  height: clamp(36px, 11vw, 52px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: 'Amiri', serif;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-card);
  color: var(--ink);
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.12s;
}
.letter-box.filled {
  border-color: var(--ink-muted);
  animation: pop 0.12s var(--ease);
}
@keyframes pop {
  50% { transform: scale(1.08); }
}

.letter-box.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
}
.letter-box.present {
  background: var(--present-bg);
  border-color: var(--present);
  color: var(--present);
}
.letter-box.absent {
  background: var(--absent-bg);
  border-color: transparent;
  color: var(--absent);
}

/* ── Keyboard ── */
.keyboard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  direction: rtl;
  width: 100%;
  max-width: 480px;
}

.key {
  font-family: 'Amiri', serif;
  color: var(--ink);
  font-size: 1.1rem;
  min-width: 36px;
  height: 44px;
  padding: 0 8px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
}
.key:hover { background: var(--surface-hover); }
.key-enter { background: var(--ink); color: #fff; border-color: var(--ink); }
.key-enter:hover { background: var(--accent); }

.kbd-hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-align: center;
}
.kbd-hint kbd {
  font-family: inherit;
  font-size: 0.7rem;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-card);
}
.key:active, .key.pressed {
  transform: translateY(1px) scale(0.97);
  filter: brightness(0.95);
}

.key.correct { background: var(--correct-bg);  border-color: var(--correct);  color: var(--correct); }
.key.present { background: var(--present-bg);  border-color: var(--present);  color: var(--present); }
.key.absent  { background: var(--absent-bg);   border-color: transparent;     color: var(--absent);  }

.key-control {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  min-width: 64px;
  border-radius: var(--radius);
}
.key-control:not(.key-enter) { background: var(--surface-hover); }

/* ── Hidden native input ── */
.sr-only-input {
  position: fixed;
  top: -1000px;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  pointer-events: none;
}

/* ── Footer ── */
footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 28px 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  direction: ltr;
}
footer p { font-size: 0.8rem; color: var(--ink-faint); }
footer a { color: var(--ink-muted); text-decoration: none; font-size: 0.8rem; }
footer a:hover { color: var(--ink); }

/* ── Mobile ── */
@media (max-width: 560px) {
  header { padding: 0 20px; }
  .hero { padding: 44px 20px 36px; }
  .hero-rule { width: calc(100% - 40px); }
  .game-layout { padding: 24px 16px 60px; }
  .letter-box { font-size: 1.5rem; }
  .key { min-width: 32px; height: 44px; padding: 0 6px; font-size: 1.05rem; }
  .guess-row { gap: 5px; }
  footer { padding: 24px 20px; }
}