@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Sora:wght@600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --border: rgba(38, 34, 27, 0.12);
  --ink: #201c17;
  --muted: #6e665c;
  --accent: #201c17;
  --shadow: 0 18px 42px rgba(32, 28, 23, 0.08);
  --peg-size: 56px;
  --empty: #e3ddd2;
  --hit: #171512;
  --near: #f2efe8;
  --red: #d85146;
  --yellow: #d9b316;
  --green: #5ea157;
  --blue: #4f7ed3;
  --orange: #da7a33;
  --purple: #8b61c6;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: 'Manrope', 'Trebuchet MS', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(216, 81, 70, 0.12), transparent 26%),
    radial-gradient(circle at right 14%, rgba(217, 179, 22, 0.14), transparent 22%),
    linear-gradient(180deg, #faf7f2 0%, var(--bg) 100%);
}

.shell {
  width: min(1040px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 36px;
}

.masthead,
.panel,
.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.masthead {
  border-radius: 30px;
  padding: clamp(22px, 4vw, 34px);
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.section-kicker,
.label,
.mini-label,
.stats dt {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  font-family: 'Sora', 'Trebuchet MS', sans-serif;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(2.5rem, 8vw, 4.4rem);
  line-height: 0.94;
}

h2 {
  font-size: 1.2rem;
}

.lede,
.panel-head p,
.legend-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.lede {
  margin-top: 12px;
  max-width: 44ch;
}

.status-strip,
.game-grid,
.info-stack,
.legend,
.stats,
.action-row {
  display: grid;
  gap: 14px;
}

.status-strip {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 16px;
}

.status-card {
  border-radius: 22px;
  padding: 16px 18px;
}

.label,
.mini-label {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 800;
}

.status-card strong {
  display: block;
  line-height: 1.4;
  font-size: 1rem;
}

.game-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  margin-top: 16px;
  align-items: start;
}

.panel {
  border-radius: 28px;
  padding: 20px;
}

.panel-compact {
  padding: 18px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  align-items: end;
  margin-bottom: 18px;
}

.play-panel {
  display: grid;
  gap: 18px;
}

.rack-stack {
  display: grid;
  gap: 14px;
}

.rack {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-radius: 22px;
  background: var(--surface-strong);
  border: 1px solid rgba(38, 34, 27, 0.08);
}

.code {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, var(--peg-size)));
  gap: 10px;
  justify-content: end;
}

.peg {
  width: var(--peg-size);
  height: var(--peg-size);
  border-radius: 18px;
  border: 2px solid rgba(38, 34, 27, 0.08);
  background: #fff;
}

.peg.is-empty {
  background: var(--empty);
  border-style: dashed;
}

.peg.is-secret {
  position: relative;
  background: #d8d2c7;
}

.peg.is-secret::after {
  content: '?';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(32, 28, 23, 0.66);
  font-size: 1.1rem;
  font-weight: 800;
}

.palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.palette-button,
.button {
  appearance: none;
  border: 0;
  border-radius: 18px;
  font: inherit;
  cursor: pointer;
}

.palette-button {
  border: 1px solid rgba(38, 34, 27, 0.1);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 12px;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--ink);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.palette-button:hover,
.palette-button:focus-visible,
.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.palette-button:focus-visible,
.button:focus-visible {
  outline: 3px solid rgba(79, 126, 211, 0.2);
  outline-offset: 3px;
}

.palette-button:hover,
.palette-button:focus-visible {
  border-color: rgba(38, 34, 27, 0.18);
  box-shadow: 0 12px 24px rgba(32, 28, 23, 0.08);
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(38, 34, 27, 0.12);
}

.palette-label {
  font-weight: 800;
}

.palette-key {
  font-size: 0.8rem;
  color: var(--muted);
}

.action-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.button {
  padding: 14px 16px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(32, 28, 23, 0.16);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border: 1px solid rgba(38, 34, 27, 0.12);
}

.info-stack {
  grid-template-columns: 1fr;
}

.legend {
  gap: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  align-items: start;
}

.legend-item strong {
  display: block;
  margin-bottom: 2px;
}

.feedback {
  display: grid;
  grid-template-columns: repeat(2, 12px);
  gap: 6px;
  justify-content: end;
}

.pin {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--empty);
  border: 1px solid rgba(38, 34, 27, 0.1);
}

.pin-hit {
  background: var(--hit);
}

.pin-near {
  background: var(--near);
}

.stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.stats div {
  border-radius: 18px;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid rgba(38, 34, 27, 0.08);
}

.stats dt {
  color: var(--muted);
  font-weight: 800;
}

.stats dd {
  margin: 8px 0 0;
  font-size: 1.5rem;
  font-weight: 800;
}

.board-panel {
  margin-top: 16px;
}

.board {
  display: grid;
  gap: 12px;
}

.guess-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 22px;
  background: var(--surface-strong);
  border: 1px solid rgba(38, 34, 27, 0.08);
}

.guess-row.is-latest {
  border-color: rgba(79, 126, 211, 0.22);
  box-shadow: inset 0 0 0 1px rgba(79, 126, 211, 0.08);
}

.row-label {
  min-width: 70px;
  font-size: 0.94rem;
  font-weight: 800;
  color: var(--muted);
}

.empty-board {
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed rgba(38, 34, 27, 0.16);
  color: var(--muted);
  text-align: center;
}

kbd {
  font: inherit;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(32, 28, 23, 0.06);
  border: 1px solid rgba(32, 28, 23, 0.1);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(32, 28, 23, 0.94);
  color: #fff;
  box-shadow: 0 18px 36px rgba(32, 28, 23, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confetti-piece {
  position: fixed;
  top: -24px;
  width: 10px;
  height: 18px;
  border-radius: 999px;
  animation: confetti-fall 1600ms linear forwards;
  z-index: 20;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) rotate(540deg);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .info-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  :root {
    --peg-size: 48px;
  }

  .shell {
    width: min(100% - 16px, 1040px);
    padding-top: 12px;
  }

  .masthead,
  .panel,
  .status-card {
    border-radius: 24px;
  }

  .masthead,
  .rack,
  .guess-row {
    grid-template-columns: 1fr;
  }

  .masthead,
  .guess-row {
    display: grid;
    align-items: start;
  }

  .rack {
    flex-direction: column;
    align-items: start;
  }

  .code,
  .feedback {
    justify-content: start;
  }

  .row-label {
    min-width: 0;
  }

  .info-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  :root {
    --peg-size: min(18vw, 44px);
  }

  .palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-strip,
  .action-row,
  .stats {
    grid-template-columns: 1fr;
  }
}
