/* WORDWELL — Level 58. Daily word puzzle. Retro-arcade dark, matches The Lab chrome. */

@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/press-start-2p.woff2") format("woff2");
}
@font-face {
  font-family: "Press Start 2P Fallback";
  src: local("Courier New");
  size-adjust: 166.64%;
  ascent-override: 60%;
  descent-override: 0%;
  line-gap-override: 0%;
}

:root {
  color-scheme: dark;

  --bg: #0a0a12;
  --surface: #12121d;
  --surface-2: #1a1a2a;
  --line: #28283c;
  --line-strong: #3a3a55;
  --text: #e9e9f2;
  --dim: #9aa0b5;

  --cyan: #45f0ff;
  --magenta: #ff3d8b;
  --gold: #ffc857;
  --green: #41ff8b;
  --red: #ff5560;

  /* Semantic puzzle states — green = in place, gold = in word, slate = out. */
  --correct: #2fd673;
  --correct-glow: rgba(65, 255, 139, 0.55);
  --present: #f0a92c;
  --present-glow: rgba(255, 200, 87, 0.5);
  --absent: #313146;
  --absent-text: #6b7185;

  --pixel: "Press Start 2P", "Press Start 2P Fallback", "Courier New", monospace;
  --body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;

  --glow-cyan: 0 0 14px rgba(69, 240, 255, 0.35);
  --space-gutter: clamp(14px, 4vw, 40px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 480px at 50% -8%, rgba(69, 240, 255, 0.06), transparent 70%),
    radial-gradient(700px 520px at 50% 118%, rgba(255, 61, 139, 0.05), transparent 72%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: rgba(69, 240, 255, 0.3);
}

[hidden] {
  display: none !important;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--cyan);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(69, 240, 255, 0.15);
  border-radius: 4px;
}

/* ---------- skip + lab link ---------- */

.skip-link {
  position: absolute;
  left: 12px;
  top: -56px;
  z-index: 200;
  background: var(--cyan);
  color: #05050d;
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-normal) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(68px);
}

.lab-link {
  position: fixed;
  left: var(--space-gutter);
  top: 16px;
  z-index: 120;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--dim);
  text-decoration: none;
  padding: 8px 6px;
  letter-spacing: 1px;
  transition: color var(--duration-fast), text-shadow var(--duration-fast), transform var(--duration-fast) var(--ease-out);
}

.lab-link:hover,
.lab-link:focus-visible {
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
  transform: translateX(-3px);
}

/* ---------- header / chrome ---------- */

.site-header {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 64px var(--space-gutter) 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-block {
  min-width: 0;
}

.level {
  margin: 0;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 200, 87, 0.3);
}

.wordmark {
  margin: 8px 0 6px;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: clamp(26px, 7vw, 44px);
  letter-spacing: 2px;
  line-height: 1.05;
  color: var(--text);
  text-shadow: 0 0 18px rgba(69, 240, 255, 0.5), 3px 3px 0 var(--magenta);
}

.wordmark__well {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(69, 240, 255, 0.6), 3px 3px 0 rgba(255, 61, 139, 0.55);
}

.tagline {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
}

.eyebrow {
  margin: 0;
}

.cursor {
  color: var(--cyan);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ---------- language toggle ---------- */

.language-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.language-button {
  min-width: 2.75rem;
  min-height: 2.5rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--dim);
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  transition: color var(--duration-fast), background-color var(--duration-fast), box-shadow var(--duration-fast);
}

.language-button:hover {
  color: var(--text);
}

.language-button.is-active {
  background: var(--cyan);
  color: #05050d;
  box-shadow: 0 0 16px rgba(69, 240, 255, 0.4);
}

/* ---------- layout ---------- */

.app-shell {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 8px var(--space-gutter) 56px;
}

.game-panel {
  display: grid;
  gap: 1.25rem;
}

/* ---------- meta + stats ---------- */

.game-meta {
  display: grid;
  gap: 1rem;
  align-items: end;
}

.game-meta__title h2 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text);
}

.date-label {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 1px;
  color: var(--dim);
}

.stats-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
}

.stat {
  min-width: 0;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface) 70%);
  padding: 0.7rem 0.5rem 0.6rem;
  text-align: center;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--line-strong);
}

.stat--streak::before {
  background: var(--gold);
  box-shadow: 0 0 10px rgba(255, 200, 87, 0.5);
}

.stat--best::before {
  background: var(--magenta);
}

.stat--attempts::before {
  background: var(--cyan);
}

.stat dt {
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
}

.stat dd {
  margin: 0.45rem 0 0;
  font-family: var(--pixel);
  font-size: clamp(13px, 4vw, 17px);
  color: var(--text);
}

.stat--streak dd {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 200, 87, 0.35);
}

/* ---------- board ---------- */

.board-frame {
  position: relative;
  width: 100%;
  max-width: 21rem;
  margin: 0 auto;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(69, 240, 255, 0.05), transparent 60%),
    var(--surface);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 18px 40px rgba(0, 0, 0, 0.4);
}

.board {
  display: grid;
  width: 100%;
  gap: 0.4rem;
  margin: 0 auto;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--pixel);
  font-size: clamp(1rem, 6vw, 1.4rem);
  line-height: 1;
  text-transform: uppercase;
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.tile.is-filled {
  border-color: var(--line-strong);
  animation: tile-pop var(--duration-fast) var(--ease-back);
}

