.solitaire-shell {
  width: min(100%, 58rem);
  height: var(--game-visible-height, 100dvh);
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.solitaire-stage { min-height: 0; height: 100%; grid-template-rows: auto minmax(0, 1fr); align-content: stretch; place-items: stretch; overflow: hidden; }
.play-options { min-height: 2.25rem; margin: 0 0 .35rem; display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.game-help { min-height: 1.4rem; margin: 0; color: var(--muted); font-size: .8rem; font-weight: 700; text-align: right; }
.game-help.hint-pop { animation: hint-pop .35s ease; }
.draw-toggle { flex: none; display: inline-flex; align-items: center; gap: .18rem; padding: .18rem; border: 1px solid #c9c0b2; border-radius: .65rem; background: var(--panel); box-shadow: 2px 2px 0 rgba(23,50,77,.1); }
.draw-toggle span { padding: 0 .38rem; color: var(--muted); font-size: .65rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.draw-toggle button { width: 2.25rem; min-height: 1.8rem; border: 0; border-radius: .45rem; background: transparent; color: #17324d; cursor: pointer; font-weight: 900; }
.draw-toggle button[aria-pressed="true"] { background: #17324d; color: #fffdf8; box-shadow: inset 0 -2px rgba(0,0,0,.18); }
.draw-toggle button:focus-visible { outline: 3px solid var(--danger); outline-offset: 2px; }
.solitaire-board { --stack-step: clamp(.42rem, 1.7cqh, 1rem); --face-step: clamp(.36rem, 1.5cqh, .9rem); width: 100%; max-width: min(100%, 165cqh); height: 100%; min-height: 0; justify-self: center; padding: clamp(.45rem, 1.5vw, .85rem); display: flex; flex-direction: column; overflow: hidden; border: 2px solid #17324d; border-radius: 1rem; background: #277565; box-shadow: inset 0 0 0 4px rgba(255,255,255,.09), 5px 5px 0 rgba(23,50,77,.13); touch-action: none; }
.top-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(.25rem, 1vw, .65rem); align-items: start; }
.stock-zone { grid-column: 1; }
.waste-zone { grid-column: 2; }
.top-spacer { grid-column: 3; }
.foundation-row { grid-column: 4 / span 4; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(.25rem, 1vw, .65rem); }
.pile-zone, .foundation-row { min-height: 0; }
.waste-zone { position: relative; }
.tableau { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: clamp(.2rem, .8vw, .55rem); margin-top: clamp(.75rem, 2vw, 1.2rem); }
.tableau-pile { position: relative; min-width: 0; min-height: 0; height: 100%; }
.playing-card, .empty-pile { width: 100%; height: auto; }
.playing-card { font-size: clamp(.68rem, 2.2vw, 1.25rem); }
.empty-pile { aspect-ratio: 1 / 1.42; padding: 0; border-radius: clamp(.3rem, .8vw, .55rem); cursor: pointer; }
.empty-pile:focus-visible { z-index: 90 !important; outline: 3px solid #ffd65a; outline-offset: 2px; }
.playing-card.dragging-source { opacity: .48; }
.card-drag-ghost { position: fixed; z-index: 1000; width: var(--drag-width); height: var(--drag-height); margin: 0; pointer-events: none; opacity: .92; transform: translate(-50%, -42%) rotate(2deg) scale(1.04); box-shadow: 0 12px 24px rgba(8,29,35,.38), 0 0 0 3px #ffd65a; }
.card-drag-ghost::after { content: attr(data-card-count); position: absolute; right: -.45rem; bottom: -.45rem; display: grid; place-items: center; min-width: 1.45rem; height: 1.45rem; padding: 0 .25rem; border-radius: 999px; background: #ffd65a; color: #17324d; font-size: .75rem; font-weight: 950; }
.card-drag-ghost[data-card-count="1"]::after { display: none; }
.empty-pile { display: grid; place-items: center; border: 2px dashed rgba(255,255,255,.38); background: rgba(8,49,44,.15); color: rgba(255,255,255,.44); font-family: Georgia, serif; font-size: clamp(1.15rem, 3vw, 2rem); font-weight: 800; }
.empty-pile:not(:disabled):hover { background: rgba(255,255,255,.08); }
.empty-pile.recycle { color: rgba(255,255,255,.72); font-family: inherit; font-size: clamp(1.6rem, 5vw, 2.7rem); }
.empty-pile:disabled { cursor: default; opacity: .6; }
.tableau-pile .playing-card { position: absolute; top: calc(var(--card-index) * var(--stack-step) + var(--face-offsets) * var(--face-step)); left: 0; z-index: calc(var(--card-index) + 1); }
.waste-card { position: absolute; inset: 0 auto auto calc(var(--waste-index) * min(1.2rem, 1.7vw)); z-index: calc(var(--waste-index) + 1); }
.waste-card:disabled { opacity: 1; }
.tableau-pile > .empty-pile { position: absolute; inset: 0 auto auto 0; }
.action-button:disabled { cursor: default; opacity: .42; transform: none; box-shadow: none; }
@keyframes hint-pop { 50% { color: #17324d; transform: scale(1.025); } }
@keyframes deal-card {
  0% { opacity: 0; transform: translate(-9rem, -7rem) rotate(-14deg) scale(.72); }
  72% { opacity: 1; transform: translate(.12rem, -.2rem) rotate(1.5deg) scale(1.03); }
  100% { transform: translate(0) rotate(0) scale(1); }
}
@keyframes draw-card {
  0% { opacity: .2; transform: translateX(-100%) rotate(-8deg) scale(.88); }
  70% { transform: translateX(.18rem) rotate(2deg) scale(1.03); }
  100% { opacity: 1; transform: translateX(0) rotate(0) scale(1); }
}
@keyframes recycle-card {
  0% { opacity: .25; transform: translateX(100%) rotate(12deg); }
  70% { transform: translateX(-.12rem) rotate(-2deg); }
}
@keyframes home-card {
  0% { transform: translateY(2.5rem) rotate(-10deg) scale(.72); opacity: .35; }
  62% { transform: translateY(-.35rem) rotate(3deg) scale(1.12); opacity: 1; box-shadow: 0 0 0 8px rgba(255,214,90,.45), 0 0 2rem #ffd65a; }
  100% { transform: translateY(0) rotate(0) scale(1); }
}
.deal-arrival { animation: deal-card .42s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--deal-order) * 22ms); }
.draw-arrival { animation: draw-card .36s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--waste-index) * 55ms); }
.recycle-arrival { animation: recycle-card .42s cubic-bezier(.2,.8,.2,1) both; }
.home-arrival { animation: home-card .56s cubic-bezier(.2,.85,.2,1) both; }

@media (max-width: 620px) {
  .solitaire-shell { padding-left: .4rem; padding-right: .4rem; gap: .55rem; }
  .solitaire-board { min-height: 0; border-radius: .7rem; padding: .35rem; }
  .scorebar { padding: .55rem .7rem; }
  .play-options { align-items: stretch; }
  .game-help { align-self: center; font-size: .7rem; line-height: 1.25; }
  .draw-toggle span { display: none; }
  .draw-toggle button { width: 2rem; }
  .metric-value { font-size: 1rem; }
  .top-row, .foundation-row { gap: .18rem; }
  .top-spacer { min-width: 0; }
  .tableau { gap: .12rem; margin-top: .65rem; }
  .tableau-pile { min-height: 0; }
  .playing-card { font-size: clamp(.62rem, 3vw, .85rem); }
  .game-actions { gap: .35rem; }
  .game-actions .action-button { min-width: 0; padding: .55rem .75rem; font-size: .85rem; }
}

@media (max-height: 620px) and (orientation: landscape) {
  .solitaire-shell { width: min(100%, 72rem); grid-template-columns: 14rem 1fr; }
  .solitaire-stage { grid-column: 2; grid-row: 1 / span 3; }
  .solitaire-board { min-height: 0; }
  .game-help { display: none; }
  .tableau-pile { min-height: 0; }
  .game-actions .action-button { padding: .35rem .25rem; font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .deal-arrival, .draw-arrival, .recycle-arrival, .home-arrival { animation: none; }
}
