:root {
  --bg-deep: #0d2430;
  --bg-mid: #163a49;
  --text: #f8f4eb;
  --muted: rgba(248, 244, 235, 0.8);
  --panel: rgba(11, 28, 37, 0.42);
  --panel-soft: rgba(248, 242, 230, 0.94);
  --felt: #215f49;
  --felt-dark: #164335;
  --gold: #cf9a43;
  --red: #b04d3c;
  --shadow: 0 20px 54px rgba(6, 12, 16, 0.26);
  --card-width: 92px;
  --card-height: 126px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(207, 154, 67, 0.16), transparent 24%),
    radial-gradient(circle at 82% 10%, rgba(72, 170, 132, 0.18), transparent 26%),
    linear-gradient(155deg, var(--bg-deep), var(--bg-mid));
}

.spider-app {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.spider-topbar,
.spider-controls,
.spider-board-panel,
.help-card {
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.spider-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(10, 26, 35, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.spider-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spider-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
}

.spider-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--gold), var(--red));
  color: #1d150e;
  font-weight: 900;
}

.spider-brand-copy {
  display: grid;
  gap: 2px;
}

.spider-brand-copy span {
  color: var(--muted);
}

.spider-return,
.spider-support,
.action-button,
.deal-stack-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.spider-return,
.action-button.primary {
  background: linear-gradient(135deg, var(--gold), #f0c274);
  color: #16212a;
}

.spider-support {
  background: linear-gradient(135deg, #ffdc42, #f0b90a);
  color: #21170f;
}

.action-button,
.deal-stack-button {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
}

.action-button:hover,
.action-button:focus-visible,
.deal-stack-button:hover,
.deal-stack-button:focus-visible,
.spider-return:hover,
.spider-return:focus-visible,
.spider-support:hover,
.spider-support:focus-visible {
  transform: translateY(-1px);
}

.action-button:disabled,
.deal-stack-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.spider-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  gap: 22px;
  align-items: start;
  padding: 30px 0 20px;
}

.eyebrow,
.mini-label,
.setup-label {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.77rem;
  font-weight: 700;
  color: rgba(248, 244, 235, 0.68);
}

.mini-label,
.setup-label {
  color: #586568;
}

.spider-copy h1,
.spider-status h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.spider-copy h1 {
  margin: 0 0 16px;
  max-width: 12ch;
  font-size: clamp(2.3rem, 4.8vw, 4.2rem);
  line-height: 0.95;
}

.spider-copy p {
  margin: 0;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.65;
}

.spider-controls {
  padding: 20px;
  background: rgba(248, 242, 230, 0.92);
  border: 1px solid rgba(34, 47, 55, 0.08);
  color: #1c2529;
}

.spider-status h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  line-height: 1.1;
}

.spider-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
}

.metric-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #586568;
}

.metric-card strong {
  font-size: 1.45rem;
}

.setup-row {
  margin-bottom: 18px;
}

.difficulty-field {
  display: inline-grid;
  gap: 10px;
}

