:root {
  color-scheme: dark;
  --background: #17151f;
  --surface: #252230;
  --line: #464052;
  --ink: #fbf8ff;
  --muted: #c8bed5;
  --accent: #d9c7ff;
  --correct: #5fdaac;
  --present: #f2ce76;
  --absent: #4b4458;
  font-family: Inter, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 0%, #2d233d 0, var(--background) 55%);
  color: var(--ink);
}

button, a { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }

.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner {
  width: min(100%, 960px);
  min-height: 65px;
  margin: auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  font-size: 1.35rem;
  font-weight: 800;
  text-decoration: none;
}
.brand-tile {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 8px;
  background: var(--correct);
  color: #10291f;
}
.brand-dot { color: var(--correct); }

nav { display: flex; gap: 4px; }
.quiet {
  padding: 7px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}
.quiet:hover { background: var(--surface); color: var(--ink); }

main {
  width: min(100%, 550px);
  flex: 1;
  display: grid;
  place-items: center;
  margin: 0 auto;
  padding: 24px 14px;
}
.welcome { text-align: center; }
.welcome h1 { font-size: clamp(1.9rem, 6.5vw, 3.2rem); margin: 20px 0 6px; }
.welcome > p, dialog p { color: var(--muted); line-height: 1.55; }

.wordmark {
  display: flex;
  justify-content: center;
  gap: clamp(5px, 2vw, 10px);
}
.wordmark span {
  display: grid;
  place-items: center;
  width: clamp(40px, 12vw, 66px);
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: clamp(1.4rem, 5vw, 2.25rem);
  font-weight: 800;
}
.wordmark span:nth-child(2) { background: var(--present); color: #342607; }
.wordmark span:nth-child(5) { background: var(--correct); color: #10291f; }

.action {
  display: inline-block;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: #211437;
  font-weight: 800;
  text-decoration: none;
}
.action:hover { background: #ebdfff; }

.game { width: 100%; text-align: center; }
.game-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 auto 16px;
  text-align: left;
}
.game-heading h1 { margin: 3px 0 0; font-size: clamp(1.2rem, 5vw, 1.8rem); }
.eyebrow { margin: 0; color: var(--muted); font-size: .74rem; font-weight: 700; }
.profile { display: flex; align-items: center; gap: 7px; min-width: 0; }
.profile img { border-radius: 50%; }
.profile-info { display: grid; justify-items: end; min-width: 0; }
.profile-info span { max-width: min(28vw, 135px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 700; }

.board {
  width: min(100%, 310px, 54dvh);
  margin: auto;
  display: grid;
  gap: 6px;
}
.board-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: clamp(1.15rem, 7vw, 2rem);
  font-weight: 800;
  line-height: 1;
}
.tile[data-active] { border-color: #807293; }
.tile[data-active]:not(:empty) { border-color: var(--accent); }
.tile.correct, .key.correct { background: var(--correct); border-color: var(--correct); color: #10291f; }
.tile.present, .key.present { background: var(--present); border-color: var(--present); color: #342607; }
.tile.absent, .key.absent { background: var(--absent); border-color: var(--absent); }
.tile.reveal {
  animation: reveal .38s ease both;
}
.tile.reveal:nth-child(2) { animation-delay: 55ms; }
.tile.reveal:nth-child(3) { animation-delay: 110ms; }
.tile.reveal:nth-child(4) { animation-delay: 165ms; }
.tile.reveal:nth-child(5) { animation-delay: 220ms; }
@keyframes reveal {
  from { transform: rotateX(90deg); opacity: .45; }
  to { transform: rotateX(0); opacity: 1; }
}

.status {
  min-height: 1.4em;
  margin: 12px 0;
  color: var(--accent);
  font-size: .88rem;
  font-weight: 700;
}
.keyboard { display: grid; gap: 5px; }
.key-row { display: flex; justify-content: center; gap: 4px; }
.key {
  flex: 0 1 45px;
  min-width: 0;
  min-height: 43px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #352e43;
  color: var(--ink);
  font-size: clamp(.72rem, 3.1vw, .96rem);
  font-weight: 800;
  touch-action: manipulation;
}
.key-wide { flex-basis: 69px; }
.key:hover:not(:disabled) { border-color: var(--ink); }
.reset { margin: 14px 0 0; color: var(--muted); font-size: .82rem; }
#countdown { font-variant-numeric: tabular-nums; color: var(--ink); }

dialog {
  width: min(calc(100% - 28px), 470px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
}
dialog::backdrop { background: rgb(10 8 15 / 78%); }
dialog h2 { margin: 0; }
dialog form { margin-top: 16px; }
.legend, .distribution { display: grid; gap: 8px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend .tile { width: 34px; flex: none; font-size: 1rem; }
.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stats-summary dt { color: var(--muted); font-size: .72rem; }
.stats-summary dd { margin: 2px 0; font-size: 1.25rem; font-weight: 800; }
.distribution li { display: flex; align-items: center; gap: 10px; }
.distribution meter { flex: 1; width: 100%; accent-color: var(--correct); }
footer {
  border-top: 1px solid var(--line);
  padding: 13px 8px;
  text-align: center;
  color: var(--muted);
  font-size: .7rem;
}
footer code { overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .tile.reveal { animation: none; }
}
