:root {
    --bg: #121213;
    --fg: #ffffff;
    --muted: rgba(255,255,255,.75);
    --border: #3a3a3c;
    --border-filled: #565758;
  
    --tile-absent: #3a3a3c;
  
    --tile-present: #F5A623;
    --tile-correct: #005CB9;
  
    --key-bg: #818384;
    --key-fg: #ffffff;
    --key-bg-weak: #565758;

  /* keyboard sizing (fluid) */
    --key-h: 52px;
    --key-gap: 8px;
    --key-radius: 10px;
    --key-font: 14px;
    --focus: rgba(255,255,255,.25);
  }
  
  html[data-theme="light"] {
    --bg: #f5f6f7;
    --fg: #101114;
    --muted: rgba(16,17,20,.7);
    --border: #d0d3d6;
    --border-filled: #a7abb0;
  
    --tile-absent: #a7abb0;
  
    --tile-present: #F5A623;
    --tile-correct: #0066CC;
  
    --key-bg: #d0d3d6;
    --key-fg: #101114;
    --key-bg-weak: #a7abb0;
  
    --focus: rgba(16,17,20,.15);
  }
  * { box-sizing: border-box; }
  
  body {
    margin: 0;
    min-height: 100vh;
    font-family: "Gotham", "Montserrat", system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
  }
  
  .topbar {
    max-width: 520px;
    margin: 0 auto;
    padding: 18px 16px 8px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
  }
  
  .brand h1 {
    margin: 0;
    letter-spacing: 0.22em;
    font-size: 28px;
  }
  
  .brand p {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--muted);
  }
  
  .wrap {
    max-width: 520px;
    margin: 0 auto;
    padding: 8px 16px 24px;
  }
  
  .board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
    justify-content: center;
    padding: 12px 0;
  }
  
  .row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  
  .tile {
    width: 56px;
    height: 56px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    text-transform: uppercase;
    user-select: none;
  }
  
  @media (max-width: 420px) {
    .tile { width: 48px; height: 48px; font-size: 26px; }
  }
  
  .tile.filled { border-color: var(--border-filled); }
  
  .tile.correct { background: var(--tile-correct); border-color: var(--tile-correct); color: #fff; }
  .tile.present { background: var(--tile-present); border-color: var(--tile-present); color: #fff; }
  .tile.absent  { background: var(--tile-absent);  border-color: var(--tile-absent);  color: #fff; }
  
  .below { display: grid; gap: 18px; justify-items: center; }
  
  .message {
    min-height: 24px;
    text-align: center;
    color: var(--muted);
  }
  
  .controls {
    display: flex;
    justify-content: center;
    gap: 10px;
  }
  
  .btn {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--tile-correct);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
  }
  
  .btn:disabled { opacity: .55; cursor: not-allowed; }
  
  .btn-secondary {
    background: transparent;
    border-color: var(--border);
    color: var(--fg);
  }
  
  .keyboard-wrap {
    width: 100%;
    padding-top: 18px;
    display: flex;
    justify-content: center;
  }
  
  .keyboard {
    width: min(500px, 100%);
    display: grid;
    gap: var(--key-gap);
    margin: 0 auto;
  }
  
  .krow,
  .key-row {
    display: flex;
    gap: var(--key-gap);
    justify-content: center;
    width: 100%;
  }
  
  /* Make keys fluid: each row spreads evenly and stays on-screen */
  .key {
    background: var(--key-bg);
    color: var(--key-fg);
    border: none;
    border-radius: var(--key-radius);
    height: var(--key-h);
    padding: 0 10px;
  
    /* Fluid sizing magic */
    flex: 1 1 0;                  /* distribute evenly across row */
    min-width: 0;                 /* allow shrinking without overflow */
    max-width: 48px;              /* keeps keys from getting huge on desktop */
  
    font-weight: 800;
    font-size: var(--key-font);
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
  
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  
  .key.wide {
    flex: 1.5 1 0;                /* wider than letters */
    max-width: 78px;
    font-size: 12px;
    letter-spacing: .02em;
  }
  
  .key:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
  
  .key.correct { background: var(--tile-correct); color: #fff; }
  .key.present { background: var(--tile-present); color: #fff; }
  .key.absent  { background: var(--tile-absent);  color: #fff; }
  
  /* Mobile: make keyboard bigger but still fit */
  @media (max-width: 480px) {
    :root {
      --key-h: 58px;
      --key-gap: 7px;
      --key-font: 15px;
    }
  
    .keyboard {
      width: 100%;
    }
  
    .key {
      max-width: 999px;           /* allow them to expand to fill row */
    }
  
    .key.wide {
      max-width: 999px;
      flex: 1.9 1 0;
      font-size: 12px;
    }
  }
  
  /* Very small phones: tighten a bit so it never overflows */
  @media (max-width: 360px) {
    :root {
      --key-h: 52px;
      --key-gap: 6px;
      --key-font: 14px;
    }
  
    .key {
      padding: 0 8px;
    }
  }

  .topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  
  .icon-btn:focus-visible,
  .modal-close:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
  
  /* Modal */
  .modal.hidden {
    display: none;
  }
  
  .modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
  }
  
  .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
  }
  
  .modal-card {
    position: relative;
    z-index: 1001;
    width: min(92vw, 420px);
    margin: 10vh auto 0;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px 18px 18px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  }
  
  .modal-card h2 {
    margin: 0 32px 14px 0;
    font-size: 22px;
    text-align: center;
  }  
  .modal-credit p { 
    text-align: center;
  }
  .modal-card p {
    margin: 10px 0;
    line-height: 1.45;
  }
  
  .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: transparent;
    color: var(--fg);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
  }
  
  .help-example {
    display: flex;
    gap: 8px;
    margin: 16px auto 14px;
    justify-content: center;
    align-items: center;
  }
  
  .help-tile {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 22px;
    color: #fff;
    background: var(--border);
    border: 2px solid var(--border);
    transform-origin: center;
    backface-visibility: hidden;
    will-change: transform;
  }
  
  .help-tile.help-correct {
    background: var(--tile-correct);
    border-color: var(--tile-correct);
  }
  
  .help-tile.help-present {
    background: var(--tile-present);
    border-color: var(--tile-present);
  }
  
  .help-tile.help-absent {
    background: var(--tile-absent);
    border-color: var(--tile-absent);
  }
  
  
  .modal-credit {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
  }
  
  .modal-credit p {
    margin: 4px 0;
  }
  
  body.modal-open {
    overflow: hidden;
  }
  /* ---------- Tile animation helpers ---------- */
.tile {
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform;
}

/* Pop when typing a letter */
.tile.pop {
  animation: tilePop 120ms ease-out;
}

/* Shake for invalid / incomplete word */
.row.shake {
  animation: rowShake 420ms ease-in-out;
}

/* Flip on reveal */
.tile.flip {
  animation: tileFlip 600ms ease-in-out;
}

/* Win bounce wave */
.tile.bounce {
  animation: tileBounce 500ms ease-out;
}

/* ---------- Keyframes ---------- */
@keyframes tilePop {
  0% {
    transform: scale(0.92);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tileFlip {
  0% {
    transform: rotateX(0);
  }
  45% {
    transform: rotateX(90deg);
  }
  55% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0);
  }
}

@keyframes tileBounce {
  0% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-12px);
  }
  55% {
    transform: translateY(0);
  }
  70% {
    transform: translateY(-4px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes rowShake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}

  /* helps prevent “double tap zoom” delays on mobile buttons */
  .key, .btn { touch-action: manipulation; }
