:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #5e6862;
  --paper: #f7f4ee;
  --panel: #ffffff;
  --line: #d8ded4;
  --teal: #18a999;
  --coral: #ef5b45;
  --gold: #f2c14e;
  --blue: #364f6b;
  --shadow: 0 18px 50px rgba(24, 33, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(24, 169, 153, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(239, 91, 69, 0.1), transparent 30%),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 46px;
  padding: 0 16px;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(24, 33, 31, 0.16);
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
  width: min(1160px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.play-surface,
.side-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(216, 222, 212, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.play-surface {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: clamp(18px, 3vw, 30px);
}

.top-line {
  align-items: start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 7px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 0.92;
  margin-bottom: 0;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.15;
  margin-bottom: 10px;
}

.date-chip {
  align-items: center;
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 42px;
  min-width: 122px;
  padding: 0 12px;
  white-space: nowrap;
}

.status-grid,
.detail-list {
  display: grid;
  gap: 10px;
}

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

.metric,
.detail-list div {
  background: #f9fbf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.metric span,
.detail-list span {
  color: var(--muted);
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.metric strong,
.detail-list strong {
  display: block;
  font-size: 1.3rem;
}

.board-wrap {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
}

.edge-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.board {
  --board-size: 6;
  aspect-ratio: 1;
  background: #25322f;
  border: 8px solid var(--ink);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(var(--board-size), minmax(0, 1fr));
  max-width: min(74vh, 680px);
  padding: 6px;
  width: 100%;
}

.challenge-strip {
  align-items: center;
  background: #f9fbf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(145px, 1fr) repeat(3, minmax(96px, auto));
  min-width: 0;
  padding: 10px;
}

.challenge-strip label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.challenge-strip input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
}

.challenge-strip button {
  background: var(--blue);
  min-height: 44px;
  padding: 0 12px;
}

.cell {
  align-items: center;
  aspect-ratio: 1;
  background: #edf2e9;
  border: 2px solid rgba(24, 33, 31, 0.16);
  color: var(--ink);
  display: flex;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.1rem, 4.8vw, 2.7rem);
  font-weight: 900;
  justify-content: center;
  min-height: 0;
  padding: 0;
  position: relative;
}

.cell:disabled {
  opacity: 1;
}

.cell.mirror {
  background: #fff9dd;
  border-color: rgba(242, 193, 78, 0.9);
}

.cell.mirror:not(:disabled):hover {
  background: #ffe9a2;
}

.cell.source::after,
.cell.target::after {
  align-items: center;
  border-radius: 6px;
  bottom: 4px;
  color: #fff;
  content: "IN";
  display: flex;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.57rem;
  font-weight: 900;
  height: 17px;
  justify-content: center;
  letter-spacing: 0.04em;
  padding: 0 5px;
  position: absolute;
  right: 4px;
}

.cell.source::after {
  background: var(--blue);
}

.cell.target::after {
  background: var(--teal);
  content: "DOCK";
}

.cell.beam {
  background: #ffe8a8;
  box-shadow: inset 0 0 0 3px rgba(242, 193, 78, 0.58);
}

.cell.beam-success {
  background: #c9f4df;
  box-shadow: inset 0 0 0 4px rgba(24, 169, 153, 0.6);
}

.cell.beam-fail {
  background: #ffd0c8;
  box-shadow: inset 0 0 0 4px rgba(239, 91, 69, 0.48);
}

.controls {
  display: grid;
  gap: 10px;
  grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr));
}

.primary-button {
  background: var(--coral);
}

#fire-button {
  background: var(--teal);
}

#nudge-button {
  background: var(--blue);
}

#next-button {
  background: var(--gold);
  color: var(--ink);
}

#copy-button {
  background: var(--ink);
}

.side-panel {
  align-self: start;
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dock-card,
.result-panel {
  background: #f9fbf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

#dock-status,
#share-text {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.detail-list {
  grid-template-columns: 1fr;
}

.result-panel {
  border-color: rgba(24, 169, 153, 0.42);
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 22px, 720px);
  }

  .side-panel {
    align-self: stretch;
  }

  .detail-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    gap: 12px;
    padding: 10px 0 18px;
    width: calc(100vw - 14px);
  }

  .play-surface,
  .side-panel {
    padding: 12px;
  }

  .top-line {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2.4rem;
  }

  .date-chip {
    justify-content: flex-start;
    width: 100%;
  }

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

  .challenge-strip {
    grid-template-columns: 1fr 1fr;
  }

  .challenge-strip label,
  .challenge-strip input {
    grid-column: 1 / -1;
  }

  .challenge-strip button {
    min-height: 42px;
    padding: 0 8px;
  }

  #copy-link-button {
    grid-column: 1 / -1;
  }

  .board {
    border-width: 5px;
    gap: 3px;
    padding: 4px;
  }

  .cell {
    border-width: 1px;
    font-size: clamp(1rem, 8vw, 1.75rem);
  }

  .cell.source::after,
  .cell.target::after {
    bottom: 2px;
    font-size: 0.48rem;
    height: 14px;
    padding: 0 3px;
    right: 2px;
  }

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

  .controls button {
    min-height: 44px;
    padding: 0 10px;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }
}
