:root {
  color-scheme: light;
  --page-bg: #f5f3ed;
  --text: #1f2933;
  --muted: #667085;
  --line: #d8ded6;
  --brand: #16613f;
  --brand-strong: #0d3f2a;
  --accent: #c8503f;
  --gold: #d7a541;
  --panel: #ffffff;
  --table: #176b47;
  --table-deep: #0f4d33;
  --table-line: rgba(255, 255, 255, 0.24);
  --card-width: 76px;
  --card-aspect-ratio: 2 / 3;
  --card-w: var(--card-width);
  --card-h: calc(var(--card-width) * 1.5);
  --card-gap: 12px;
  --stack-gap: 27px;
  --radius: 8px;
  --shadow: 0 9px 20px rgba(13, 35, 24, 0.18);
  --focus: #f7c948;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at center top, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 360px),
    var(--page-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
input {
  border-radius: var(--radius);
}

button {
  border: 1px solid rgba(22, 97, 63, 0.28);
  background: #ffffff;
  color: var(--brand-strong);
  min-height: 40px;
  padding: 8px 12px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

button:hover,
button:focus-visible {
  border-color: var(--brand);
  background: #f0faf5;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--brand-strong);
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
.pile:focus-visible,
.card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 30;
  background: #ffffff;
  color: var(--brand-strong);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: 12px;
}

.content-wrap {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.93);
  border-bottom: 1px solid rgba(22, 97, 63, 0.18);
  backdrop-filter: blur(10px);
}

.site-header__inner {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 800;
}

.brand__mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fffdf7;
  font-size: 15px;
  box-shadow: 0 7px 16px rgba(22, 97, 63, 0.28);
}

.brand__text {
  font-size: 22px;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: #2f4238;
}

.main-nav a:hover,
.main-nav a:focus-visible {
  background: #ecf7f1;
}

.intro-section {
  padding: 34px 0 14px;
}

.intro-section h1 {
  max-width: 780px;
  margin: 0 0 8px;
  color: #12261c;
  font-size: 42px;
  line-height: 1.08;
}

.intro-section p {
  max-width: 760px;
  margin: 0;
  color: #45564d;
  font-size: 18px;
}

.game-section {
  padding: 0 0 12px;
}

.game-shell {
  overflow: hidden;
  border: 1px solid rgba(16, 61, 40, 0.2);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(16, 39, 29, 0.14);
}

.game-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.game-topline h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.daily-status {
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid #f0d795;
  border-radius: var(--radius);
  background: #fff9e9;
  color: #665018;
  font-size: 14px;
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(105px, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.stats-bar div {
  min-width: 0;
  background: #fbfcfb;
  padding: 10px 12px;
}

.stats-bar span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats-bar strong {
  display: block;
  overflow: hidden;
  color: #26342e;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 0;
  background: #f8faf8;
}

.controls > button {
  margin-bottom: 12px;
}

.options-tab-button[aria-expanded="true"] {
  position: relative;
  z-index: 3;
  margin-bottom: -1px;
  padding-bottom: 13px;
  border-color: var(--line);
  border-bottom-color: #ffffff;
  border-radius: 8px 8px 0 0;
  background: #ffffff;
  color: var(--brand-strong);
  box-shadow: 0 -2px 7px rgba(20, 42, 31, 0.08);
}

.control-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
}

.control-primary:hover,
.control-primary:focus-visible {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
  color: #ffffff;
}

.controls__secondary-start {
  margin-left: auto;
}

.status-line {
  min-height: 32px;
  margin: 0;
  padding: 7px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: #34463c;
}

.settings-panel {
  margin: 0 16px 12px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 8px;
  background: #ffffff;
  box-shadow: 0 7px 16px rgba(20, 42, 31, 0.09);
}

.settings-panel.is-collapsed {
  display: none;
}

.options-section {
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #ffffff;
}

.options-section.is-relevant {
  border-color: rgba(11, 122, 69, 0.56);
  box-shadow: 0 0 0 2px rgba(11, 122, 69, 0.08);
}

.preference-section > summary {
  cursor: pointer;
  list-style: none;
}

.preference-section > summary::-webkit-details-marker {
  display: none;
}

.options-section__header {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #26342e;
}

.preference-section > summary::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transition: transform 140ms ease;
}

.preference-section[open] > summary::after {
  transform: rotate(225deg);
}

.options-section.is-relevant .options-section__header {
  background: #f0f8f3;
}

.options-section__heading {
  display: grid;
  gap: 1px;
  min-width: 0;
  margin-right: auto;
}

.options-section__heading strong {
  font-size: 15px;
}

.options-section__heading small {
  color: var(--muted);
  font-size: 12px;
}

.options-section__badge {
  display: none;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  text-transform: uppercase;
}

.options-section.is-relevant .options-section__badge {
  display: inline-flex;
}

.options-section__body {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.settings-grid label,
.settings-actions {
  min-width: 0;
}

.settings-grid span,
.check-row span {
  display: block;
  margin-bottom: 4px;
  color: #4c5b53;
  font-size: 13px;
  font-weight: 700;
}

.settings-grid select,
.settings-grid input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c8d3cb;
  background: #ffffff;
  color: #243129;
  padding: 7px 9px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

.preference-help {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(11, 122, 69, 0.46);
  border-radius: 0 6px 6px 0;
  background: rgba(11, 122, 69, 0.06);
  color: #46554d;
  font-size: 13px;
  line-height: 1.45;
}

.game-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}

.game-action-grid button {
  min-height: 42px;
}

.preference-section {
  margin-top: 14px;
  border: 1px solid #d7dfd9;
  border-radius: var(--radius);
  background: #fafcfb;
}

.preference-section > summary {
  position: relative;
  padding: 11px 38px 11px 12px;
  color: #34463c;
  font-size: 13px;
  font-weight: 800;
}

.preference-section > summary::after {
  right: 16px;
  top: 14px;
  width: 7px;
  height: 7px;
}

.preference-section > summary span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.preference-section__body {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check-row span {
  margin: 0;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.game-board {
  --placeholder-color: rgba(255, 255, 255, 0.55);
  position: relative;
  min-height: 560px;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--table);
  background-size: 28px 28px;
}

.game-board.is-paused::after {
  content: "Game paused";
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(10, 28, 20, 0.82);
  color: #ffffff;
  font-size: clamp(22px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

body.animations-off *,
body.animations-off *::before,
body.animations-off *::after {
  scroll-behavior: auto !important;
  transition-duration: 1ms !important;
  animation-duration: 1ms !important;
}

body.theme-blue .game-board {
  --table: #195f83;
  --table-deep: #113c59;
  --table-line: rgba(255, 255, 255, 0.22);
}

body.theme-dark {
  --page-bg: #161a1f;
  --text: #e5e7eb;
  --muted: #b5bdc8;
  --line: #313942;
  --panel: #20262d;
  --table: #1d252b;
  --table-deep: #10161b;
  --table-line: rgba(255, 255, 255, 0.17);
  color-scheme: dark;
}

body.theme-dark .site-header,
body.theme-dark .game-shell,
body.theme-dark .controls,
body.theme-dark .status-line,
body.theme-dark .settings-panel,
body.theme-dark .options-section,
body.theme-dark .preference-section,
body.theme-dark .stats-panel,
body.theme-dark .content-section,
body.theme-dark .modal {
  background: #20262d;
  color: #e5e7eb;
}

body.theme-dark .main-nav a,
body.theme-dark .brand,
body.theme-dark a,
body.theme-dark button {
  color: #d9f7e7;
}

body.theme-dark button,
body.theme-dark select,
body.theme-dark input,
body.theme-dark .stats-bar div {
  background: #28313a;
  border-color: #3f4a55;
  color: #eef2f5;
}

body.theme-dark .control-primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

body.theme-dark .control-primary:hover,
body.theme-dark .control-primary:focus-visible {
  border-color: #24865b;
  background: #24865b;
}

body.theme-dark .options-tab-button[aria-expanded="true"] {
  border-color: #3f4a55;
  border-bottom-color: #20262d;
  background: #20262d;
  color: #d9f7e7;
}

body.theme-dark .intro-section h1,
body.theme-dark .game-topline h2,
body.theme-dark .stats-bar strong {
  color: #f5f7fa;
}

body.theme-dark .intro-section p,
body.theme-dark .settings-grid span,
body.theme-dark .check-row span,
body.theme-dark .options-section__header,
body.theme-dark .preference-section > summary,
body.theme-dark .status-line {
  color: #c8d0d8;
}

body.theme-dark .options-section.is-relevant .options-section__header {
  background: #25392f;
}

body.theme-dark .preference-section {
  background: #242c33;
}

body.theme-dark .daily-status {
  border-color: #73612d;
  background: #342d18;
  color: #f6df99;
}

body.card-large {
  --card-width: 88px;
  --stack-gap: 30px;
}

body.card-compact {
  --card-width: 62px;
  --card-gap: 8px;
  --stack-gap: 22px;
}

body.layout-left .top-row {
  direction: rtl;
}

body.layout-left .stock-waste,
body.layout-left .foundation-row {
  direction: ltr;
}

.top-row {
  display: grid;
  grid-template-columns: minmax(calc(var(--card-w) * 2 + var(--card-gap)), auto) minmax(calc(var(--card-w) * 4 + var(--card-gap) * 3), 1fr);
  align-items: start;
  gap: 18px;
  margin-bottom: 20px;
}

.stock-waste,
.foundation-row {
  display: flex;
  gap: var(--card-gap);
  min-width: 0;
}

.foundation-row {
  justify-content: flex-end;
}

.pile {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
  flex: 0 0 var(--card-w);
  border: 2px dashed var(--table-line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.pile::before {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--placeholder-color);
  font-size: 30px;
  font-weight: 700;
}

.pile--stock::before {
  content: "Deck";
  font-size: 13px;
}

.pile--waste::before {
  content: "Discard";
  font-size: 13px;
}

#foundation-spades::before { content: "♠"; }
#foundation-hearts::before { content: "♥"; color: rgba(255, 211, 211, 0.7); }
#foundation-diamonds::before { content: "♦"; color: rgba(255, 211, 211, 0.7); }
#foundation-clubs::before { content: "♣"; }

.pile.is-drop-target {
  border-style: solid;
  border-color: #f7c948;
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.pile.is-drop-hover {
  border-color: #ffffff;
  box-shadow: 0 0 0 5px rgba(247, 201, 72, 0.72), inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.tableau-column.is-drop-target::before {
  border-style: solid;
  border-color: #f7c948;
  box-shadow: 0 0 0 3px rgba(247, 201, 72, 0.24), inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.tableau-column.is-drop-hover::before {
  border-color: #ffffff;
  box-shadow: 0 0 0 5px rgba(247, 201, 72, 0.72), inset 0 0 0 2px rgba(255, 255, 255, 0.72);
}

.tableau-column.is-drop-hover > .card:last-child {
  outline: 5px solid rgba(247, 201, 72, 0.9);
  outline-offset: 2px;
}

.pile.is-hint,
.card.is-hint {
  outline: 4px solid #f7c948;
  outline-offset: 3px;
  z-index: 10;
}

.pile.is-selected,
.card.is-selected {
  outline: 4px solid #ffffff;
  outline-offset: 3px;
}

.tableau {
  display: grid;
  grid-template-columns: repeat(7, minmax(var(--card-w), 1fr));
  gap: var(--card-gap);
  align-items: start;
}

.tableau-column {
  position: relative;
  min-width: var(--card-w);
  min-height: var(--card-h);
  border-radius: var(--radius);
}

.tableau-column::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--card-w);
  height: var(--card-h);
  transform: translateX(-50%);
  border: 2px dashed var(--table-line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.06);
}

.card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  aspect-ratio: var(--card-aspect-ratio);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #202124;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform 120ms ease, box-shadow 120ms ease, outline-color 120ms ease;
}

.card:hover {
  transform: translateY(-1px);
}

.card.dragging {
  opacity: 0.55;
}

.card.dragging-stack {
  opacity: 0.28;
}

.pile--waste .card.dragging-stack {
  opacity: 0;
}

.drag-stack-preview {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  pointer-events: none;
  z-index: 1000;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.28));
  will-change: transform;
}

.drag-stack-preview .card {
  left: 0;
  top: calc(var(--preview-row, 0) * var(--stack-gap));
  cursor: grabbing;
  transform: none;
}

.drag-stack-preview .card:hover {
  transform: none;
}

.pile > .card {
  left: 0;
  top: 0;
}

.tableau-column > .card {
  left: 50%;
  top: calc(var(--row, 0) * var(--stack-gap));
  transform: translateX(-50%);
}

.tableau-column > .card:hover {
  transform: translateX(-50%) translateY(-1px);
}

.card-inner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: calc(var(--radius) - 1px);
  background: transparent;
}

.card.face-up .card-inner {
  border: 1px solid #d5d9d6;
  background: #fffefb;
  box-shadow: inset 0 0 7px rgba(18, 31, 24, 0.08);
}

.card-art {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: var(--card-aspect-ratio);
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.card-face {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  color: #111820;
  font-family: Georgia, "Times New Roman", serif;
  pointer-events: none;
}

.card.red .card-face {
  color: #c3171d;
}

.card-corner {
  position: absolute;
  z-index: 4;
  display: inline-flex;
  min-width: 18%;
  flex-direction: column;
  align-items: center;
  font-size: clamp(14px, calc(var(--card-w) * 0.25), 22px);
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: -0.06em;
}

.card-corner--top {
  top: 5%;
  left: 4%;
}

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

.card-corner__suit {
  margin-top: 0.16em;
  font-size: 0.68em;
  line-height: 1;
  letter-spacing: 0;
}

body.card-large-ranks .card-corner {
  font-size: clamp(18px, calc(var(--card-w) * 0.34), 28px);
}

body.card-large-ranks .card-corner__suit {
  margin-top: 0.2em;
  font-size: 0.8em;
}

.card-face[data-rank="2"] .card-corner__rank,
.card-face[data-rank="3"] .card-corner__rank {
  font-family: Georgia, "Times New Roman", serif;
  font-style: normal;
  font-variant-numeric: lining-nums;
  font-weight: 900;
}

.pip-field,
.court-field {
  position: absolute;
  inset: 8% 14%;
}

.card-pip {
  position: absolute;
  left: var(--pip-x);
  top: var(--pip-y);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(12px, calc(var(--card-w) * 0.23), 21px);
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -50%);
}

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

.pip-field--1 .card-pip {
  font-size: clamp(30px, calc(var(--card-w) * 0.58), 48px);
}

.court-field {
  inset: 0;
}

.court-portrait {
  position: absolute;
  left: 50%;
  width: 47%;
  height: 49%;
  background-image: url("../assets/cards/cardroar/court-figures-sprite.png?v=4.1");
  background-repeat: no-repeat;
  background-size: 300% 100%;
}

.court-field[data-court-rank="11"] .court-portrait { background-position: 0% center; }
.court-field[data-court-rank="12"] .court-portrait { background-position: 50% center; }
.court-field[data-court-rank="13"] .court-portrait { background-position: 100% center; }

.court-portrait--top {
  top: 1%;
  transform: translateX(-50%);
}

.court-portrait--bottom {
  bottom: 1%;
  transform: translateX(-50%) rotate(180deg);
}

.card.face-down {
  border-color: transparent;
}

body.theme-dark .card {
  background: transparent;
}

.card.face-down .card-inner {
  background: #101821;
}

body.back-2 .card.face-down .card-art {
  filter: hue-rotate(28deg) saturate(0.82);
}

body.back-3 .card.face-down .card-art {
  filter: hue-rotate(292deg) saturate(0.72);
}

.stock-count {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 22px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-size: 12px;
  text-align: center;
  z-index: 2;
}

.waste-fan-0,
.waste-fan-1,
.waste-fan-2 {
  top: 0;
}

.waste-layered {
  top: 0;
  left: 0;
}

.waste-fan-0 { left: 0; }
.waste-fan-1 { left: 18px; }
.waste-fan-2 { left: 36px; }

.pile--waste {
  width: calc(var(--card-w) + 36px);
  flex-basis: calc(var(--card-w) + 36px);
}

.stats-panel {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.stats-panel h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.stats-panel dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin: 0;
}

.stats-panel div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfb;
}

.stats-panel dt {
  color: var(--muted);
  font-size: 12px;
}

.stats-panel dd {
  margin: 2px 0 0;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-section {
  padding: 32px 0;
  border-top: 1px solid rgba(22, 97, 63, 0.12);
  background: rgba(255, 255, 255, 0.52);
}

.readable {
  max-width: 840px;
}

.readable h2 {
  margin: 0 0 10px;
  color: #12261c;
  font-size: 28px;
  line-height: 1.18;
}

.readable h3 {
  margin: 20px 0 6px;
  color: #253329;
  font-size: 20px;
}

.readable p {
  margin: 0 0 12px;
  color: #46554d;
}

.site-footer {
  padding: 24px 0 40px;
  background: #10261c;
  color: #f7f4eb;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  text-underline-offset: 0.18em;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: #ffffff;
  text-decoration-thickness: 2px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 12px;
}

.page-main {
  min-height: calc(100vh - 210px);
}

.page-main .intro-section {
  padding-bottom: 24px;
}

.page-card {
  margin: 28px auto 48px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(16, 61, 40, 0.14);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 38px rgba(13, 49, 33, 0.08);
}

.page-card h2 {
  margin-top: 28px;
  color: #12261c;
}

.page-card h2:first-child {
  margin-top: 0;
}

.page-card li + li {
  margin-top: 8px;
}

.page-card a {
  color: #0d6640;
}

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  padding: 0;
  list-style: none;
}

.game-list li {
  margin: 0;
}

.game-list a,
.game-list span {
  display: block;
  height: 100%;
  padding: 18px;
  border: 1px solid rgba(16, 61, 40, 0.16);
  border-radius: 9px;
  background: #f8fbf8;
}

.coming-soon-label {
  display: block;
  margin-top: 5px;
  color: #5e6c64;
  font-size: 0.88rem;
}

.modal {
  width: min(440px, calc(100% - 28px));
  border: 1px solid rgba(16, 61, 40, 0.22);
  border-radius: 8px;
  padding: 22px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}

.modal::backdrop {
  background: rgba(9, 20, 14, 0.48);
}

.modal h2 {
  margin: 0 0 8px;
}

.modal p {
  margin: 0 0 16px;
}

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

.victory-dialog {
  width: min(560px, calc(100% - 28px));
  overflow: hidden;
  text-align: center;
}

.victory-dialog::backdrop {
  background:
    radial-gradient(circle at 50% 35%, rgba(24, 91, 59, 0.22), transparent 48%),
    rgba(5, 17, 11, 0.72);
}

.victory-mark {
  margin: -4px 0 8px;
  color: #18211d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 8vw, 48px);
  letter-spacing: 0.16em;
  line-height: 1;
}

.victory-mark span {
  color: #c3171d;
}

.victory-dialog h2 {
  color: var(--brand-strong);
  font-size: clamp(32px, 9vw, 52px);
  line-height: 1;
}

.victory-game-name {
  color: #26342e;
  font-size: 18px;
  font-weight: 800;
}

.victory-summary {
  color: #526159;
  font-size: 14px;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 22px;
}

.victory-stats div {
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8f6;
}

.victory-stats dt {
  color: #5b6861;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.victory-stats dd {
  margin: 3px 0 0;
  color: #1f3027;
  font-size: 20px;
  font-weight: 900;
}

.victory-dialog .modal-actions {
  justify-content: center;
}

.victory-dialog .modal-actions button {
  flex: 1 1 145px;
}

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

.victory-confetti {
  position: absolute;
  top: -12vh;
  left: var(--confetti-x);
  color: #f5b700;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(14px, 2.8vw, 28px);
  font-weight: 900;
  opacity: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
  animation: victory-confetti-fall var(--confetti-duration) cubic-bezier(0.18, 0.64, 0.45, 1) var(--confetti-delay) forwards;
}

.victory-confetti:nth-child(6n + 2) { color: #e74040; }
.victory-confetti:nth-child(6n + 3) { color: #2b78e4; }
.victory-confetti:nth-child(6n + 4) { color: #19a36a; }
.victory-confetti:nth-child(6n + 5) { color: #8d54c7; }
.victory-confetti:nth-child(6n + 6) { color: #ff7a1a; }

.victory-celebration--reduced {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 5vh;
}

.victory-celebration--reduced .victory-confetti {
  position: static;
  opacity: 0.72;
  animation: none;
}

@keyframes victory-confetti-fall {
  0% {
    opacity: 0;
    transform: translate3d(0, -8vh, 0) rotate(0deg) scale(0.72);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0.94;
    transform: translate3d(var(--confetti-drift), 116vh, 0) rotate(var(--confetti-rotation)) scale(1);
  }
}

body.theme-dark .victory-game-name,
body.theme-dark .victory-stats dd {
  color: #f5f7fa;
}

body.theme-dark .victory-summary,
body.theme-dark .victory-stats dt,
body.theme-dark .preference-help {
  color: #c8d0d8;
}

body.theme-dark .victory-stats div,
body.theme-dark .preference-help {
  border-color: #3f4a55;
  background: #242c33;
}

.shortcut-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

kbd {
  display: inline-grid;
  min-width: 30px;
  min-height: 28px;
  place-items: center;
  border: 1px solid #c7cfd8;
  border-bottom-width: 3px;
  border-radius: 6px;
  background: #f8fafc;
  color: #1f2937;
  font-weight: 800;
}

@media (max-width: 900px) {
  :root {
    --card-width: 64px;
    --card-gap: 8px;
    --stack-gap: 23px;
  }

  body.card-large {
    --card-width: 72px;
    --stack-gap: 25px;
  }

  body.card-compact {
    --card-width: 54px;
    --stack-gap: 20px;
  }

  body.card-large-ranks {
    --stack-gap: 28px;
  }

  body.card-large.card-large-ranks {
    --stack-gap: 30px;
  }

  body.card-compact.card-large-ranks {
    --stack-gap: 26px;
  }

  .intro-section h1 {
    font-size: 34px;
  }

  .stats-bar {
    grid-template-columns: repeat(3, minmax(95px, 1fr));
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(145px, 1fr));
  }

  .game-action-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .game-board {
    overflow-x: auto;
    min-height: 500px;
    padding: 12px;
  }

  .game-board > * {
    min-width: calc(var(--card-w) * 7 + var(--card-gap) * 6);
  }

  .stats-panel dl {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 620px) {
  :root {
    --card-width: 46px;
    --card-gap: 6px;
    --stack-gap: 17px;
  }

  body.card-large {
    --card-width: 52px;
    --stack-gap: 19px;
  }

  body.card-compact {
    --card-width: 42px;
    --stack-gap: 16px;
  }

  body.card-large-ranks {
    --stack-gap: 25px;
  }

  body.card-large.card-large-ranks {
    --stack-gap: 27px;
  }

  body.card-compact.card-large-ranks {
    --stack-gap: 23px;
  }

  /* Phone cards are intentionally one-way: one large index, upright pips,
     and one full court figure instead of the desktop mirrored treatment. */
  .card-corner--bottom,
  .court-portrait--bottom {
    display: none;
  }

  .card-corner--top {
    top: 4%;
    left: 4%;
    min-width: 28%;
    padding: 1px;
    border-radius: 4px;
    background: rgba(255, 254, 251, 0.9);
    font-size: clamp(18px, calc(var(--card-w) * 0.42), 24px);
  }

  body.card-large-ranks .card-corner--top {
    min-width: 0;
    flex-direction: row;
    align-items: center;
    gap: 2px;
    padding: 2px 3px 3px;
    font-size: clamp(21px, calc(var(--card-w) * 0.49), 30px);
    line-height: 1;
  }

  body.card-large-ranks .card-corner--top .card-corner__suit {
    margin-top: 0;
    font-size: 0.78em;
  }

  .pip-field {
    inset: 24% 7% 5% 11%;
  }

  body.card-large-ranks .pip-field {
    inset: 31% 6% 5% 10%;
  }

  body.card-large-ranks .pip-field--10 {
    inset: 35% 5% 4% 9%;
  }

  .card-pip,
  .card-pip.is-inverted {
    font-size: clamp(8px, calc(var(--card-w) * 0.2), 12px);
    transform: translate(-50%, -50%);
  }

  .pip-field--1 .card-pip {
    font-size: clamp(24px, calc(var(--card-w) * 0.56), 34px);
  }

  .court-portrait--top {
    top: 17%;
    left: 64%;
    width: 64%;
    height: 79%;
  }

  .site-header__inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }

  .main-nav {
    justify-content: flex-start;
  }

  .intro-section {
    padding-top: 24px;
  }

  .intro-section h1 {
    font-size: 30px;
  }

  .intro-section p {
    font-size: 16px;
  }

  .game-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .daily-status {
    max-width: 100%;
  }

  .stats-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls__secondary-start {
    margin-left: 0;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-actions button {
    width: 100%;
  }

  .victory-dialog {
    max-height: calc(100dvh - 20px);
    padding: 18px;
  }

  .victory-stats {
    margin: 14px 0 18px;
  }

  .victory-dialog .modal-actions {
    flex-direction: column;
  }

  .victory-dialog .modal-actions button {
    width: 100%;
    flex-basis: auto;
  }

  .game-action-grid {
    grid-template-columns: 1fr;
  }

  .options-section__badge {
    display: none !important;
  }

  .top-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .foundation-row {
    justify-content: flex-start;
  }

  .pile::before {
    font-size: 22px;
  }

  .pile--stock::before,
  .pile--waste::before {
    font-size: 10px;
  }

  .waste-fan-1 { left: 12px; }
  .waste-fan-2 { left: 24px; }

  .pile--waste {
    width: calc(var(--card-w) + 24px);
    flex-basis: calc(var(--card-w) + 24px);
  }

  .readable h2 {
    font-size: 24px;
  }
}

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