:root {
  --sky: #1ca4f4;
  --yellow: #ffde59;
  --gold: #f6ba2f;
  --cream: #fff7e8;
  --green: #18b367;
  --dark-green: #078442;
  --purple: #9747ff;
  --ink: #111111;
  --shadow: 4px 4px 0 var(--ink);
  --card-w: clamp(74px, 8.4vw, 116px);
  --card-h: calc(var(--card-w) * 1.4);
  --stack-gap: clamp(21px, 2.55vw, 34px);
  --waste-gap: clamp(19px, 2.1vw, 27px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  background:
    linear-gradient(180deg, rgba(28, 164, 244, 0.92) 0 52%, rgba(24, 179, 103, 0.92) 52% 100%),
    url("./assets/bg.fcfc94519d61898b94b0.png") center bottom / cover fixed no-repeat;
  color: var(--ink);
  font-family: Chewy, system-ui, sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  position: relative;
  padding: 4px clamp(10px, 2.6vw, 28px) 12px;
}

.game-topbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
  position: relative;
  z-index: 10;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup img {
  width: min(145px, 34vw);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(2px 3px 0 var(--ink));
}

.brand-lockup span,
.score-strip,
.controls button,
.pile-label,
.win-card h1 {
  letter-spacing: 0.04em;
}

.brand-lockup span {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px 9px 3px;
  transform: rotate(-2deg);
  white-space: nowrap;
}

.score-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px 10px;
  text-align: center;
}

.score-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}

.score-strip span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--yellow);
  border: 2px solid var(--ink);
}

.controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.controls button,
.win-card button {
  cursor: pointer;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 7px 10px 5px;
  min-width: 72px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.controls button:hover,
.win-card button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 6px 6px 0 var(--ink);
}

.controls button:disabled,
.win-card button:disabled {
  cursor: not-allowed;
  background: #b8b8b8;
  color: rgba(17, 17, 17, 0.56);
  box-shadow: 2px 2px 0 rgba(17, 17, 17, 0.68);
  transform: none;
}

.hero-strip {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.hero-dog {
  position: absolute;
  right: clamp(6px, 2vw, 44px);
  bottom: clamp(10px, 3vw, 42px);
  width: clamp(130px, 20vw, 255px);
  filter: drop-shadow(5px 5px 0 var(--ink));
  z-index: 3;
}

.dog-bubble {
  position: absolute;
  right: clamp(130px, 19vw, 255px);
  bottom: clamp(160px, 22vw, 285px);
  max-width: min(230px, 42vw);
  padding: 10px 14px 8px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  background: var(--cream);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(17px, 2.1vw, 26px);
  line-height: 1.05;
  text-align: center;
  opacity: 0;
  transform: translateY(8px) rotate(-3deg) scale(0.92);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 4;
}

.dog-bubble::after {
  content: "";
  position: absolute;
  right: 28px;
  bottom: -18px;
  width: 28px;
  height: 28px;
  background: var(--cream);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}

.dog-bubble.show {
  opacity: 1;
  transform: translateY(0) rotate(-2deg) scale(1);
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg);
  }
  50% {
    transform: translateY(-14px) rotate(-2deg);
  }
}

.board-wrap {
  position: relative;
  z-index: 3;
  margin-top: -14px;
  overflow-x: auto;
  padding: 14px 4px 12px;
}

.board {
  width: min(100%, 1240px);
  min-height: 0;
  margin: 0 auto;
}

.top-row {
  display: grid;
  grid-template-columns: var(--card-w) calc(var(--card-w) + 2 * var(--waste-gap)) 1fr repeat(4, var(--card-w));
  gap: clamp(10px, 1.6vw, 18px);
  align-items: start;
}

.spacer {
  min-width: 20px;
}

.foundations {
  display: contents;
}

.tableau {
  display: grid;
  grid-template-columns: repeat(7, var(--card-w));
  gap: clamp(10px, 1.6vw, 18px);
  margin-top: 14px;
  align-items: start;
}

.pile {
  position: relative;
  min-width: var(--card-w);
  min-height: var(--card-h);
  border-radius: 12px;
}

.stock {
  cursor: pointer;
  padding: 0;
}

.tableau-pile {
  min-height: var(--card-h);
}

