:root {
  --bg: #f3efe5;
  --bg-accent: #e7dcc6;
  --panel: rgba(255, 252, 245, 0.86);
  --panel-strong: #fffaf0;
  --border: rgba(92, 63, 33, 0.15);
  --text: #24170d;
  --muted: #6e5a45;
  --accent: #db6f32;
  --accent-soft: rgba(219, 111, 50, 0.16);
  --teal: #2a7f7f;
  --olive: #758646;
  --danger: #c24843;
  --shadow: 0 18px 45px rgba(67, 45, 21, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 35%),
    radial-gradient(circle at bottom right, rgba(219, 111, 50, 0.18), transparent 28%),
    linear-gradient(135deg, var(--bg) 0%, #efe5d4 45%, var(--bg-accent) 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker,
.meta-label,
.stat-label,
.speed-title {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

.page-title {
  margin-bottom: 18px;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1;
}

.hero-panel {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.stat-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.88);
  border: 1px solid rgba(92, 63, 33, 0.1);
}

.stat-card strong {
  display: block;
  font-size: 1rem;
  line-height: 1.3;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.75fr);
  gap: 20px;
}

.board-column {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 20px;
}

.board-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.section-heading h2,
.controls-panel h2,
.detail-panel h2,
.log-panel h2 {
  margin-top: 6px;
  font-size: 1.5rem;
}

.board-badge {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.board-badge span {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.board-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 24px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(42, 127, 127, 0.09), rgba(117, 134, 70, 0.09)),
    rgba(255, 249, 238, 0.86);
  overflow: auto;
}

.board {
  width: min(100%, 760px);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(56, 1fr);
  grid-template-rows: repeat(56, 1fr);
  gap: 0;
  padding: 10px;
  background: rgba(61, 43, 26, 0.3);
  border-radius: 18px;
  overflow: hidden;
}

.board:focus-visible {
  outline: 3px solid rgba(42, 127, 127, 0.35);
  outline-offset: 4px;
}

.cell {
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid rgba(83, 60, 38, 0.18);
  border-bottom: 1px solid rgba(83, 60, 38, 0.18);
  transition: background 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.cell.drop-target {
  outline: 2px solid rgba(219, 111, 50, 0.75);
  outline-offset: -2px;
}

.cell.drop-invalid {
  outline: 2px solid rgba(194, 72, 67, 0.72);
  outline-offset: -2px;
}

.cell.filled {
  opacity: 0.98;
}

.cell.selected-piece {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.95);
  filter: saturate(1.1) brightness(1.03);
}

.cell.trying {
  background: rgba(219, 111, 50, 0.55);
  transform: scale(0.94);
}

.cell.rejected {
  background: rgba(194, 72, 67, 0.62);
}

.cell.removing {
  background: rgba(36, 23, 13, 0.42);
}

.sidebar {
  display: grid;
  gap: 20px;
  align-content: start;
}

.controls-intro {
  margin-top: 12px;
}

.controls-row,
.speed-grid {
  display: grid;
  gap: 10px;
}

.controls-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

button {
  border: 1px solid rgba(92, 63, 33, 0.14);
  background: var(--panel-strong);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

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

button.control-active,
.speed-grid button.active {
  background: linear-gradient(135deg, var(--accent), #ef9153);
  color: white;
  border-color: transparent;
}

.speed-block {
  margin-top: 18px;
}

.speed-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 10px;
}

#timeline {
  width: 100%;
  margin-top: 18px;
  accent-color: var(--accent);
}

.helper-text,
.event-description {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.setup-tips {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.setup-tips li + li {
  margin-top: 6px;
}

.mode-chip {
  margin-top: 14px;
}

.mode-chip span {
  display: inline-block;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(42, 127, 127, 0.12);
  border: 1px solid rgba(42, 127, 127, 0.18);
  color: var(--teal);
  font-size: 0.9rem;
}

.setup-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, auto);
  gap: 10px;
  align-items: end;
  margin-top: 18px;
}

.piece-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.piece-chip {
  position: relative;
  border: 1px solid rgba(92, 63, 33, 0.14);
  border-radius: 18px;
  background: var(--panel-strong);
  padding: 10px;
  min-height: 84px;
  cursor: grab;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.piece-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(67, 45, 21, 0.08);
}

.piece-chip.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.piece-chip.selected {
  border-color: rgba(219, 111, 50, 0.45);
  box-shadow: 0 0 0 3px rgba(219, 111, 50, 0.12);
}

.piece-chip-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.piece-chip strong {
  color: var(--text);
}

.piece-chip-preview {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  justify-content: start;
}

.piece-chip-preview span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

.setup-field {
  display: grid;
  gap: 8px;
}

.setup-field select {
  width: 100%;
  border: 1px solid rgba(92, 63, 33, 0.14);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 12px 14px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.meta-grid strong {
  display: block;
  margin-top: 6px;
  font-family: "IBM Plex Mono", monospace;
}

.event-log {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.event-log li {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.8);
  border: 1px solid rgba(92, 63, 33, 0.08);
  color: var(--muted);
  line-height: 1.45;
}

.event-log li.current {
  border-color: rgba(219, 111, 50, 0.35);
  background: rgba(219, 111, 50, 0.12);
  color: var(--text);
}

.event-log .event-kind {
  display: inline-block;
  margin-bottom: 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--teal);
}

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

@media (max-width: 700px) {
  .page-shell {
    width: min(100% - 20px, 1380px);
    padding-top: 16px;
  }

  .panel {
    border-radius: 22px;
  }

  .hero-panel,
  .controls-row,
  .speed-grid,
  .meta-grid,
  .setup-controls {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    padding: 12px;
  }

  .board {
    width: min(100%, 92vw);
    padding: 6px;
  }
}
