:root {
  color-scheme: light;
  --felt: #0b6843;
  --felt-dark: #06442d;
  --felt-line: rgba(255, 255, 255, 0.055);
  --panel: rgba(8, 42, 30, 0.82);
  --panel-border: rgba(255, 255, 255, 0.18);
  --text: #f7fbf8;
  --muted: rgba(247, 251, 248, 0.72);
  --card: #fffdf7;
  --card-edge: rgba(20, 23, 25, 0.24);
  --black-suit: #15171c;
  --red-suit: #c3232f;
  --gold: #f7cc5b;
  --blue-back: #174d9a;
  --blue-back-dark: #0d2d68;
  --shadow: 0 13px 28px rgba(0, 0, 0, 0.26);
  --card-w: clamp(48px, 10.5vw, 110px);
  --card-h: calc(var(--card-w) * 1.42);
  --gap: clamp(6px, 1.1vw, 16px);
  --stack-gap: clamp(18px, 3vw, 32px);
  --waste-offset: clamp(16px, 2.8vw, 34px);
  --radius: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--felt-dark);
  background-size: 24px 24px, 24px 24px, auto;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(7, 72, 48, 0.94), rgba(4, 55, 37, 0.92) 44%, rgba(3, 43, 31, 0.98)),
    var(--felt);
}

.app-bar {
  display: grid;
  grid-template-columns: auto minmax(250px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: rgba(4, 36, 27, 0.9);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: clamp(1.05rem, 1.7vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-mark {
  width: 24px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 5px;
  background:
    linear-gradient(135deg, transparent 43%, rgba(255, 255, 255, 0.9) 44%, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
    linear-gradient(45deg, transparent 43%, rgba(255, 255, 255, 0.9) 44%, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
    linear-gradient(135deg, #2e70c9, #0c2f70);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.25);
  transform: rotate(-7deg);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  justify-self: center;
  width: min(100%, 520px);
}

.status-item {
  display: grid;
  gap: 1px;
  padding: 7px 10px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  min-width: 0;
}

.status-item span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.05;
}

.status-item strong {
  font-size: clamp(0.92rem, 1.2vw, 1.12rem);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.language-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.language-button img {
  display: block;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(20, 23, 25, 0.18);
}

.language-button:hover,
.language-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
}

.language-button.is-active {
  border-color: rgba(247, 204, 91, 0.62);
  background: rgba(247, 204, 91, 0.18);
}

.tool-button,
.select-wrap select,
.dialog-close {
  min-height: 36px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, 0.11);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
}

.tool-button.icon-only {
  width: 38px;
  padding: 0;
  font-size: 1.05rem;
}

.tool-button.primary {
  color: #1f2519;
  background: linear-gradient(180deg, #ffe28d, #f4bd3e);
  border-color: rgba(59, 45, 12, 0.25);
}

.tool-button:disabled {
  opacity: 0.42;
  cursor: default;
}

.tool-button:not(:disabled):hover,
.select-wrap select:hover,
.dialog-close:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.tool-button.primary:not(:disabled):hover {
  background: linear-gradient(180deg, #ffe99f, #f7ca5b);
}

.button-icon {
  font-size: 1.05em;
  line-height: 1;
}

.select-wrap {
  display: inline-flex;
}

.select-wrap select,
.field select {
  appearance: none;
  padding: 0 31px 0 10px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 16px,
    calc(100% - 10px) 16px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.select-wrap select option,
.field select option {
  color: #18221d;
  background: #fffdf7;
}

.select-wrap select option:checked,
.field select option:checked {
  color: #18221d;
  background: #f7cc5b;
}

.game-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: clamp(8px, 1.8vw, 20px);
  padding-bottom: max(34px, clamp(8px, 1.8vw, 20px));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.board {
  position: relative;
  width: min(100%, calc((var(--card-w) * 7) + (var(--gap) * 6)));
  min-height: calc(var(--card-h) + (var(--stack-gap) * 18) + 92px);
  margin: 0 auto;
  outline: none;
  perspective: 900px;
}

.top-row,
.tableau-row {
  display: grid;
  grid-template-columns: repeat(7, var(--card-w));
  gap: var(--gap);
}

.top-row {
  align-items: start;
  margin-bottom: clamp(14px, 2.2vw, 28px);
}

.waste-area {
  grid-column: span 2;
  position: relative;
  min-height: var(--card-h);
  width: calc(var(--card-w) + (var(--waste-offset) * 2));
}

.foundation-rack {
  grid-column: span 4;
  display: grid;
  grid-template-columns: repeat(4, var(--card-w));
  gap: var(--gap);
}

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

.slot {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    rgba(3, 42, 29, 0.38);
  box-shadow: inset 0 1px 12px rgba(0, 0, 0, 0.2);
}

.slot.stock-slot {
  cursor: pointer;
}

.slot.is-empty-stock::before {
  content: "";
  width: 44%;
  height: 44%;
  border: 3px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
}

.slot-placeholder {
  color: rgba(255, 255, 255, 0.22);
  font-size: calc(var(--card-w) * 0.48);
  line-height: 1;
}

.pile {
  min-height: calc(var(--card-h) + var(--stack-gap) * 2);
}

.pile::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.055);
}

.card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  border: 1px solid var(--card-edge);
  box-shadow: var(--shadow);
  touch-action: none;
  transform: translateZ(0);
  transform-style: preserve-3d;
  transition: opacity 130ms ease, filter 130ms ease, box-shadow 160ms ease;
  -webkit-touch-callout: none;
}

.card.face-up {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 252, 242, 0.98)),
    var(--card);
  cursor: grab;
}

.card.face-up:active {
  cursor: grabbing;
}

.card.face-down {
  cursor: default;
  background:
    linear-gradient(135deg, transparent 44%, rgba(255, 255, 255, 0.8) 45%, rgba(255, 255, 255, 0.8) 50%, transparent 51%),
    linear-gradient(45deg, transparent 44%, rgba(255, 255, 255, 0.75) 45%, rgba(255, 255, 255, 0.75) 50%, transparent 51%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.13) 0 1px, transparent 1px 9px),
    linear-gradient(160deg, var(--blue-back), var(--blue-back-dark));
  background-size: 20px 20px, 20px 20px, auto, auto;
  overflow: hidden;
}

.card.face-down::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 2px solid rgba(255, 255, 255, 0.66);
  border-radius: calc(var(--radius) - 2px);
  box-shadow: inset 0 0 0 2px rgba(11, 49, 122, 0.55);
}

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

