:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #f4efe3;
  color: #242220;
  --panel: #fffaf0;
  --ink-soft: #645f55;
  --line: #d8ccb6;
  --dark: #111414;
  --focus: #0b7a75;
  --danger: #b3263d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0)),
    #f4efe3;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 2px solid #242220;
  border-radius: 8px;
  background: #242220;
  color: #fffaf0;
  font-weight: 800;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    opacity 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

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

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

button.secondary {
  background: #fffaf0;
  color: #242220;
}

button.ghost {
  background: transparent;
  color: #242220;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  padding: 10px 0 14px;
  border-bottom: 2px solid #242220;
}

.eyebrow {
  margin: 0 0 6px;
  color: #6a4028;
  font-size: 0.85rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lede {
  max-width: 56rem;
  margin: 10px 0 0;
  color: #514b42;
  font-size: 1.02rem;
  line-height: 1.5;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(76px, 1fr));
  gap: 8px;
  min-width: min(620px, 100%);
}

.meter {
  min-height: 72px;
  padding: 9px 10px;
  border: 2px solid #242220;
  background: #fffaf0;
}

.meter span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.meter strong {
  display: block;
  margin-top: 5px;
  font-size: 1.05rem;
  line-height: 1.15;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(310px, 0.72fr);
  gap: 18px;
  align-items: start;
  padding-top: 18px;
}

.board,
.control-panel,
.message-panel {
  border: 2px solid #242220;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 5px 5px 0 #242220;
}

.board {
  overflow: hidden;
}

.relay-canvas {
  display: block;
  width: 100%;
  height: 162px;
  border-bottom: 2px solid #242220;
}

.board-section {
  padding: 16px;
  border-bottom: 2px solid var(--line);
}

.board-section:last-child {
  border-bottom: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 0.98rem;
}

.section-head span {
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 750;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 52px;
  align-items: center;
}

.token {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 7px;
  align-items: center;
  min-width: 82px;
  min-height: 42px;
  padding: 6px 9px;
  border: 2px solid #242220;
  border-radius: 8px;
  background: var(--token-bg);
  color: var(--token-ink);
  box-shadow: 3px 3px 0 #242220;
}

.token strong {
  display: grid;
  place-items: center;
  width: 29px;
  height: 26px;
  border: 2px solid currentColor;
  border-radius: 6px;
  font-size: 0.79rem;
}

.token span {
  font-size: 0.82rem;
  font-weight: 850;
}

.token[data-large="true"] {
  width: 100%;
  min-height: 70px;
  grid-template-columns: 54px 1fr;
}

.token[data-large="true"] strong {
  width: 48px;
  height: 44px;
  font-size: 1rem;
}

.token[data-active="true"] {
  outline: 4px solid #242220;
  outline-offset: 2px;
}

.token[data-spent="true"] {
  filter: grayscale(1);
  opacity: 0.36;
  box-shadow: none;
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.slot {
  display: grid;
  min-height: 92px;
  padding: 10px;
  border: 2px dashed #756e61;
  border-radius: 8px;
  background: #faf3df;
}

.slot[data-filled="true"] {
  border-style: solid;
  background: #fffaf0;
}

.slot-empty,
.empty-note {
  display: grid;
  place-items: center;
  min-height: 42px;
  color: #756e61;
  font-weight: 850;
}

.control-panel {
  padding: 16px;
}

.control-panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.primary-actions,
.slot-actions,
.emit-actions,
.utility-actions {
  display: grid;
  gap: 8px;
}

.primary-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.slot-actions,
.emit-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.utility-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-label {
  display: block;
  margin: 0 0 7px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.button-token {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  margin-left: 5px;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
}

.message-panel {
  margin-top: 18px;
  padding: 14px;
}

.message-panel h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.message-panel p {
  min-height: 48px;
  margin: 0;
  color: #3f3931;
  line-height: 1.45;
}

.share-text {
  display: block;
  width: 100%;
  min-height: 118px;
  margin-top: 12px;
  padding: 10px;
  border: 2px solid #242220;
  border-radius: 8px;
  background: #fff;
  color: #242220;
  resize: vertical;
}

[hidden] {
  display: none !important;
}

#app[data-status="lost"] .board,
#app[data-status="lost"] .control-panel {
  box-shadow: 5px 5px 0 var(--danger);
}

@media (max-width: 820px) {
  .topbar,
  .game-grid {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .relay-canvas {
    height: 128px;
  }
}

@media (max-width: 460px) {
  .shell {
    width: min(100% - 18px, 1120px);
    padding-top: 10px;
  }

  h1 {
    font-size: 2.45rem;
  }

  .lede {
    font-size: 0.95rem;
  }

  .board-section,
  .control-panel,
  .message-panel {
    padding: 12px;
  }

  .slots,
  .primary-actions,
  .slot-actions,
  .emit-actions,
  .utility-actions {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter {
    min-height: 64px;
  }

  .token {
    min-width: 76px;
  }
}
