/* Wordle — paper & ink */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-head .sub {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.play {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(14px, 3vw, 22px);
  position: relative;
}

.aside-info { margin-top: 22px; }
.aside-info details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.aside-info summary {
  cursor: pointer;
  font: 700 14px 'Inter', sans-serif;
  color: var(--ink);
}
.aside-info .help-body {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.aside-info .help-body p { margin: 0 0 8px; }
.aside-info .help-body ul { margin: 0 0 8px; padding-left: 18px; }
.aside-info .help-body li { margin: 4px 0; }

/* Mode toggle (segmented control) */
.mode-toggle {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--shadow);
}
.mode-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 13px 'Inter', sans-serif;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
  transition: background 160ms ease, color 160ms ease;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.is-active {
  background: var(--accent);
  color: var(--paper);
}

/* Stage */
.wordle-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.4vw, 22px);
  width: 100%;
}

.streak-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.streak-pill {
  font: 600 12px 'Inter', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 999px;
}
.streak-pill strong {
  color: var(--ink);
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 14px;
  margin-left: 4px;
}
.streak-pill:empty { display: none; }

/* Board */
.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: min(100%, 340px);
  aspect-ratio: 5 / 6;
}
.board-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.board-row.is-shaking {
  animation: shake 420ms cubic-bezier(.36,.07,.19,.97);
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}

.tile {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(22px, 6vw, 32px);
  color: var(--ink);
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease;
}
.tile.is-filled {
  border-color: var(--ink-soft);
  animation: pop 140ms ease;
}
@keyframes pop {
  0% { transform: scale(0.92); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Reveal flip animation (per-tile delay applied inline) */
.tile.is-revealing {
  animation: flip 560ms ease forwards;
}
@keyframes flip {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* Result colours — desaturated forest green, warm ochre, neutral grey */
.tile.is-correct,
.key.is-correct {
  background: #4f7a52;
  border-color: #4f7a52;
  color: #fbf6ea;
}
.tile.is-present,
.key.is-present {
  background: #c69a4a;
  border-color: #c69a4a;
  color: #fbf6ea;
}
.tile.is-absent,
.key.is-absent {
  background: #8a8478;
  border-color: #8a8478;
  color: #fbf6ea;
}

/* Victory bounce — winning row hops together */
@keyframes wordle-victory-bounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(-14px); }
  60%  { transform: translateY(2px); }
  100% { transform: translateY(0); }
}
.board-row.is-victory .tile {
  animation: wordle-victory-bounce 620ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.board-row.is-victory .tile:nth-child(1) { animation-delay: 0ms; }
.board-row.is-victory .tile:nth-child(2) { animation-delay: 80ms; }
.board-row.is-victory .tile:nth-child(3) { animation-delay: 160ms; }
.board-row.is-victory .tile:nth-child(4) { animation-delay: 240ms; }
.board-row.is-victory .tile:nth-child(5) { animation-delay: 320ms; }
@media (prefers-reduced-motion: reduce) {
  .board-row.is-victory .tile { animation: none; }
}

/* Toast */
.toast {
  min-height: 22px;
  font: 600 13px 'Inter', sans-serif;
  color: var(--ink);
  background: transparent;
  padding: 0;
  text-align: center;
  letter-spacing: 0.02em;
  transition: opacity 200ms ease;
  opacity: 0;
}
.toast[data-show="true"] {
  opacity: 1;
}
.toast.is-warn {
  color: var(--danger);
}
.toast.is-ok {
  color: var(--success);
}

/* Keyboard */
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}
.kb-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}
.key {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  font: 700 14px 'Inter', sans-serif;
  text-transform: uppercase;
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  cursor: pointer;
  padding: 0 2px;
  transition: background 140ms ease, transform 100ms ease, color 140ms ease, border-color 140ms ease;
}
.key:hover { background: var(--accent-soft); }
.key:active { transform: translateY(1px); }
.key.is-wide {
  flex: 1.6 1 0;
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 42, 58, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  text-align: center;
  box-shadow: var(--shadow-lift);
  max-width: 360px;
  width: 100%;
}
.overlay-card h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.overlay-sub {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}
.overlay-grid {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  margin: 0 auto 14px;
  width: 130px;
  aspect-ratio: 5 / 6;
}
.overlay-grid .mini-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.overlay-grid .mini {
  border-radius: 3px;
  background: var(--bg-2);
  aspect-ratio: 1;
}
.overlay-grid .mini.is-correct { background: #4f7a52; }
.overlay-grid .mini.is-present { background: #c69a4a; }
.overlay-grid .mini.is-absent  { background: #8a8478; }
.overlay-meta {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
}
.overlay-meta strong {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.overlay-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Fullscreen tweaks */
body[data-fullscreen="true"] .wordle-stage {
  max-width: 560px;
  margin: 0 auto;
}

/* Mobile */
@media (max-width: 480px) {
  .board { width: min(100%, 320px); }
  .key { height: 48px; font-size: 13px; padding: 0 1px; }
  .key.is-wide { font-size: 10px; }
  .kb-row { gap: 3px; }
  .keyboard { gap: 4px; }
  .head-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 360px) {
  .tile { font-size: 22px; }
  .key { height: 40px; }
}
