:root {
  --ink: #23190f;
  --paper: #fbf2dd;
  --clay: #bd6238;
  --moss: #63734d;
  --tile: #f5d28d;
  --tile-edge: #9a6a31;
  --sky: #d7e7d0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(189, 98, 56, .28), transparent 28rem),
    radial-gradient(circle at 85% 15%, rgba(99, 115, 77, .32), transparent 24rem),
    linear-gradient(135deg, var(--paper), var(--sky));
}

button, input {
  border: 0;
  border-radius: 16px;
  font: inherit;
}

button {
  cursor: pointer;
  padding: .85rem 1rem;
  color: #fff8e8;
  background: var(--clay);
  box-shadow: 0 10px 24px rgba(87, 48, 21, .18);
}

input {
  width: 100%;
  padding: .85rem 1rem;
  color: var(--ink);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(35,25,15,.18);
}

.app {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 24px;
  align-items: end;
  min-height: 38vh;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: .78rem;
}

h1 {
  margin: .25rem 0 .75rem;
  font-size: clamp(3rem, 10vw, 8rem);
  line-height: .86;
}

.lede {
  max-width: 36rem;
  font-size: 1.2rem;
}

.panel, .sidebar, .rack-wrap {
  padding: 18px;
  border: 1px solid rgba(35,25,15,.14);
  border-radius: 28px;
  background: rgba(255, 248, 232, .72);
  backdrop-filter: blur(14px);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.actions button:first-child {
  grid-column: 1 / -1;
}

.hidden { display: none !important; }

.game {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  margin-top: 22px;
}

.player {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(35,25,15,.15);
}

.current {
  color: var(--clay);
  font-weight: 700;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, minmax(22px, 1fr));
  gap: 3px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(35,25,15,.18);
}

.cell, .tile {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 700;
  user-select: none;
}

.cell {
  min-width: 0;
  color: rgba(35,25,15,.58);
  background: rgba(255,248,232,.72);
  font-size: clamp(.45rem, 1.8vw, .75rem);
}

.cell.selected {
  outline: 3px solid var(--clay);
}

.cell.pending {
  outline: 3px solid rgba(99, 115, 77, .72);
  outline-offset: -3px;
}

.cell.word-highlight {
  outline: 4px solid #ffcf4a;
  outline-offset: -4px;
  box-shadow: inset 0 0 0 999px rgba(255, 207, 74, .2);
}

.cell.TW { background: #c95b3b; color: white; }
.cell.DW { background: #e8a666; }
.cell.TL { background: #466e84; color: white; }
.cell.DL { background: #90b6b5; }

.tile {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #ffe2a4, var(--tile));
  border: 1px solid rgba(154,106,49,.72);
  border-radius: 10px;
  color: var(--ink);
  box-shadow: inset 0 -3px rgba(154,106,49,.22);
}

.tile span {
  display: grid;
  place-items: center;
  min-width: 1.45em;
  min-height: 1.45em;
  border-radius: 7px;
  line-height: 1;
  font-size: 1.08em;
  background: rgba(255, 248, 232, .35);
}

.tile small {
  position: absolute;
  right: 7px;
  bottom: 1px;
  font-size: .76em;
  line-height: 1;
  font-weight: 800;
  color: #4f3519;
  z-index: 2;
}

.cell > .tile {
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  font-size: clamp(.78rem, 2.8vw, 1.12rem);
}

.cell > .tile span {
  min-width: 1.35em;
  min-height: 1.35em;
}

.cell > .tile small {
  right: 4px;
  bottom: 2px;
  font-size: .66em;
}

.rack-wrap {
  margin-top: 16px;
}

.rack {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 64px));
  gap: 8px;
  margin-bottom: 12px;
}

.rack .tile.active {
  transform: translateY(-8px) rotate(-2deg);
  background: linear-gradient(145deg, #ffe9b8, #f0bd68);
  border-color: var(--moss);
  box-shadow: 0 12px 22px rgba(35,25,15,.2), inset 0 -3px rgba(154,106,49,.2);
}

.history {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.history-item {
  padding: 10px;
  border-radius: 16px;
  background: rgba(255,255,255,.38);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span,
.muted {
  color: rgba(35,25,15,.58);
  font-size: .9rem;
}

.history-word {
  margin: 8px 6px 0 0;
  padding: .42rem .58rem;
  color: var(--ink);
  background: var(--tile);
  border: 1px solid rgba(154,106,49,.42);
  box-shadow: none;
}

.history-word small {
  font-size: .78em;
  color: rgba(35,25,15,.68);
}

@media (max-width: 760px) {
  .hero, .game {
    grid-template-columns: 1fr;
  }
  .game {
    display: flex;
    flex-direction: column-reverse;
  }
  .board {
    gap: 2px;
    padding: 5px;
    margin-inline: -6px;
  }
  .sidebar {
    position: sticky;
    bottom: 8px;
  }
}
