/* ===== Wordle — game UI ===== */
:root { --tile: min(17vw, 62px); --gap: 6px; }
html, body { overflow-x: hidden; }
.wrap {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
  padding: clamp(18px, 5vw, 36px) 14px 40px;
}
.head { width: 100%; max-width: calc(var(--tile) * 5 + var(--gap) * 4); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.title { margin: 0; font-size: clamp(24px, 6vw, 30px); letter-spacing: -.02em; }
.meta { display: flex; gap: 14px; font-size: 13.5px; color: var(--gc-text-muted); }
.meta__item b { color: var(--gc-text); font-variant-numeric: tabular-nums; }

/* Board */
.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: var(--gap);
  margin: 6px 0;
}
.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
}
.tile {
  width: var(--tile); height: var(--tile);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--tile) * 0.52); font-weight: 800; text-transform: uppercase;
  color: var(--gc-text);
  border: 2px solid var(--gc-border);
  border-radius: 8px;
  background: transparent;
  user-select: none;
}
.tile--filled { border-color: var(--gc-text-muted); }
.tile--pop { animation: pop .12s ease; }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* Reveal flip + states (fixed arcade colours, independent of light/dark). */
.tile--correct { background: #6aaa64; border-color: #6aaa64; color: #fff; }
.tile--present { background: #c9b458; border-color: #c9b458; color: #fff; }
.tile--absent  { background: #787c7e; border-color: #787c7e; color: #fff; }
.tile--reveal { animation: flip .5s ease forwards; }
@keyframes flip {
  0% { transform: rotateX(0); }
  50% { transform: rotateX(-90deg); }
  100% { transform: rotateX(0); }
}
/* Shake a rejected row. */
.row--shake { animation: shake .4s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* Toast */
.toast {
  min-height: 22px;
  font-size: 14px; font-weight: 600; color: var(--gc-text);
  text-align: center;
}

/* Keyboard */
.kb { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 7px; }
.kb__row { display: flex; gap: 6px; justify-content: center; }
.key {
  appearance: none; cursor: pointer; font: inherit;
  flex: 1; max-width: 46px; height: 52px;
  border-radius: 8px; border: 1px solid var(--gc-border);
  background: var(--gc-surface-2); color: var(--gc-text);
  font-size: 16px; font-weight: 700; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center;
  transition: transform .06s ease, background .15s ease, color .15s ease;
}
.key:hover { border-color: var(--gc-accent); }
.key:active { transform: translateY(1px); }
.key:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.key--wide { flex: 1.5; max-width: 66px; font-size: 12.5px; font-weight: 600; }
.key.kb__enter { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-on-accent); }
.key--correct { background: #6aaa64; border-color: #6aaa64; color: #fff; }
.key--present { background: #c9b458; border-color: #c9b458; color: #fff; }
.key--absent  { background: #3a3d40; border-color: #3a3d40; color: #9aa0a6; }

.actions { width: 100%; max-width: 500px; display: flex; gap: 8px; }
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 16px; border-radius: 10px; width: auto; flex: 1; white-space: nowrap;
  border: 1px solid var(--gc-border); background: var(--gc-surface); color: var(--gc-text);
  transition: transform .06s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--gc-accent); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--gc-ring); }
.btn--primary { background: var(--gc-accent); border-color: var(--gc-accent); color: var(--gc-on-accent); }

.sub { margin: 0; color: var(--gc-text-muted); font-size: 13px; text-align: center; }

/* Overlay */
.overlay { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; background: rgba(6, 12, 20, .55); backdrop-filter: blur(3px); padding: 16px; }
.overlay[hidden] { display: none; }
.overlay__card { width: min(92vw, 360px); text-align: center; padding: 26px 24px; border-radius: 16px; background: var(--gc-surface); border: 1px solid var(--gc-border); box-shadow: var(--gc-shadow-hi); animation: cardpop .3s ease; }
@keyframes cardpop { from { transform: scale(.9); opacity: 0; } }
.overlay__card h2 { margin: 0 0 6px; font-size: 26px; }
.overlay__card p { margin: 0 0 18px; color: var(--gc-text-muted); }
.overlay__actions { display: flex; gap: 10px; justify-content: center; }
.overlay__actions .btn { width: auto; }

/* Rules modal — the full-screen overlay scrolls, never the card itself. */
.rules { position: fixed; inset: 0; z-index: 600; display: flex; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.rules[hidden] { display: none; }
.rules__backdrop { position: fixed; inset: 0; background: rgba(6, 12, 20, .55); backdrop-filter: blur(3px); }
.rules__panel { position: relative; z-index: 1; margin: auto; width: min(92vw, 460px); padding: 24px 26px; border-radius: 16px; background: var(--gc-surface); border: 1px solid var(--gc-border); box-shadow: var(--gc-shadow-hi); }
.rules__title { margin: 0 0 12px; font-size: 22px; letter-spacing: -.01em; }
.rules__panel p { margin: 0 0 12px; color: var(--gc-text-muted); font-size: 14px; line-height: 1.55; }
.rules__legend { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rules__legend li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--gc-text-muted); }
.sw { flex: none; width: 22px; height: 22px; border-radius: 5px; display: inline-block; }
.sw--correct { background: #6aaa64; }
.sw--present { background: #c9b458; }
.sw--absent { background: #787c7e; }
.rules__actions { display: flex; justify-content: center; margin-top: 4px; }
.rules__actions .btn { width: auto; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .tile--pop, .tile--reveal, .row--shake, .overlay__card { animation: none; }
  .key, .btn { transition: none; }
}
