#game {
  --felt: #123b30;
  --felt-deep: #102f28;
  --line: #a9c5aa50;
  --paper: #fffaf0;
  --ink: #182b25;
  --accent: #f1ca7f;
  --board-gap: clamp(3px, 0.9vw, 12px);
  --card-radius: clamp(3px, 0.9vw, 9px);
  color: var(--paper);
  min-height: 37rem;
  margin-block: 0 2rem;
}
#game[hidden], #game [hidden] { display: none !important; }
#game button, #game select, #game input { font: inherit; }
#game button { cursor: pointer; }
#game button:disabled { cursor: default; }
#game button:focus-visible, #game a:focus-visible, #game select:focus-visible, #game input:focus-visible {
  outline: 3px solid #ffdf88;
  outline-offset: 2px;
  z-index: 2;
}
#game .game-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0.8rem;
  border: 1px solid #393a2c;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  color: #f9f0dd;
  background: #242d25;
}
#game .game-actions, #game .game-options, #game .dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
#game .game-bar button, #game .game-dialog button, #game .game-variant button {
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 0.42rem 0.7rem;
  line-height: 1.15;
  font-weight: 650;
}
#game .game-bar button:hover:not(:disabled) { background: #ffffff16; }
#game .game-bar button:disabled { opacity: 0.5; }
#game .game-bar [data-action="new"] { border-color: #dfcba166; }
#game .game-felt {
  display: flex;
  flex-direction: column;
  min-height: 33rem;
  border-radius: 0 0 14px 14px;
  border: 1px solid #153a2c;
  padding: clamp(0.5rem, 2vw, 1.4rem);
  background:
    radial-gradient(ellipse at 42% 0, #638e6650, transparent 74%),
    repeating-linear-gradient(30deg, #ffffff03 0 1px, #00000004 1px 3px),
    linear-gradient(160deg, var(--felt), var(--felt-deep));
  box-shadow: inset 0 0 0 4px #ffffff06, 0 7px 22px #15352725;
}
#game .game-info, #game .game-metrics, #game .game-variant, #game .game-variant form {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
#game .game-info {
  justify-content: space-between;
  flex-wrap: wrap;
  min-height: 2.5rem;
  margin: 0 0 0.7rem;
  color: #f6efd9;
  font-size: 0.93rem;
}
#game .game-variant a { color: #f6d88d; }
#game .game-metrics { font-variant-numeric: tabular-nums; }
#game .game-metrics span { white-space: nowrap; }
#game .game-metrics span + span::before { content: "·"; margin-right: 0.55rem; opacity: 0.8; }
#game .game-variant input, #game .game-variant select {
  max-width: 6.25rem;
  min-height: 34px;
  padding: 0.2rem 0.25rem;
  color: var(--paper);
  background: var(--felt-deep);
  border: 1px solid #d6e1cb60;
  border-radius: 5px;
}
#game .game-variant button { min-height: 34px; border-color: #d6e1cb60; }
#game .game-piles {
  width: min(100%, 700px);
  margin: 0 auto;
}
#game[data-game^="spider"] .game-piles { width: min(100%, 840px); }
#game .game-top, #game .game-tableau {
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: var(--board-gap);
}
#game .game-top { margin-bottom: clamp(1.05rem, 3vw, 2rem); }
#game .game-supply, #game .game-foundations {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--board-gap);
}
#game .game-supply { grid-column: span 3; grid-template-columns: repeat(3, minmax(0, 1fr)); }
#game .game-foundations { grid-column: span 4; }
#game[data-game="freecell"] .game-supply {
  grid-column: span 4;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#game[data-game^="spider"] .game-supply { grid-column: span 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#game[data-game^="spider"] .game-foundations { grid-column: span 8; grid-template-columns: repeat(8, minmax(0, 1fr)); }