.card.black {
  color: var(--black-suit);
}

.card.blocked {
  cursor: default;
}

.card.is-selected {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.card.is-hinted,
.slot.is-hinted,
.pile.is-hinted::before {
  animation: hintPulse 1s ease-in-out infinite;
}

.card.is-drag-origin {
  opacity: 0.32;
  filter: saturate(0.9) brightness(0.98);
}

.card.is-flipping {
  animation: cardFlipIn 430ms cubic-bezier(0.2, 0.82, 0.2, 1);
  transform-origin: center center;
}

.card.is-settling {
  animation: cardSettle 210ms cubic-bezier(0.18, 0.82, 0.32, 1);
}

.game-notice {
  display: grid;
  gap: 4px;
  width: min(100%, calc((var(--card-w) * 5) + (var(--gap) * 4)));
  margin: clamp(18px, 3vw, 28px) auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(247, 204, 91, 0.44);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(4, 29, 22, 0.78);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.23);
}

.game-notice strong {
  font-size: clamp(0.96rem, 1.5vw, 1.12rem);
  line-height: 1.2;
}

.game-notice span,
.game-notice small {
  color: var(--muted);
  line-height: 1.35;
}

.game-notice small {
  font-size: 0.78rem;
}

.card-corner {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 0;
  font-weight: 800;
  line-height: 0.86;
  font-size: clamp(0.56rem, calc(var(--card-w) * 0.18), 1.08rem);
}

.card-corner.top {
  top: 7%;
  left: 8%;
}

.card-corner.bottom {
  right: 8%;
  bottom: 7%;
  transform: rotate(180deg);
}

.corner-suit {
  font-size: 0.92em;
}

.pip-grid {
  position: absolute;
  inset: 18% 18% 16%;
}

.pip {
  position: absolute;
  font-size: clamp(0.78rem, calc(var(--card-w) * 0.24), 1.7rem);
  line-height: 1;
  transform: translate(-50%, -50%);
}

.pos-1 { left: 26%; top: 17%; }
.pos-2 { left: 50%; top: 17%; }
.pos-3 { left: 74%; top: 17%; }
.pos-4 { left: 26%; top: 38%; }
.pos-5 { left: 50%; top: 50%; }
.pos-6 { left: 74%; top: 62%; }
.pos-7 { left: 26%; top: 83%; }
.pos-8 { left: 50%; top: 83%; }
.pos-9 { left: 74%; top: 83%; }
.pos-10 { left: 74%; top: 38%; }
.pos-11 { left: 26%; top: 62%; }

.pip.inverted {
  transform: translate(-50%, -50%) rotate(180deg);
}

.ace-pip,
.court {
  display: grid;
  place-items: center;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.035);
  font-size: clamp(1.6rem, calc(var(--card-w) * 0.58), 4rem);
  line-height: 1;
}