@keyframes tile-pop {
  0% {
    transform: scale(0.86);
  }
  100% {
    transform: scale(1);
  }
}

.tile.is-correct,
.tile.is-present,
.tile.is-absent {
  color: #05050d;
  animation: tile-flip 0.5s var(--ease-out) both;
}

@keyframes tile-flip {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

/* Stagger the reveal across the row for an arcade cascade. */
.board-row .tile:nth-child(1) { animation-delay: 0ms; }
.board-row .tile:nth-child(2) { animation-delay: 90ms; }
.board-row .tile:nth-child(3) { animation-delay: 180ms; }
.board-row .tile:nth-child(4) { animation-delay: 270ms; }
.board-row .tile:nth-child(5) { animation-delay: 360ms; }

.tile.is-correct {
  border-color: var(--correct);
  background: var(--correct);
  box-shadow: 0 0 18px var(--correct-glow);
}

.tile.is-present {
  border-color: var(--present);
  background: var(--present);
  box-shadow: 0 0 16px var(--present-glow);
}

.tile.is-absent {
  border-color: var(--absent);
  background: var(--absent);
  color: var(--absent-text);
  box-shadow: none;
}

/* ---------- message ---------- */

.message {
  min-height: 1.6rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-align: center;
  color: var(--dim);
}

.message.is-error {
  color: var(--red);
  animation: nudge 0.32s ease;
}

.message.is-success {
  color: var(--green);
  text-shadow: 0 0 14px var(--correct-glow);
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------- actions ---------- */

.action-row {
  display: flex;
  justify-content: center;
}

.primary-action {
  min-height: 2.75rem;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  background: var(--cyan);
  color: #05050d;
  padding: 0.6rem 1.4rem;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  box-shadow: 0 0 22px rgba(69, 240, 255, 0.35);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out), background-color var(--duration-fast);
}

.primary-action:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 0 32px rgba(69, 240, 255, 0.55);
}

.primary-action:not(:disabled):active {
  transform: translateY(1px);
}

.primary-action:disabled {
  border-color: var(--line);
  background: transparent;
  color: var(--dim);
  box-shadow: none;
}

.share-output {
  width: 100%;
  min-height: 8rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 0.75rem;
  font-family: var(--mono);
  line-height: 1.7;
}

/* ---------- keyboard ---------- */

.keyboard {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  max-width: 30rem;
  margin: 0.25rem auto 0;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}

.key-row.is-short {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  justify-self: center;
  width: min(100%, 16rem);
}

.key-row.is-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.2rem;
}

.key {
  min-width: 0;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--text);
  padding: 0.4rem 0.25rem;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  transition: transform var(--duration-fast) var(--ease-out), border-color var(--duration-fast), color var(--duration-fast);
}

.key:hover {
  border-color: var(--line-strong);
  color: var(--cyan);
}

.key:active {
  transform: translateY(2px);
  box-shadow: none;
}

.key.is-wide {
  min-height: 3rem;
  font-size: 10px;
}

.key.is-correct,
.key.is-present,
.key.is-absent {
  color: #05050d;
  background-image: none;
}

.key.is-correct {
  border-color: var(--correct);
  background: var(--correct);
  box-shadow: 0 0 14px var(--correct-glow);
}

.key.is-present {
  border-color: var(--present);
  background: var(--present);
  box-shadow: 0 0 12px var(--present-glow);
}

.key.is-absent {
  border-color: var(--absent);
  background: var(--absent);
  color: var(--absent-text);
  box-shadow: none;
}

.key.is-correct:hover,
.key.is-present:hover {
  color: #05050d;
}

.key.is-absent:hover {
  color: var(--absent-text);
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px var(--space-gutter) 28px;
  text-align: center;
  display: grid;
  gap: 0.9rem;
  justify-items: center;
}

.crt-toggle {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1.5px;
  background: transparent;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.7rem 0.85rem;
  transition: color var(--duration-fast), border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.crt-toggle:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

.crt-toggle[aria-pressed="true"] {
  color: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 12px rgba(65, 255, 139, 0.35);
}

.site-footer__by {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--dim);
}

.site-footer__by a {
  text-decoration: none;
}

.site-footer__by a:hover {
  text-decoration: underline;
  text-shadow: var(--glow-cyan);
}

/* ---------- CRT mode ---------- */

body.crt::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}

body.crt::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 56%, rgba(0, 0, 0, 0.4) 100%);
  box-shadow: inset 0 0 130px rgba(69, 240, 255, 0.07);
}

/* ---------- responsive ---------- */

@media (min-width: 600px) {
  .game-meta {
    grid-template-columns: 1fr minmax(16rem, 21rem);
  }

  .board-frame {
    max-width: 22rem;
  }
}

@media (max-width: 420px) {
  .site-header {
    padding-top: 58px;
  }

  .wordmark {
    text-shadow: 0 0 14px rgba(69, 240, 255, 0.5), 2px 2px 0 var(--magenta);
  }

  .stat dt {
    font-size: 6px;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cursor {
    animation: none;
  }

  .tile.is-filled,
  .tile.is-correct,
  .tile.is-present,
  .tile.is-absent {
    animation: none !important;
  }
}