.stock.empty::before {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(17, 17, 17, 0.54);
  font-size: clamp(15px, 2vw, 22px);
  text-align: center;
  border-radius: 12px;
  background: rgba(255, 247, 232, 0.12);
}

.empty-foundation {
  border: 3px dashed rgba(17, 17, 17, 0.62);
  background: rgba(255, 247, 232, 0.2);
}

.empty-tableau {
  border: 3px dashed rgba(17, 17, 17, 0.62);
  background: rgba(255, 247, 232, 0.16);
}

.foundation-placeholder {
  position: absolute;
  inset: 18%;
  width: 64%;
  height: 64%;
  object-fit: contain;
  opacity: 0.42;
  filter: grayscale(0.2);
}

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--ink);
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  transform: rotate(var(--tilt, -0.5deg));
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.card.face-up {
  background: var(--cream);
}

.card.face-down {
  background:
    radial-gradient(circle at center, rgba(255, 247, 232, 0.34) 0 24%, transparent 25%),
    linear-gradient(135deg, var(--yellow), var(--gold));
}

.card.face-down::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background:
    url("./assets/hero.2154f4b435a7e3aefd46.png") center 58% / 76% auto no-repeat,
    rgba(255, 247, 232, 0.32);
}

.card.selected {
  transform: translateY(-9px) rotate(1deg);
  box-shadow: 7px 7px 0 var(--purple);
  outline: 4px solid var(--yellow);
}

.card.valid-target,
.pile.valid-target {
  outline: 4px solid var(--purple);
  outline-offset: 3px;
}

.tableau-pile.valid-target {
  border: 3px dashed var(--purple);
  background: rgba(255, 247, 232, 0.18);
  outline: none;
}

.corner-rank,
.corner-suit {
  position: absolute;
  z-index: 2;
}

.corner-rank {
  top: 5px;
  left: 7px;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(20px, 2.35vw, 30px);
  line-height: 1;
}

.corner-suit {
  top: 5px;
  right: 6px;
  width: clamp(21px, 2.25vw, 30px);
  height: clamp(21px, 2.25vw, 30px);
  object-fit: contain;
}

.center-rank {
  position: absolute;
  display: grid;
  inset: 0;
  place-items: center;
  color: var(--suit);
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(35px, 5vw, 62px);
  line-height: 1;
  text-shadow: 2px 2px 0 #ffffff;
  z-index: 3;
  transform: translateY(7%);
}

.card.yellow {
  --suit: #c58c00;
}

.card.green {
  --suit: #098d48;
}

.card .corner-rank {
  color: var(--suit);
  text-shadow: 1px 1px 0 #ffffff;
}

.waste {
  min-width: calc(var(--card-w) + 2 * var(--waste-gap));
}

.waste-preview-card {
  cursor: default;
}

.card.face-card::after {
  content: none;
}

.card.foundation-top::after {
  opacity: 0.28;
}

.win-modal,
.choice-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(17, 17, 17, 0.42);
  z-index: 30;
  padding: 20px;
}

.win-card,
.mode-card {
  width: min(560px, 94vw);
  text-align: center;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 14px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 18px;
  transform: rotate(-0.5deg);
}

.win-card img {
  width: min(342px, 70vw, 39dvh);
  height: auto;
  object-fit: contain;
  margin: -18px auto -4px;
  display: block;
}

.win-modal[data-mode="hard"] .win-card img {
  width: min(324px, 67vw, 37dvh);
  margin: -18px auto 0;
}

.win-card h1 {
  margin: 0;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(46px, 9vw, 84px);
}

.win-card p {
  margin: 4px 0 18px;
  font-size: 24px;
}

.modal-copy {
  margin: -4px 0 16px;
  font-size: 24px;
}

.mode-card h1 {
  margin: 0 0 14px;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(42px, 8vw, 70px);
}

.mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.mode-option {
  cursor: pointer;
  min-height: 120px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 14px 10px 10px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.mode-option:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 6px 6px 0 var(--ink);
}

.mode-option span {
  display: block;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
}