.court {
  width: 58%;
  border-radius: var(--radius);
  font-weight: 850;
  font-size: clamp(1.25rem, calc(var(--card-w) * 0.43), 3.15rem);
  background:
    linear-gradient(135deg, rgba(247, 204, 91, 0.26), rgba(255, 255, 255, 0.06)),
    rgba(0, 0, 0, 0.035);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.court small {
  display: block;
  margin-top: -0.1em;
  font-size: 0.48em;
}

.drag-stack {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  width: var(--card-w);
  height: var(--card-h);
}

.drag-stack .card {
  opacity: 0.95;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.38);
}

.celebration-layer {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  pointer-events: none;
}

.celebration-card {
  --celebration-card-w: clamp(46px, 7.2vw, 82px);
  position: absolute;
  top: 0;
  left: 0;
  width: var(--celebration-card-w);
  height: calc(var(--celebration-card-w) * 1.42);
  opacity: 0;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
  transform-origin: center center;
  will-change: transform, opacity;
  animation: winCardFlight var(--flight-duration) cubic-bezier(0.12, 0.78, 0.24, 1) var(--flight-delay) both;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(4, 29, 22, 0.9);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, 18px);
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.legal-footer {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(4, 29, 22, 0.5);
  opacity: 0.68;
  backdrop-filter: blur(8px);
  transition: opacity 140ms ease, background-color 140ms ease;
}

.legal-footer:hover,
.legal-footer:focus-within {
  background: rgba(4, 29, 22, 0.86);
  opacity: 1;
}

.legal-footer a {
  color: rgba(247, 251, 248, 0.82);
  font-size: 0.72rem;
  line-height: 1.2;
  text-decoration: none;
}

.legal-footer a:hover,
.legal-footer a:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

