:root {
  --paper: #f4ead7;
  --ink: #201a17;
  --coal: #171717;
  --panel: #fff8e9;
  --line: #2c2119;
  --red: #c73535;
  --green: #2f8f68;
  --blue: #257a91;
  --gold: #d6a637;
  --violet: #8061b8;
  --shadow: 0 18px 0 rgba(32, 26, 23, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(32, 26, 23, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(32, 26, 23, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: #fffdf6;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--line);
}

button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  background: var(--coal);
  color: var(--paper);
}

.wide {
  width: 100%;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h1,
.board-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(34px, 5vw, 72px);
  line-height: 0.94;
}

.eyebrow {
  margin: 0 0 6px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.connection,
.turn-plate {
  border: 2px solid var(--line);
  border-radius: 6px;
  background: var(--gold);
  padding: 10px 12px;
  font-family: "Courier New", monospace;
  font-weight: 700;
}

.arena {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.panel,
.board-zone {
  border: 3px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.board-zone {
  padding: 18px;
}

.board-head,
.loadout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(62px, 1fr));
  gap: 10px;
  margin: 18px 0;
  aspect-ratio: 1;
}

.tile {
  position: relative;
  min-width: 0;
  border: 3px solid var(--line);
  border-radius: 6px;
  background: #f7d683;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: "Courier New", monospace;
  font-size: clamp(26px, 5vw, 48px);
  font-weight: 900;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.12);
}

.tile.selected {
  outline: 5px solid var(--blue);
  transform: translateY(-4px);
}

.tile.silver {
  background: #c9d0d5;
}

.tile.gold {
  background: #f0b83f;
}

.tile.gem {
  background: var(--violet);
  color: white;
}

.tile.ailed {
  background: #a84b3f;
  color: white;
}

.tile.locked {
  filter: grayscale(0.75);
}

.badge {
  position: absolute;
  right: 5px;
  bottom: 4px;
  max-width: calc(100% - 10px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1;
  font-family: "Courier New", monospace;
}

.word-rack {
  display: grid;
  grid-template-columns: 1fr repeat(4, minmax(82px, auto));
  gap: 10px;
}

input {
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 0 12px;
  font-family: "Courier New", monospace;
  font-weight: 700;
}

.meter-block {
  margin-bottom: 16px;
}

.meter-block span,
.effect-row span {
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.meter-block strong {
  float: right;
  font-size: 28px;
}

.meter {
  clear: both;
  height: 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: white;
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--green);
}

.enemy .meter i {
  background: var(--red);
}

.effects h2,
.trophies h2,
.potions h2,
.combat-log h2,
.loadout h2 {
  margin: 18px 0 10px;
  font-size: 18px;
}

.chips,
.potion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.chip,
.potion-btn {
  border: 2px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 5px 9px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
}

.effect-row {
  margin-bottom: 10px;
}

.option-list {
  display: grid;
  gap: 8px;
}

.option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 9px;
}

.option strong,
.option small {
  display: block;
}

.option small {
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.option-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.option-controls button {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.combat-log ol {
  margin: 0;
  padding-left: 22px;
  max-height: 220px;
  overflow: auto;
}

.combat-log li {
  margin-bottom: 8px;
  line-height: 1.25;
}

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

  .status-panel,
  .inventory-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .loadout,
  .combat-log {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding: 12px 0;
  }

  .topbar,
  .board-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-panel,
  .inventory-panel {
    display: block;
  }

  .board {
    gap: 7px;
  }

  .word-rack {
    grid-template-columns: 1fr 1fr;
  }

  .word-rack input {
    grid-column: 1 / -1;
    min-height: 42px;
  }
}
