/* peel: styled to match the site — black, white, bold Inter, sharp corners.
   Green marks success, amber a dead end, red a wrong move. */

:root {
  --warn: #fbbf24;
  --bad: #f87171;
}

[hidden] {
  display: none !important;
}

.game {
  max-width: 520px;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.tabs {
  display: flex;
}

.tab {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  background: #000;
  color: var(--dim);
  border: 1px solid var(--faint);
  border-radius: 0;
  cursor: pointer;
}

.tab + .tab {
  border-left: 0;
}

.tab:hover {
  color: var(--fg);
}

.tab[aria-selected="true"] {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.rule {
  margin: 0;
  color: var(--dim);
  font-size: 15px;
  max-width: 46ch;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pips {
  display: flex;
  gap: 6px;
}

.pip {
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1px solid #fff;
}

.pip.off {
  background: transparent;
  border-color: #444;
}

.lens {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-size: 14px;
}

.chip {
  font: inherit;
  width: 38px;
  height: 34px;
  background: #000;
  color: var(--fg);
  border: 1px solid var(--faint);
  border-radius: 0;
  cursor: pointer;
}

.chip:hover {
  border-color: #fff;
}

.chip[aria-pressed="true"] {
  background: #fff;
  color: #000;
  border-color: #fff;
}

/* Board: past words stack above the live word, narrowing as letters go. */

.board {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding-block: 8px;
}

.row {
  --gap: 6px;
  display: flex;
  justify-content: center;
  gap: var(--gap);
  width: 100%;
}

.row .tile {
  width: var(--ts);
  height: var(--ts);
  font-size: calc(var(--ts) * 0.5);
}

.row.past {
  --ts: min(30px, calc((100cqw - (var(--n) - 1) * var(--gap)) / var(--n)));
}

.row.cur {
  --ts: min(60px, calc((100cqw - (var(--n) - 1) * var(--gap)) / var(--n)));
  margin-top: 8px;
}

.tile {
  display: grid;
  place-items: center;
  font-family: inherit;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  border-radius: 0;
}

.past .tile {
  background: #000;
  color: var(--dim);
  border: 1px solid var(--faint);
}

.past .tile.gone {
  border-style: dashed;
  color: #555;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.row.past.dead-past .tile {
  border-color: var(--warn);
}

.cur .tile {
  background: #fff;
  color: #000;
  border: 1px solid #fff;
  padding: 0;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}

.cur button.tile {
  cursor: pointer;
}

.cur button.tile:hover:not(:disabled) {
  background: #ccc;
  border-color: #ccc;
  transform: translateY(-3px);
}

.cur button.tile:active:not(:disabled) {
  transform: translateY(2px);
}

.cur button.tile:disabled {
  cursor: default;
}

.cur .tile.out {
  transform: translateY(34px) rotate(9deg);
  opacity: 0;
}

.cur .tile.hint {
  animation: glow 0.9s ease-in-out infinite alternate;
}

.cur.dead .tile {
  background: var(--warn);
  border-color: var(--warn);
}

.cur .tile.shake {
  animation: shake 0.3s ease;
}

.row.cur.enter .tile {
  animation: drop 0.22s ease-out;
}

@keyframes drop {
  from { opacity: 0; transform: translateY(-14px); }
}

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

@keyframes glow {
  from { box-shadow: 0 0 0 0 var(--good); }
  to { box-shadow: 0 0 0 4px var(--good); }
}

.msg {
  min-height: 1.4em;
  margin: 0;
  text-align: center;
}

.msg.ok { color: var(--good); }
.msg.warn { color: var(--warn); }
.msg.bad { color: var(--bad); }

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.btn {
  font: inherit;
  font-size: 15px;
  padding: 12px 18px;
  border-radius: 0;
  cursor: pointer;
}

.btn-primary {
  background: #fff;
  color: #000;
  border: 1px solid #fff;
  font-weight: 800;
}

.btn-primary:hover {
  background: #ccc;
  border-color: #ccc;
}

.btn-ghost {
  background: #000;
  color: var(--fg);
  border: 1px solid var(--faint);
}

.btn-ghost:hover {
  border-color: #fff;
}

.btn:disabled {
  color: #444;
  border-color: var(--faint);
  cursor: default;
  background: #000;
}

/* Result */

.result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 0 0;
  border-top: 1px solid var(--faint);
}

.result h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.result p {
  margin: 0;
  color: var(--dim);
  font-size: 15px;
}

.route {
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.share {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--faint);
  font: inherit;
  font-size: 15px;
  line-height: 1.3;
  white-space: pre;
  overflow-x: auto;
  user-select: all;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