.game-dialog {
  width: min(92vw, 440px);
  padding: 0;
  color: #18221d;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.game-dialog::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

.dialog-panel {
  overflow: hidden;
  border-radius: var(--radius);
  background: #fffdf7;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.38);
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
}

.dialog-header {
  border-bottom: 1px solid rgba(20, 23, 25, 0.1);
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.dialog-close {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: #18221d;
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.dialog-actions {
  border-top: 1px solid rgba(20, 23, 25, 0.1);
  justify-content: flex-end;
}

.dialog-actions .tool-button {
  color: #18221d;
  border-color: rgba(20, 23, 25, 0.16);
  background: rgba(0, 0, 0, 0.05);
}

.dialog-actions .tool-button.primary {
  background: linear-gradient(180deg, #ffe28d, #f4bd3e);
}

.legal-dialog {
  width: min(94vw, 780px);
}

.legal-panel {
  max-height: min(86svh, 760px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  user-select: text;
}

.legal-dialog-body {
  display: block;
  max-height: none;
  overflow: auto;
  padding: 18px;
}

.legal-document a,
.legal-page-toolbar a {
  color: #0a5f40;
  font-weight: 650;
  text-decoration: none;
}

.legal-document a:hover,
.legal-document a:focus-visible,
.legal-page-toolbar a:hover,
.legal-page-toolbar a:focus-visible {
  text-decoration: underline;
}

.legal-document {
  color: #18221d;
  font-size: 0.95rem;
  line-height: 1.55;
}

.legal-intro {
  margin: 0 0 16px;
  color: #3d4d45;
  font-weight: 650;
}

.legal-section {
  padding: 15px 0;
  border-top: 1px solid rgba(20, 23, 25, 0.1);
}

.legal-section h3 {
  margin: 0 0 8px;
  color: #18221d;
  font-size: 1rem;
  letter-spacing: 0;
}

.legal-section p {
  margin: 8px 0 0;
}

.legal-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.legal-list li + li {
  margin-top: 4px;
}

.legal-note {
  margin: 16px 0 0;
  color: #52615a;
  font-size: 0.88rem;
}

.legal-page {
  min-height: 100svh;
  overflow: auto;
  user-select: text;
}

.legal-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(7, 72, 48, 0.94), rgba(4, 55, 37, 0.92) 44%, rgba(3, 43, 31, 0.98)),
    var(--felt);
}

.legal-page-shell {
  width: min(100% - 28px, 900px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.legal-page-toolbar {
  margin-bottom: 10px;
}

.legal-page-toolbar a {
  color: rgba(247, 251, 248, 0.86);
}

.legal-page-card {
  padding: clamp(18px, 3vw, 30px);
  border-radius: var(--radius);
  background: #fffdf7;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
}

.legal-page-card h1 {
  margin: 0 0 10px;
  color: #18221d;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  letter-spacing: 0;
}

.field {
  display: grid;
  gap: 7px;
  color: #28352f;
  font-weight: 650;
}

.field select {
  min-height: 38px;
  border: 1px solid rgba(20, 23, 25, 0.18);
  border-radius: var(--radius);
  color: #18221d;
  background-color: #fff;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #28352f;
  font-weight: 650;
}

.switch input {
  width: 20px;
  height: 20px;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-card {
  padding: 10px;
  border: 1px solid rgba(20, 23, 25, 0.1);
  border-radius: var(--radius);
  background: rgba(11, 104, 67, 0.07);
}

.stats-card span {
  display: block;
  color: #52615a;
  font-size: 0.78rem;
}

.stats-card strong {
  display: block;
  margin-top: 2px;
  color: #18221d;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.win-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes hintPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(247, 204, 91, 0.95), var(--shadow);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(247, 204, 91, 0.18), var(--shadow);
  }
}

@keyframes cardFlipIn {
  0% {
    opacity: 0.52;
    transform: rotateY(82deg) scale(0.965);
    filter: brightness(0.82) saturate(0.92);
  }
  58% {
    opacity: 1;
    transform: rotateY(-8deg) scale(1.012);
    filter: brightness(1.04) saturate(1);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
    filter: none;
  }
}

@keyframes cardSettle {
  0% {
    transform: translateY(-8px) scale(0.992);
  }
  70% {
    transform: translateY(1px) scale(1.002);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes winCardFlight {
  0% {
    opacity: 0;
    transform: translate(var(--start-x), var(--start-y)) rotate(0deg) scale(0.78);
  }
  10% {
    opacity: 1;
  }
  32% {
    transform: translate(var(--mid-x), var(--mid-y)) rotate(var(--spin-a)) scale(1.05);
  }
  68% {
    opacity: 1;
    transform: translate(var(--late-x), var(--late-y)) rotate(var(--spin-b)) scale(0.98);
  }
  100% {
    opacity: 0;
    transform: translate(var(--end-x), var(--end-y)) rotate(var(--spin)) scale(0.88);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .toast,
  .legal-footer {
    transition-duration: 1ms;
  }

  .card.is-flipping,
  .card.is-settling,
  .card.is-hinted,
  .slot.is-hinted,
  .pile.is-hinted::before {
    animation: none;
  }
}

@media (pointer: coarse) {
  .tool-button,
  .select-wrap select,
  .language-button,
  .dialog-close,
  .field select {
    min-height: 44px;
  }

  .language-button {
    width: 42px;
  }

  .tool-button.icon-only {
    width: 44px;
  }

  .toolbar {
    gap: 8px;
  }

  .card.face-up {
    cursor: default;
  }
}

@media (max-width: 1020px) {
  .app-bar {
    grid-template-columns: 1fr auto;
  }

  .status-strip {
    order: 3;
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 720px) {
  :root {
    --gap: 4px;
    --card-w: calc((100vw - 44px) / 7);
    --stack-gap: clamp(17px, 5.2vw, 27px);
    --waste-offset: clamp(11px, 3.7vw, 22px);
  }

  body {
    overflow: auto;
  }

  .app {
    min-height: 100svh;
  }

  .app-bar {
    gap: 8px;
    padding-bottom: 8px;
  }

  .brand {
    font-size: 1.02rem;
  }

  .toolbar {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 1px;
    justify-content: flex-start;
    scrollbar-width: none;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .tool-button {
    min-height: 44px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .tool-button.icon-only {
    width: 44px;
    flex: 0 0 44px;
  }

  .select-wrap {
    flex: 0 0 auto;
  }

  .language-switch {
    flex: 0 0 auto;
  }

  .select-wrap select {
    min-height: 44px;
    min-width: 112px;
    max-width: 128px;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .status-item {
    padding: 6px 7px;
  }

  .game-shell {
    padding: 8px 10px 34px;
  }

  .top-row {
    margin-bottom: 14px;
  }

  .card-corner {
    font-size: clamp(0.48rem, calc(var(--card-w) * 0.18), 0.82rem);
  }
}

@media (max-width: 430px) {
  .app-bar {
    grid-template-columns: 1fr;
  }

  .brand {
    display: none;
  }

  .toolbar {
    grid-column: 1 / -1;
  }

  .tool-button:not(.icon-only) span:not(.button-icon),
  .brand span:last-child {
    display: none;
  }

  .tool-button.primary span:not(.button-icon) {
    display: inline;
  }

  .status-item span {
    font-size: 0.66rem;
  }

  .win-summary,
  .stats-panel {
    grid-template-columns: 1fr;
  }

  .legal-footer {
    gap: 8px;
    padding: 4px 7px;
  }

  .legal-footer a {
    font-size: 0.68rem;
  }
}