#game .game-column, #game .game-waste { min-width: 0; }
#game .game-column { display: flex; flex-direction: column; container-type: inline-size; }
#game .game-waste { position: relative; container-type: inline-size; }
#game .game-waste > .card { position: absolute; left: calc(var(--spread, 0) * 25%); top: 0; }
#game .card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 0.735;
  border: 1px solid #1c392a70;
  border-radius: var(--card-radius);
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
#game .card.face {
  color: #182821;
  background: linear-gradient(146deg, #fffdf8 0 67%, #f3ead7);
  box-shadow: 0 2px 4px #0007, inset 0 0 0 1px #fff6;
}
#game .card.face:disabled { opacity: 1; }
#game .card.face:not(:disabled) { touch-action: none; }
#game .card.red { color: #a41c37; }
#game.four-colour .card[data-suit="C"] { color: #176442; }
#game.four-colour .card[data-suit="D"] { color: #205597; }
#game .card-index {
  position: absolute;
  top: 5%;
  left: 9%;
  display: flex;
  align-items: baseline;
  gap: 0.08em;
  z-index: 1;
  font-weight: 760;
  font-size: clamp(0.72rem, 2.6vw, 1.65rem);
  letter-spacing: -0.06em;
  line-height: 1.05;
}
#game .card-index .pip { font-size: 0.86em; }
#game .card-mark {
  position: absolute;
  right: 11%;
  bottom: 6%;
  font-size: clamp(0.95rem, 4.2vw, 3rem);
  line-height: 0.94;
  opacity: 0.82;
}
#game .card.back {
  background:
    linear-gradient(140deg, #213e51, #162a39);
  border-color: #a6b9b784;
  box-shadow: 0 2px 4px #0007;
}
#game .card.back::after {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: calc(var(--card-radius) * 0.6);
  border: 1px solid #cfcb9e8c;
  background:
    repeating-linear-gradient(45deg, #e2c78531 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, #e2c78531 0 1px, transparent 1px 7px);
}
#game .card.slot {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: #f2d78bda;
  background: #051d1450;
  font-size: clamp(0.95rem, 3vw, 2rem);
}
#game .card.overlapped { margin-bottom: calc(-136.055cqw + clamp(23px, 2.6vw, 28px)); }
#game .card.back.overlapped { margin-bottom: calc(-136.055cqw + clamp(8px, 1.15vw, 14px)); }
#game .card.overlapped:focus-visible { z-index: 0; outline-offset: -2px; }
#game .card.selected, #game .card.suggested {
  outline: 2px solid #e5c879;
  outline-offset: -2px;
}
#game .card.suggested { outline-style: dashed; }
#game .card.selected { background: #f8e7b4; }
#game .stock-count {
  position: absolute;
  right: 5%;
  bottom: 4%;
  z-index: 1;
  background: #192f39;
  border: 1px solid #ebdea788;
  border-radius: 3px;
  color: #fff4d5;
  font-size: clamp(0.64rem, 1.4vw, 0.85rem);
  font-weight: 700;
  padding: 0 0.18em;
}
#game .game-message {
  min-height: 1.3em;
  margin-top: auto;
  padding-top: 1rem;
  color: #f5df9e;
  font-size: 0.94rem;
}
#game .game-drag {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  opacity: 0.9;
}
#game .game-drag .card { position: absolute; left: 0; }
#game .game-dialog {
  max-width: min(32rem, calc(100% - 2rem));
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #bcad8f;
  border-radius: 12px;
  box-shadow: 0 20px 70px #0006;
  padding: 1.4rem;
}
#game .game-dialog::backdrop { background: #091e18ba; }
#game .game-dialog h2 { margin: 0 0 0.75rem; }
#game .game-dialog label { display: block; padding: 0.3rem 0; }
#game .game-dialog .dialog-actions { align-items: center; }
#game .game-dialog button, #game .game-dialog a {
  border-color: #c4b99c;
  padding: 0.52rem 0.65rem;
}
#game .game-dialog .game-primary { color: #fffaf0; background: #1a513d; border-color: #1a513d; }
#game .game-dialog dl { display: grid; grid-template-columns: 1fr auto; gap: 0.45rem 1.1rem; }
#game .game-dialog dd { margin: 0; font-weight: 700; text-align: right; }
#share-fallback { max-width: min(32rem, calc(100% - 2rem)); }
#share-fallback textarea { display: block; width: 100%; }

@media (max-width: 600px) {
  #game { min-height: 32rem; }
  #game .game-felt { min-height: 26rem; }
  #game .game-bar { font-size: 0.8rem; padding: 0.3rem; gap: 0.15rem; }
  #game .game-actions, #game .game-options { gap: 0.1rem; }
  #game .game-bar button { padding-inline: 0.36rem; }
  #game .game-info { font-size: 0.83rem; }
  #game .game-dialog .dialog-actions { gap: 0.45rem; }
}
@media (max-width: 400px) {
  #game[data-game^="spider"] .card-index { left: 6%; font-size: 0.68rem; }
  #game .game-variant, #game .game-variant form { gap: 0.25rem; }
  #game .game-variant input { max-width: 4.4rem; }
}
