:root {
  --bg-dark: #021f17;
  --bg-panel: rgba(3, 42, 29, 0.78);
  --green: #13985d;
  --green-light: #42d98b;
  --border: rgba(255, 255, 255, 0.16);
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.68);
  --red: #e01818;
  --gold: #ffb83d;
  --black: #111111;
  --card-w: clamp(112px, 8.333vw, 128px);
  --card-h: calc(var(--card-w) * 1.453125);
  --card-radius: 9px;
  font-family: Inter, system-ui, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg-dark);
  color: var(--text);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow: auto;
  background: var(--bg-dark);
}

button {
  font: inherit;
}

.game {
  position: relative;
  width: 100vw;
  min-width: 1366px;
  height: 100vh;
  min-height: 768px;
  overflow: hidden;
  padding: 28px 28px 20px;
  background:
    radial-gradient(circle at center, #0f7a45 0%, #064427 45%, #021f17 100%);
}

.game::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.011) 0 1px, transparent 1px 8px);
}

.game > * {
  position: relative;
  z-index: 1;
}

.table-hud {
  display: grid;
  grid-template-columns: 300px minmax(540px, 1fr) auto;
  align-items: center;
  gap: 18px;
  height: 82px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  width: 300px;
  gap: 16px;
}

.brand-mark {
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: linear-gradient(145deg, #0d8a55, #063421);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 12px 28px rgba(0, 0, 0, 0.28);
}

.brand-mark .spider-svg {
  width: 58px;
  height: 58px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--text);
  font-size: 34px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
}

h2 {
  font-size: 2rem;
}

.hud-center {
  justify-self: center;
}

.stats-grid {
  display: flex;
  width: 540px;
  height: 82px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(3, 35, 27, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 14px 30px rgba(0, 0, 0, 0.22);
}

.stat {
  display: flex;
  align-items: center;
  width: 25%;
  gap: 14px;
  padding: 0 18px;
}

.stat + .stat {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.stat-icon {
  display: block;
  min-width: 30px;
  color: var(--gold);
  font-size: 30px;
  line-height: 1;
  text-align: center;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.22));
}

.stat:nth-child(2) .stat-icon {
  color: var(--red);
}

.stat:nth-child(3) .stat-icon,
.stat:nth-child(4) .stat-icon {
  color: var(--green-light);
}

.stat-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  line-height: 1;
}

.stat strong {
  color: #fff;
  font-size: 28px;
  font-weight: 850;
  line-height: 1;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  justify-self: end;
  gap: 14px;
}

.icon-btn {
  display: flex;
  width: 82px;
  height: 82px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 10px 6px 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(3, 35, 27, 0.72);
  color: #fff;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 24px rgba(0, 0, 0, 0.22);
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.icon-btn svg {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.icon-btn span {
  max-width: 100%;
  color: currentColor;
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.12;
  text-align: center;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(66, 217, 139, 0.5);
  background: rgba(8, 80, 52, 0.8);
}

.icon-btn:disabled,
.stock-pile:disabled {
  cursor: not-allowed;
}

.icon-btn:disabled {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(3, 35, 27, 0.5);
  color: rgba(255, 255, 255, 0.42);
  transform: none;
}

.stock-pile:disabled {
  opacity: 0.46;
}

.game-table {
  position: relative;
  height: calc(100vh - 170px);
  min-height: 580px;
  margin-top: 22px;
  overflow: hidden;
  padding: 26px 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(4, 76, 45, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 80px rgba(0, 0, 0, 0.18);
}

.game-table::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 8px);
}

.difficulty {
  position: absolute;
  z-index: 20;
  top: 18px;
  left: 20px;
  display: flex;
  width: 360px;
  height: 48px;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
}

.difficulty-btn {
  position: relative;
  display: flex;
  height: 36px;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex: 1 1 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.difficulty-btn::before {
  content: "";
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.difficulty-btn.is-active {
  border-color: #42d98b;
  background: rgba(20, 152, 93, 0.22);
  color: #fff;
}

.difficulty-btn.is-active::before {
  background: #6af0a5;
  box-shadow: 0 0 16px rgba(106, 240, 165, 0.5);
}

.game-surface {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.board-wrap {
  position: absolute;
  z-index: 5;
  top: 96px;
  right: 18px;
  left: 18px;
  height: calc(100% - 340px);
  min-height: 430px;
  overflow: visible;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, var(--card-w));
  justify-content: space-between;
  align-items: start;
  width: 100%;
  height: 100%;
}

.column {
  position: relative;
  width: var(--card-w);
  min-height: 430px;
  border-radius: 14px;
}

.column.is-empty::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--card-radius);
  background: rgba(0, 0, 0, 0.08);
}

.column.is-drop-target::before,
.column.is-hint-target::before {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(66, 217, 139, 0.72);
  border-radius: 16px;
  background: rgba(66, 217, 139, 0.08);
}

.card,
.stock-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-radius);
}