.mode-option small {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mode-option.compact {
  min-height: 72px;
  font-family: Luckiest Guy, Chewy, sans-serif;
  font-size: clamp(22px, 3vw, 34px);
}

.mode-option.secondary {
  background: var(--cream);
}

.quiet-button {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: rgba(17, 17, 17, 0.72);
  padding: 8px 12px 4px;
}

@media (max-width: 900px) {
  .game-topbar {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .controls {
    justify-content: flex-start;
  }

  .score-strip {
    justify-content: flex-start;
  }

  .hero-dog {
    opacity: 0.28;
  }
}

@media (max-width: 620px) {
  :root {
    --card-w: clamp(43px, 13.6vw, 54px);
    --stack-gap: clamp(16px, 5vw, 22px);
    --waste-gap: clamp(6px, 2vw, 9px);
    --shadow: 3px 3px 0 var(--ink);
  }

  body {
    background:
      linear-gradient(180deg, rgba(28, 164, 244, 0.93) 0 48%, rgba(24, 179, 103, 0.93) 48% 100%),
      url("./assets/bg-mobile.45d01f125b177e7252ec.png") center bottom / cover fixed no-repeat;
  }

  .app-shell {
    padding: 4px 2px 10px;
    overflow-x: hidden;
  }

  .game-topbar {
    gap: 6px;
  }

  .brand-lockup {
    flex-wrap: wrap;
    gap: 6px;
  }

  .brand-lockup img {
    width: min(125px, 38vw);
  }

  .brand-lockup span {
    border-width: 2px;
    border-radius: 8px;
    padding: 4px 8px 2px;
  }

  .score-strip {
    justify-content: center;
    gap: 5px;
    border-width: 2px;
    border-radius: 8px;
    padding: 5px 7px 3px;
    font-size: clamp(14px, 4vw, 18px);
  }

  .score-strip span {
    min-height: 20px;
  }

  .score-strip span:not(:last-child)::after {
    width: 6px;
    height: 6px;
    margin-left: 5px;
    border-width: 1px;
  }

  .controls button {
    flex: 1 1 0;
    min-width: 0;
    border-width: 2px;
    border-radius: 8px;
    padding: 6px 4px 4px;
    font-size: clamp(14px, 4.2vw, 18px);
  }

  .hero-dog {
    right: -12px;
    bottom: 6px;
    width: clamp(96px, 31vw, 140px);
    opacity: 0.46;
  }

  .dog-bubble {
    right: clamp(82px, 26vw, 130px);
    bottom: clamp(100px, 32vw, 145px);
    max-width: min(170px, 52vw);
    padding: 8px 10px 6px;
    border-width: 2px;
    border-radius: 12px;
    font-size: clamp(14px, 4vw, 18px);
  }

  .dog-bubble::after {
    right: 20px;
    bottom: -12px;
    width: 18px;
    height: 18px;
    border-right-width: 2px;
    border-bottom-width: 2px;
  }

  .board-wrap {
    margin-top: -6px;
    overflow-x: hidden;
    padding: 12px 0 8px;
  }

  .board {
    width: 100%;
    max-width: 100%;
  }

  .top-row,
  .tableau {
    grid-template-columns: repeat(7, var(--card-w));
    gap: clamp(1px, 0.35vw, 2px);
    justify-content: center;
  }

  #stock {
    grid-column: 1;
  }

  #waste {
    grid-column: 2 / span 2;
    min-width: 100%;
  }

  .spacer {
    display: none;
  }

  .tableau {
    margin-top: 10px;
  }

  .pile {
    border-radius: 8px;
  }

  .empty-foundation,
  .empty-tableau {
    border-width: 2px;
  }

  .stock.empty::before {
    font-size: clamp(12px, 3.4vw, 15px);
  }

  .foundation-placeholder {
    inset: 17%;
    width: 66%;
    height: 66%;
  }

  .card {
    border-width: 2px;
    border-radius: 8px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .card.face-down::before {
    inset: 8px;
    border-width: 2px;
    border-radius: 8px;
  }

  .card.selected {
    outline-width: 3px;
    box-shadow: 4px 4px 0 var(--purple);
  }

  .card.valid-target,
  .pile.valid-target {
    outline-width: 3px;
  }

  .corner-rank {
    top: 2px;
    left: 3px;
    font-size: clamp(14px, 4.2vw, 18px);
  }

  .corner-suit {
    top: 3px;
    right: 3px;
    width: clamp(13px, 3.7vw, 16px);
    height: clamp(13px, 3.7vw, 16px);
  }

  .center-rank {
    font-size: clamp(25px, 7.8vw, 34px);
    transform: translateY(9%);
    z-index: 3;
  }

  .mode-options {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

  .board {
    min-height: 0;
  }
}
