:root {
  color-scheme: light;
  font-family: "Trebuchet MS", "Verdana", sans-serif;
  background: #f6f3e8;
  color: #2f2a22;
  --paper: rgba(255, 250, 240, 0.97);
  --paper-strong: #fffef9;
  --border: #ddc9a7;
  --accent: #f28a1c;
  --accent-dark: #c56a0d;
  --accent-soft: #ffe1b0;
  --tile: #fff2cf;
  --tile-active: #ffc96f;
  --status: #70573b;
  --ink-soft: #7a6245;
  --shadow: 0 16px 36px rgba(126, 84, 24, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 214, 133, 0.95), transparent 30%),
    radial-gradient(circle at bottom, rgba(255, 243, 209, 0.9), transparent 35%),
    linear-gradient(180deg, #fff4da 0%, #f4e4c1 100%);
}

button {
  border: 0;
  border-radius: 18px;
  min-height: 3.75rem;
  padding: 0.95rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 120ms ease, background 120ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button:active {
  transform: translateY(1px);
}

.secondary-button {
  background: #eadfc7;
  color: #4c4134;
}

.secondary-button:hover {
  background: #ddd0b2;
}

.page {
  min-height: 100vh;
  padding: 0.65rem;
}

.game-card {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 1.6rem;
  padding: 0.8rem;
  box-shadow: var(--shadow);
}

.panel-head,
.controls {
  display: grid;
  gap: 0.85rem;
}

.panel-label,
.used-count {
  margin: 0;
}

.panel {
  border: 2px solid var(--border);
  border-radius: 1.35rem;
  background: var(--paper-strong);
}

.panel {
  padding: 0.8rem;
  margin-bottom: 0.7rem;
}

.panel-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #6f593d;
}

.word-panel {
  padding-top: 0.9rem;
}

.current-word {
  min-height: 4.5rem;
  display: grid;
  place-items: center;
  border-radius: 1.1rem;
  background: #fff;
  border: 2px dashed #d8c7a8;
  font-size: clamp(1.65rem, 7vw, 2.2rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  padding: 0.3rem;
}

.score-rules {
  margin-top: 0.85rem;
  padding: 0.8rem 0.95rem;
  border-radius: 1rem;
  background: #fff5df;
  border: 1px solid #eed5a6;
  color: #6d512a;
}

.score-rules p {
  margin: 0 0 0.55rem;
  font-weight: 700;
}

.score-rules ul {
  margin: 0;
  padding-left: 1.1rem;
}

.score-rules li + li {
  margin-top: 0.35rem;
}

.panel-head-actions {
  display: grid;
  align-items: center;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.55rem;
}

.panel-head-actions > #new-game-button {
  justify-self: start;
}

.panel-head-actions > #refresh-rack-button {
  justify-self: end;
}

.score-inline {
  min-height: 3.2rem;
  min-width: 6.75rem;
  padding: 0.7rem 0.95rem;
  border: 2px solid #dcc7a3;
  border-radius: 1.05rem;
  background: #f7edd8;
  color: #4e3d2a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 800;
  justify-self: center;
  align-self: center;
  box-shadow: inset 0 -2px 0 rgba(181, 145, 88, 0.12);
}

.score-inline:hover {
  background: #f2e5ca;
  color: #3e2f1d;
}

.score-inline:active {
  transform: translateY(1px);
}

.score-inline-label {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.score-inline strong {
  font-size: 1.18rem;
  line-height: 1;
}

.rack {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.tile {
  min-height: 4.2rem;
  border: 2px solid #d7bc8a;
  border-radius: 1.1rem;
  background: var(--tile);
  color: #433522;
  font-size: 1.55rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -3px 0 rgba(198, 156, 88, 0.14);
}

.tile:hover {
  background: #ffe5ba;
}

.tile.is-selected {
  background: var(--tile-active);
  border-color: #de8a1c;
  color: #60360f;
}

.controls {
  margin-bottom: 0.3rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.controls button {
  width: 100%;
  min-height: 3.15rem;
  padding: 0.7rem 0.4rem;
  font-size: 0.8rem;
  line-height: 1.15;
}

.used-words-list {
  list-style: none;
  padding: 0;
  margin: 0.9rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.used-words-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid #e2d5bd;
  gap: 0.75rem;
}

.history-entry--empty {
  justify-content: center;
  color: var(--ink-soft);
  text-align: center;
}

.history-text {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.used-word {
  font-weight: 700;
  text-transform: uppercase;
}

.history-note {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.2;
}

.used-score {
  font-weight: 700;
  flex-shrink: 0;
}

.used-score--positive {
  color: #925511;
}

.used-score--negative {
  color: #a04d1a;
}

.used-score--neutral {
  color: #7a6245;
}

.history-entry--rejected {
  background: #fff7ef;
}

.history-entry--repeated {
  background: #fffaf5;
}

.history-entry--reroll {
  background: #fffaf2;
}

@media (min-width: 640px) {
  .page {
    display: grid;
    place-items: center;
    padding: 1.25rem;
  }

  .game-card {
    max-width: 48rem;
    padding: 1.35rem;
    border-radius: 1.8rem;
  }

  .panel {
    padding: 0.95rem;
    margin-bottom: 0.9rem;
  }

  .current-word {
    min-height: 5.4rem;
    font-size: clamp(1.85rem, 8vw, 2.5rem);
    padding: 0.4rem;
  }

  .panel-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .panel-head-actions {
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
  }

  .rack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
  }

  .tile {
    min-height: 5.2rem;
    font-size: 2.1rem;
  }

  .controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 0.5rem;
  }

  .controls button {
    min-height: 3.75rem;
    padding: 0.95rem 1rem;
    font-size: 1rem;
  }
}