.card {
  position: absolute;
  top: var(--card-top);
  left: 0;
  display: block;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: var(--black);
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.card.face-up {
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #f8f8f8 60%, #eeeeee 100%);
  cursor: pointer;
}

.card.face-up::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -18px 22px rgba(0, 0, 0, 0.035);
}

.card.face-down {
  position: absolute;
  display: grid;
}

.back-card {
  position: relative;
  display: grid;
}

.card.face-down,
.back-card {
  display: grid;
  overflow: hidden;
  place-items: center;
  border: 3px solid #f4f4f4;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 10px),
    linear-gradient(145deg, #0f8a55, #063d29);
  color: #fff;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.45),
    0 8px 18px rgba(0, 0, 0, 0.28);
}

.card.face-down .spider-svg,
.back-card .spider-svg {
  width: 58%;
  height: 58%;
  opacity: 0.96;
}

.card.is-red {
  color: var(--red);
}

.card.face-down.is-red {
  color: #fff;
}

.card.is-selected,
.card.is-hint-source {
  border-color: var(--green-light);
  box-shadow:
    0 0 0 3px rgba(66, 217, 139, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.28);
}

.card.is-dragging {
  opacity: 0.54;
}

.corner {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 15px;
  display: grid;
  justify-items: start;
  min-width: 32px;
  font-weight: 850;
  line-height: 0.92;
}

.corner-bottom {
  display: none;
}

.rank {
  font-size: 28px;
}

.suit {
  margin-top: 3px;
  font-size: 18px;
}

.pip-layer {
  position: absolute;
  inset: 32% 13% 10%;
}

.pip {
  position: absolute;
  font-size: clamp(1.4rem, 2.4vw, 2.6rem);
  line-height: 1;
  transform: translate(-50%, -50%) rotate(var(--pip-rotate));
}

.pip.is-ace {
  font-size: clamp(4rem, 5vw, 4.4rem);
}

.center-suit {
  position: absolute;
  right: 18px;
  bottom: 22px;
  left: 18px;
  z-index: 2;
  font-size: clamp(58px, 4.6vw, 70px);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-shadow: 0 9px 18px rgba(0, 0, 0, 0.12);
}

.court-card {
  position: absolute;
  right: 20px;
  bottom: 17px;
  left: 20px;
  z-index: 2;
  display: grid;
  place-items: center;
}

.court-inner {
  display: grid;
  place-items: center;
}

.court-rank {
  font-size: clamp(56px, 4.8vw, 72px);
  font-weight: 900;
  line-height: 0.86;
}

.court-suit {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1;
}

.hint-card {
  position: absolute;
  left: 28px;
  bottom: 130px;
  z-index: 12;
  display: flex;
  width: 340px;
  min-height: 150px;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(2, 28, 20, 0.45);
  color: #fff;
}

.hint-card strong {
  color: var(--gold);
  font-size: 24px;
  line-height: 1.35;
}

.hint-card p {
  margin: 0;
  font-size: 16px;
  font-weight: 520;
  line-height: 1.55;
}

.table-bottom {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.bottom-spacer {
  display: none;
}

.stock-pile {
  position: absolute;
  bottom: 88px;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  transform: translateX(-50%);
}

.stock-stack {
  position: relative;
  display: block;
  width: calc(var(--card-w) + 48px);
  height: var(--card-h);
}

.stock-stack .stock-card {
  position: absolute;
  top: 0;
}

.stock-stack .stock-card:nth-child(1) {
  left: 0;
}

.stock-stack .stock-card:nth-child(2) {
  left: 16px;
}

.stock-stack .stock-card:nth-child(3) {
  left: 32px;
}

.stock-stack .stock-card:nth-child(4) {
  left: 48px;
}

.stock-meta {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 18px;
  font-weight: 750;
  pointer-events: none;
}

.stock-meta strong,
.stock-meta small {
  color: #fff;
  font: inherit;
}

.foundation-panel {
  position: absolute;
  right: 42px;
  bottom: 165px;
  pointer-events: auto;
}

.foundation-grid {
  display: grid;
  grid-template-columns: repeat(8, 68px);
  gap: 10px;
}

.foundation-slot {
  display: grid;
  width: 68px;
  height: 92px;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(255, 255, 255, 0.28);
  font-size: 30px;
  font-weight: 800;
}

.foundation-slot.is-filled {
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.12);
  background: linear-gradient(180deg, #fff 0%, #f8f8f8 60%, #eeeeee 100%);
  color: var(--black);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}

.foundation-slot.is-red {
  color: var(--red);
}

.status-line {
  position: absolute;
  left: 28px;
  bottom: 86px;
  z-index: 16;
  display: flex;
  max-width: 360px;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(2, 28, 20, 0.64);
  color: rgba(255, 255, 255, 0.94);
  font-size: 14px;
  font-weight: 750;
  pointer-events: none;
}

.status-line:empty {
  display: none;
}

.status-line::before {
  content: "★";
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: var(--gold);
  font-size: 18px;
}

.goal-bar {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  z-index: 14;
  display: flex;
  height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  font-size: 18px;
}

.goal-bar div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.goal-bar strong {
  color: var(--gold);
  font-size: 25px;
}

.stats-button {
  display: flex;
  width: 180px;
  height: 52px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(3, 35, 27, 0.65);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 750;
}

.stats-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.landing-strip {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 18, 16, 0.68);
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f1f4ec);
  color: #101515;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.modal-card .eyebrow {
  color: #66736d;
}

