@font-face {
  font-family: Ysabeau;
  src: url('./fonts/ysabeau-site-015a63c728.woff2') format('woff2');
  font-weight: 1 1000;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Ysabeau, system-ui, sans-serif;
  font-weight: 450;
  --background: #fcfaeb;
  --surface: #f9f7f0;
  --text: #524946;
  --green: #55aa99;
  --laurel: #447d4d;
  --sky: #99ccff;
  --peach: #fed7aa;
  --worm: #ff8a82;
  --line: color-mix(in srgb, var(--text) 33%, var(--background));
  --board-line: color-mix(in srgb, var(--text) 62%, var(--background));
  --complete: color-mix(in srgb, var(--green) 29%, var(--background));
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
p, h1, h2 { margin: 0; }

.game {
  width: min(30rem, calc(100% - 2.5rem));
  margin-inline: auto;
  padding-block: 1rem;
}

.game-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: .625rem;
  border-bottom: 1px solid var(--line);
}

h1 {
  font-size: clamp(1.875rem, 9vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: -.045em;
  font-weight: 500;
}

.clock {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: .95rem;
}

.time {
  min-width: 3ch;
  text-align: right;
  font-size: 1.55rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.clock.urgent .time {
  text-decoration: underline;
  text-decoration-color: var(--worm);
  text-decoration-thickness: .17em;
  text-underline-offset: .16em;
}

.game-body {
  display: grid;
  grid-template-areas: "instructions" "board" "actions";
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: .625rem;
  padding-top: .625rem;
}

.board-panel { grid-area: board; min-width: 0; }
.board-status {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: 1.25rem;
  margin-bottom: .35rem;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

progress {
  flex: 1;
  min-width: 0;
  height: .25rem;
  appearance: none;
  border: 0;
  background: var(--line);
  color: var(--laurel);
}

progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--laurel); }
progress::-moz-progress-bar { background: var(--laurel); }

.board {
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--board-line);
  background: var(--board-line);
  list-style: none;
}

.board-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--columns, 5), minmax(0, 1fr));
  gap: 1px;
}

.tile {
  display: grid;
  block-size: clamp(2.75rem, 11vw, 3rem);
  place-items: center;
  background: var(--surface);
  font-size: clamp(1.55rem, 6vw, 2.25rem);
  font-weight: 650;
  line-height: 1;
  text-transform: uppercase;
}

.active::after {
  position: absolute;
  inset: 0;
  border: 2px solid var(--laurel);
  content: '';
  pointer-events: none;
}

.active .tile { background: var(--background); }
.active .tile.starter { background: var(--peach); }
.active .tile.clue-tile { background: var(--sky); }
.active .tile.banned-tile { background: var(--worm); }
.completed .tile { background: var(--complete); }
.board-row:focus-within .tile:is(.current, .selected) { outline: 2px solid var(--laurel); outline-offset: -4px; }

.word-entry {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  opacity: 0;
  font-size: 1rem;
  cursor: text;
}

.instructions { grid-area: instructions; min-width: 0; }
h2 {
  font-size: clamp(1.55rem, 3.3vw, 2rem);
  line-height: 1.2;
  letter-spacing: -.02em;
  font-weight: 550;
}

.word-rule { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .7rem; }
.rule-clue { display: inline-flex; align-items: center; gap: .38rem; }
.rule-clue.banned .rule-letter { background: var(--worm); }
.rule-letter {
  display: grid;
  place-items: center;
  min-width: 1.35em;
  height: 1.35em;
  border: 1px solid var(--board-line);
  background: var(--sky);
  font-weight: 650;
}

.instruction {
  max-width: 35ch;
  margin-top: .25rem;
  font-size: 1rem;
  line-height: 1.35;
}

.actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: .625rem; }
button {
  min-height: 3rem;
  padding: .6rem 1rem;
  border: 1px solid var(--text);
  border-radius: 4px;
  background: var(--text);
  color: var(--background);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 650;
  cursor: pointer;
}

button:hover:enabled { background: var(--laurel); border-color: var(--laurel); }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--laurel); outline-offset: 3px; }
.mode-button.restart { background: transparent; color: var(--text); font-weight: 550; }
.mode-button.restart:hover { border-color: var(--laurel); color: var(--laurel); }
.feedback {
  margin-top: .4rem;
  padding-inline-start: .65rem;
  border-inline-start: 3px solid var(--worm);
  font-size: 1.0625rem;
  line-height: 1.4;
}
.feedback:empty { margin: 0; padding: 0; border: 0; }

@media (width > 42rem) {
  .game {
    width: min(54rem, calc(100% - 3rem));
    padding-block: clamp(1.75rem, 6vw, 4.5rem);
  }
  .game-header { padding-bottom: clamp(.75rem, 2.5vw, 1.25rem); }
  h1 { font-size: clamp(2.35rem, 6.2vw, 4rem); }
  .game-body {
    grid-template-areas: "board instructions" "board actions";
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    grid-template-rows: auto 1fr;
    gap: 1.125rem clamp(1.5rem, 6vw, 4.25rem);
    padding-top: clamp(1rem, 3vw, 1.75rem);
  }
  .board-status { min-height: 1.5rem; margin-bottom: .55rem; }
  .tile { block-size: auto; aspect-ratio: 1.22; }
  .instructions { padding-top: 2.05rem; }
  .instruction { margin-top: .65rem; font-size: 1.125rem; line-height: 1.5; }
  .feedback { margin-top: .75rem; }
}