.difficulty-select {
  min-width: 180px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid rgba(28, 37, 41, 0.14);
  background: rgba(255, 255, 255, 0.72);
  color: #1c2529;
  font: inherit;
  font-weight: 700;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.spider-board-panel {
  padding: 22px;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 255, 255, 0.12), transparent 18%),
    linear-gradient(145deg, rgba(31, 106, 79, 0.96), rgba(18, 69, 52, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.spider-board-head {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}

.stock-panel,
.completed-panel {
  padding: 16px;
  border-radius: 22px;
  background: rgba(7, 19, 25, 0.18);
}

.deal-stack-button {
  width: 100%;
  min-height: 124px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  justify-content: start;
  text-align: left;
}

.deal-stack-visual {
  display: flex;
  gap: 8px;
  align-items: center;
}

.deal-stack {
  display: block;
  width: 16px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.deal-stack.filled {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(145deg, #d56240, #a53822);
}

.deal-stack-copy {
  display: grid;
  align-content: center;
  gap: 4px;
}

.deal-stack-copy strong {
  font-size: 1.45rem;
}

.deal-stack-copy span,
.stock-hint {
  color: rgba(248, 244, 235, 0.8);
  line-height: 1.5;
}

.stock-hint {
  margin: 12px 0 0;
  font-size: 0.95rem;
}

.completed-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
}

.completed-slot {
  min-height: 94px;
  border-radius: 18px;
  padding: 10px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(248, 244, 235, 0.6);
}

.completed-slot.filled {
  border-style: solid;
  background: linear-gradient(145deg, #fcf8ee, #fffdf8);
  color: #1d252a;
}

.completed-slot.red {
  color: #b04d3c;
}

.completed-slot.black {
  color: #1d252a;
}

.completed-slot strong {
  font-size: 1.6rem;
  line-height: 1;
}

.completed-run-label,
.completed-placeholder {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tableau-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.spider-tableau {
  display: grid;
  grid-template-columns: repeat(10, var(--card-width));
  gap: 14px;
  min-width: calc((10 * var(--card-width)) + (9 * 14px));
}

.spider-column {
  position: relative;
  width: var(--card-width);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

.spider-column.target-column {
  background: rgba(207, 154, 67, 0.18);
  border-style: solid;
  border-color: rgba(255, 238, 201, 0.34);
}

.empty-column-button {
  width: 100%;
  min-height: var(--card-height);
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: rgba(248, 244, 235, 0.68);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.spider-card {
  position: absolute;
  left: 0;
  width: var(--card-width);
  height: var(--card-height);
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 14px 28px rgba(4, 10, 12, 0.2);
  background: linear-gradient(145deg, #fcf8ee, #fffdf8);
  color: #1d252a;
  padding: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.spider-card.back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%),
    linear-gradient(145deg, #d56240, #a53822);
  border-color: rgba(255, 255, 255, 0.12);
}

.spider-card.red {
  color: #b04d3c;
}

.spider-card.selected-card {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px rgba(4, 10, 12, 0.26), 0 0 0 3px rgba(240, 194, 116, 0.45);
}

.spider-card.movable-card.face-up:hover,
.spider-card.movable-card.face-up:focus-visible {
  transform: translateY(-2px);
}

.spider-card-content {
  display: grid;
  width: 100%;
  height: 100%;
  grid-template-rows: auto 1fr auto;
  padding: 10px;
}

.spider-card-corner,
.spider-card-suit {
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-weight: 700;
}

.spider-card-corner {
  font-size: 0.9rem;
  line-height: 1;
}

.spider-card-corner-bottom {
  transform: rotate(180deg);
  justify-self: end;
}

.spider-card-suit {
  place-self: center;
  font-size: 2rem;
}

.spider-card-back-mark {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #f8f4eb;
  font-weight: 900;
}

.spider-help {
  margin-top: 20px;
}

.help-card {
  padding: 20px;
  background: rgba(248, 242, 230, 0.92);
  border: 1px solid rgba(34, 47, 55, 0.08);
  color: #1c2529;
}

.help-list {
  margin: 0;
  padding-left: 18px;
  color: #586568;
  line-height: 1.75;
}

.spider-seo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.spider-seo-card {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 38%),
    rgba(248, 242, 230, 0.96);
  border: 1px solid rgba(34, 47, 55, 0.1);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.spider-seo-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: linear-gradient(180deg, var(--gold), var(--red));
}

.spider-seo-card-wide {
  grid-column: 1 / -1;
}

.spider-seo-card h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.3rem;
  line-height: 1.15;
}

.spider-seo-card p {
  margin: 0;
  color: #586568;
  line-height: 1.7;
}

.spider-faq-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.spider-faq-list div {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(34, 47, 55, 0.08);
}

.spider-faq-list dt {
  margin: 0 0 6px;
  font-weight: 800;
}

.spider-faq-list dd {
  margin: 0;
  color: #586568;
  line-height: 1.65;
}

.spider-seo-card a {
  color: #8d4b2f;
  font-weight: 800;
  text-decoration-thickness: 2px;
}

@media (max-width: 1080px) {
  .spider-hero {
    grid-template-columns: 1fr;
  }

  .spider-copy h1 {
    max-width: 14ch;
  }

  .spider-seo {
    grid-template-columns: 1fr;
  }

  .spider-board-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --card-width: 84px;
    --card-height: 116px;
  }

  .spider-app {
    width: min(100%, calc(100% - 20px));
    padding-top: 16px;
  }

  .spider-topbar,
  .spider-topbar-actions {
    align-items: stretch;
  }

  .spider-topbar {
    flex-direction: column;
  }

  .spider-topbar-actions,
  .control-row {
    width: 100%;
  }

  .spider-return,
  .spider-support,
  .action-button {
    flex: 1 1 180px;
  }

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

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

@media (max-width: 520px) {
  :root {
    --card-width: 78px;
    --card-height: 108px;
  }

  .spider-app {
    width: calc(100% - 16px);
  }

  .spider-controls,
  .spider-board-panel,
  .help-card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .deal-stack-button {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}