.modal-card p:not(.eyebrow) {
  color: #66736d;
  line-height: 1.55;
}

.primary-btn,
.secondary-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 850;
}

.primary-btn {
  border: 0;
  background: #052f2c;
  color: #fff;
}

.secondary-btn {
  border: 1px solid rgba(5, 47, 44, 0.18);
  background: rgba(5, 47, 44, 0.08);
  color: #052f2c;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 1365px) {
  .game {
    width: 1366px;
  }
}

@media (max-height: 820px) {
  .board-wrap {
    top: 88px;
  }

  .hint-card {
    bottom: 116px;
  }

  .stock-pile {
    bottom: 78px;
  }

  .foundation-panel {
    bottom: 148px;
  }
}

@media (max-width: 860px) {
  :root {
    --card-w: 72px;
  }

  .game {
    min-width: 0;
    width: 100vw;
    overflow-x: auto;
    padding: 12px;
  }

  .table-hud {
    grid-template-columns: 1fr;
    height: auto;
  }

  .hud-center,
  .toolbar {
    justify-self: start;
  }

  .stats-grid {
    width: 100%;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .icon-btn {
    width: 72px;
    height: 74px;
  }

  .icon-btn svg {
    width: 26px;
    height: 26px;
  }

  .icon-btn span {
    font-size: 11px;
  }

  .game-table {
    height: calc(100vh - 270px);
    min-height: 560px;
  }

  .board-wrap {
    overflow-x: auto;
  }

  .hint-card {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
