:root {
  --blue: #244f8a;
  --blue-2: #183c6d;
  --pink: #e79fb8;
  --pink-2: #f7c7da;
  --pink-3: #fce6ef;
  --theme-surface: var(--pink);
  --theme-surface-2: #df8fb0;
  --theme-surface-3: #cf7aa0;
  --theme-contrast: var(--blue);
  --theme-contrast-2: var(--blue-2);
  --theme-button-text: #fff;
  --paper: #fff8fb;
  --ink: #1f2937;
  --muted: #667085;
  --line: rgba(36, 79, 138, .14);
  --shadow: 0 16px 40px rgba(24, 60, 109, .18);
}

* { box-sizing: border-box; }

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

body {
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, var(--pink-2) 0%, #fff2f7 48%, #edf3fb 100%);
}

body.is-playing {
  overflow: hidden;
}

body.theme-blue {
  --theme-surface: var(--blue);
  --theme-surface-2: #21497f;
  --theme-surface-3: var(--blue-2);
  --theme-contrast: var(--pink);
  --theme-contrast-2: #f4bdd1;
  --theme-button-text: var(--blue);
  background: linear-gradient(180deg, #dbe9f8 0%, #f2f7fd 48%, #fff2f7 100%);
}

button {
  min-height: 36px;
  border: 1px solid color-mix(in srgb, var(--theme-contrast) 64%, #fff);
  border-radius: 8px;
  background: var(--theme-contrast);
  color: var(--theme-button-text);
  padding: 0 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(36, 79, 138, .12);
}

button:disabled {
  opacity: .42;
  box-shadow: none;
  cursor: not-allowed;
}

button.primary,
#playBtn:not(:disabled) {
  background: var(--theme-contrast);
  color: var(--theme-button-text);
  border-color: color-mix(in srgb, var(--theme-contrast) 70%, #fff);
}

[hidden] { display: none !important; }

.app {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 8px;
  overflow-x: hidden;
}

body:not(.is-playing) .app {
  padding: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: inherit;
  opacity: .7;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.intro,
.deal-screen {
  min-height: calc(100svh - 16px);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 22px;
  text-align: center;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.58), transparent 42%),
    linear-gradient(180deg, var(--theme-surface) 0%, var(--theme-surface-2) 46%, var(--theme-surface-3) 100%);
  color: var(--theme-contrast);
  box-shadow: var(--shadow);
}

body.theme-blue .intro,
body.theme-blue .deal-screen {
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.5), transparent 42%),
    linear-gradient(180deg, var(--theme-surface) 0%, var(--theme-surface-2) 46%, var(--theme-surface-3) 100%);
  color: var(--theme-contrast);
}

.deal-screen {
  min-height: calc(100svh - 16px);
}

body:not(.is-playing) .intro,
body:not(.is-playing) .deal-screen {
  min-height: 100svh;
  border-radius: 0;
}

.logo-flip {
  width: 58px;
  height: 58px;
  min-height: 0;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  perspective: 700px;
}

.logo-flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.2, .8, .2, 1);
}

.logo-flip.flipped .logo-flip-inner {
  transform: rotateY(180deg) rotateZ(360deg);
}

.logo-flip.auto-spin .logo-flip-inner {
  animation: logoIntroSpin 1.15s cubic-bezier(.2, .8, .2, 1) .22s both;
}

.logo-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  backface-visibility: hidden;
  filter: drop-shadow(0 10px 18px rgba(24,60,109,.18));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.logo-back {
  transform: rotateY(180deg);
}

.intro-logo {
  width: 128px;
  height: 128px;
}

.wordmark {
  display: block;
  width: min(330px, 82vw);
  height: auto;
  margin: 0 auto;
  filter:
    drop-shadow(0 2px 0 rgba(255,255,255,.9))
    drop-shadow(0 14px 24px rgba(24,60,109,.16));
}

.intro h1,
.deal-screen h1 {
  margin: 0;
  font-size: clamp(44px, 12vw, 72px);
  line-height: .92;
  letter-spacing: 0;
  text-transform: uppercase;
}

.intro-line {
  max-width: min(430px, 92vw);
  margin: 8px auto 0;
  font-size: clamp(13px, 3.4vw, 17px);
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  color: color-mix(in srgb, var(--theme-contrast) 88%, #fff);
}

body.theme-blue .intro-line {
  color: color-mix(in srgb, var(--theme-contrast) 88%, #fff);
}

.daily-card {
  width: min(430px, 100%);
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 12px;
  background: rgba(255,255,255,.18);
  color: #fff;
  text-align: left;
  box-shadow: 0 14px 34px rgba(24,60,109,.12);
  backdrop-filter: blur(8px);
}

.kickstarter-promo {
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.46);
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  color: #fff;
  text-align: left;
  box-shadow: 0 14px 34px rgba(24,60,109,.12);
  backdrop-filter: blur(8px);
}

.kickstarter-promo strong,
.kickstarter-promo span {
  display: block;
}

.kickstarter-promo strong {
  margin-bottom: 3px;
  font-size: 16px;
  line-height: 1;
}

.kickstarter-promo span {
  color: rgba(255,255,255,.86);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.18;
}

.kickstarter-promo a,
.settings-links a {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 8px;
  background: var(--theme-contrast);
  color: var(--theme-button-text);
  padding: 0 12px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(24,60,109,.12);
}

@media (max-width: 420px) {
  .kickstarter-promo {
    grid-template-columns: 1fr;
  }

  .kickstarter-promo a {
    width: 100%;
  }
}

.daily-card .eyebrow {
  color: inherit;
  opacity: .78;
}

.daily-quote,
.daily-song {
  padding: 7px 9px;
  border-radius: 9px;
  background: rgba(255,255,255,.13);
}

.daily-quote blockquote {
  margin: 0;
  color: #fff;
  font-size: 14px;
  line-height: 1.14;
  font-weight: 900;
}

.daily-quote span,
.daily-song span {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.82);
  font-size: 12px;
  font-weight: 900;
}

.daily-song strong {
  display: block;
  color: #fff;
  font-size: 16px;
  line-height: 1.1;
}

.daily-song-layout {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 118px;
  grid-template-areas:
    "dancer copy links"
    "preview preview links";
  align-items: start;
  gap: 8px;
}

.daily-dancer {
  grid-area: dancer;
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
}

.daily-dancer img {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: 50%;
  filter: drop-shadow(0 8px 12px rgba(24,60,109,.18));
  transform-origin: 50% 82%;
}

.daily-dancer span {
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  opacity: .82;
  transform-origin: bottom;
}

.daily-dancer span:nth-of-type(1) { right: 10px; }
.daily-dancer span:nth-of-type(2) { right: 17px; height: 15px; }
.daily-dancer span:nth-of-type(3) { right: 24px; height: 8px; }

.daily-card.is-previewing .daily-dancer img {
  animation: cacaheadGroove 2.15s cubic-bezier(.32, .04, .28, 1) infinite;
}

.daily-card.is-previewing .daily-dancer span:nth-of-type(1) {
  animation: musicBarOne .86s ease-in-out infinite;
}

.daily-card.is-previewing .daily-dancer span:nth-of-type(2) {
  animation: musicBarTwo .71s ease-in-out .08s infinite;
}

.daily-card.is-previewing .daily-dancer span:nth-of-type(3) {
  animation: musicBarThree 1.04s ease-in-out .14s infinite;
}

.daily-song-copy {
  grid-area: copy;
  min-width: 0;
}

.daily-actions {
  grid-area: links;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 0;
}

.daily-actions a {
  min-height: 27px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--theme-contrast) 64%, #fff);
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  color: var(--blue);
  padding: 0 8px;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(36,79,138,.12);
}

.daily-inline-preview {
  grid-area: preview;
  justify-self: start;
  width: min(174px, 100%);
  min-height: 27px;
  margin-top: -2px;
  padding: 0 10px;
  background: var(--pink);
  color: var(--blue);
  border-color: color-mix(in srgb, var(--pink) 72%, #fff);
  font-size: 10px;
}

.daily-actions button {
  min-height: 29px;
  padding: 0 8px;
  background: var(--pink);
  color: var(--blue);
  border-color: color-mix(in srgb, var(--pink) 72%, #fff);
  font-size: 10px;
}

@media (max-width: 380px) {
  .daily-song-layout {
    grid-template-columns: 38px minmax(0, 1fr) 104px;
  }

  .daily-dancer {
    width: 38px;
    height: 38px;
  }

  .daily-dancer img {
    width: 31px;
    height: 31px;
  }

  .daily-actions a,
  .daily-actions button {
    font-size: 10px;
    padding: 0 6px;
  }
}

.intro-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(430px, 100%);
}

.intro-actions button {
  min-height: 44px;
  padding: 0 18px;
}

.intro-actions .primary {
  grid-column: 1 / -1;
}

.intro-actions .primary[hidden] + button {
  grid-column: auto;
}

.theme-home-button,
.deal-back-button {
  grid-column: 1 / -1;
}

.theme-home-button {
  order: 99;
}

.deal-preview {
  position: relative;
  width: 158px;
  height: 108px;
  margin: 2px 0;
}

.deal-preview img {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 64px;
  border-radius: 8px;
  box-shadow: 0 18px 34px rgba(10, 26, 48, .26);
  transform-origin: 50% 100%;
  animation: previewDeal .72s cubic-bezier(.2, .8, .2, 1) both;
}

.deal-preview img:nth-child(1) {
  transform: translateX(-88%) rotate(-10deg);
  animation-delay: .04s;
}

.deal-preview img:nth-child(2) {
  transform: translateX(-50%) translateY(-8px);
  animation-delay: .1s;
}

.deal-preview img:nth-child(3) {
  transform: translateX(-12%) rotate(10deg);
  animation-delay: .16s;
}

.legal-page {
  width: min(760px, calc(100% - 28px));
  margin: 24px auto;
  padding: 22px;
  border: 1px solid rgba(36,79,138,.16);
  border-radius: 14px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}

.legal-wordmark {
  display: block;
  width: min(280px, 82vw);
  height: auto;
  margin-bottom: 18px;
}

.legal-page h1,
.legal-page h2 {
  color: var(--blue);
  letter-spacing: 0;
}

.legal-page h1 {
  margin: 0 0 12px;
  font-size: 34px;
  line-height: 1;
}

.legal-page h2 {
  margin: 22px 0 6px;
  font-size: 18px;
}

.legal-page p {
  margin: 0 0 10px;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.45;
}

.legal-page a {
  color: var(--blue);
  font-weight: 900;
}

.game-shell {
  min-height: calc(100svh - 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dealing-live .topbar,
.dealing-live .message,
.dealing-live .opponents,
.dealing-live .table,
.dealing-live .player-panel {
  animation: surfaceIn .46s cubic-bezier(.2, .8, .2, 1) both;
}

.dealing-live .message { animation-delay: .04s; }
.dealing-live .opponents { animation-delay: .08s; }
.dealing-live .table { animation-delay: .12s; }
.dealing-live .player-panel { animation-delay: .16s; }

.dealing-live .mini-card,
.dealing-live #handRow .card,
.dealing-live #boardRow .card {
  opacity: 0;
}

.dealing-live .mini-card.dealt-in,
.dealing-live #handRow .card.dealt-in,
.dealing-live #boardRow .card.dealt-in {
  opacity: 1;
  transition: opacity .12s ease;
}

.topbar,
.message,
.opponent,
.table,
.player-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  background: linear-gradient(90deg, var(--theme-surface-2), var(--theme-surface), var(--theme-surface-3));
  color: var(--theme-contrast);
}

body.theme-blue .topbar {
  background: linear-gradient(90deg, var(--theme-surface-3), var(--theme-surface));
  color: var(--theme-contrast);
}

.topbar-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.topbar-brand {
  min-width: 0;
}

.topbar-wordmark {
  display: block;
  width: min(190px, 48vw);
  height: auto;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.86));
}

.topbar h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0;
}

.topbar .eyebrow {
  display: none;
}

.message {
  min-height: 34px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  align-self: start;
  padding: 8px;
  background: rgba(255,255,255,.88);
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
  box-shadow: none;
}

.player-panel .message {
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.message button {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  flex: 0 0 auto;
}

.message.guidance-hidden {
  display: none;
}

.opponents {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.opponent {
  min-height: 88px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  box-shadow: none;
  overflow: visible;
}

.player-panel.active {
  border-color: rgba(231,159,184,.9);
  box-shadow: 0 0 0 3px rgba(231,159,184,.3), var(--shadow);
}

.opponent.active .mini-layout {
  border-color: rgba(231,159,184,.9);
  box-shadow: 0 0 0 3px rgba(231,159,184,.3), var(--shadow);
}

.opponent.out { opacity: .5; }

.opponent.cacahead .mini-layout {
  border-color: rgba(231,159,184,.95);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(245,213,225,.82));
}

.opponent.out .mini-layout {
  display: none;
}

.opponent-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 4px;
  margin: 0 4px 5px;
}

.opponent-name {
  width: 100%;
  max-width: 72px;
  min-height: 22px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--theme-contrast);
  color: var(--theme-button-text);
  font-size: 11px;
  line-height: 1.05;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.counts {
  min-height: 22px;
  display: grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 7px;
  background: rgba(36,79,138,.08);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  text-align: right;
  font-weight: 900;
}

.mini-layout {
  min-height: 68px;
  padding: 6px;
  border: 1px solid rgba(36,79,138,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
}

.mini-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-height: 48px;
}

.mini-slot {
  position: relative;
  min-height: 48px;
}

.mini-card {
  position: relative;
  width: 30px;
  flex: 0 0 auto;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  line-height: 0;
}

.mini-card img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: initial;
  background: transparent;
  border-radius: 5px;
  box-shadow: 0 5px 10px rgba(36,79,138,.12);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.mini-slot .mini-card {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.mini-slot .mini-back {
  top: 11px;
  opacity: .95;
}

.mini-slot .mini-front {
  top: 0;
}

.mini-slot.revealed .mini-back {
  top: 0;
}

.mini-front::after {
  content: attr(data-rank);
  position: absolute;
  right: 3px;
  top: 3px;
  min-width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
}

.table {
  min-height: 132px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 62px;
  gap: 8px;
  align-items: center;
  justify-items: center;
  overflow: hidden;
  padding: 8px;
  background: linear-gradient(110deg, color-mix(in srgb, var(--theme-surface) 98%, #fff), color-mix(in srgb, var(--theme-contrast) 82%, transparent));
}

.pile-card {
  position: relative;
  width: 100%;
  aspect-ratio: 62 / 86;
  min-height: 86px;
  display: grid;
  place-items: center;
  align-content: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(36,79,138,.18), rgba(36,79,138,.18)),
    url("./assets/cards/card-back-premium.png") center / cover no-repeat;
  color: #fff;
  border: 1px solid rgba(255,255,255,.55);
  box-shadow:
    0 8px 0 -4px rgba(225,156,183,.88),
    0 16px 22px rgba(24,60,109,.18);
}

.pile-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(24,60,109,.18);
}

.pile-card span,
.pile-card strong {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 5px rgba(16,42,77,.45);
}

.pile-card span {
  font-size: 10px;
  font-weight: 900;
  opacity: .94;
}

.pile-card strong {
  font-size: 27px;
  line-height: 1;
}

.discard-zone {
  text-align: center;
  border-radius: 10px;
  transition: box-shadow .16s ease, transform .16s ease;
}

.zone-label {
  display: none;
}

.pile-stack {
  position: relative;
  min-height: 92px;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.discard-zone.empty-pile,
.discard-zone.empty-pile .pile-stack {
  width: 0;
  min-width: 0;
  min-height: 0;
  height: 0;
  overflow: hidden;
}

#pileHint {
  display: none;
  margin: 4px 0 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

.player-panel {
  flex: 1;
  min-height: 0;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  grid-template-rows: auto auto auto 1fr auto;
  align-content: start;
  row-gap: 4px;
  column-gap: 8px;
  padding: 8px 8px 10px;
  background: rgba(255,255,255,.94);
}

.player-panel.safe {
  flex: 0 0 auto;
  min-height: 0;
}

.player-panel.safe .row-wrap,
.player-panel.safe .board-row {
  display: none;
}

.player-heading {
  grid-column: 2;
  grid-row: 1 / span 4;
  display: grid;
  align-content: start;
  gap: 8px;
  margin-bottom: 0;
  text-align: right;
}

.player-panel .message {
  grid-column: 1;
  grid-row: 1;
  align-self: stretch;
  margin-bottom: 0;
  padding: 10px 12px;
  line-height: 1.18;
}

.player-panel:not(.guidance-off) .message {
  min-height: 118px;
  margin-bottom: 0;
}

.player-heading .eyebrow {
  display: none;
}

.player-heading h3 {
  width: 100%;
  max-width: none;
  min-height: 31px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--theme-contrast);
  margin: 0 0 2px;
  color: var(--theme-button-text);
  font-size: 14px;
  line-height: 1.05;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions,
.secondary-actions {
  display: grid;
  gap: 4px;
  justify-items: stretch;
}

.actions button,
.secondary-actions button {
  min-height: 31px;
  padding: 0 8px;
  font-size: 11px;
}

.secondary-actions {
  grid-column: 1 / -1;
  grid-row: 5;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 6px;
}

.safe-banner,
.cacahead-banner {
  grid-column: 1;
  display: grid;
  gap: 4px;
  margin: 8px 0 4px;
  padding: 12px;
  border: 1px solid rgba(231,159,184,.55);
  border-radius: 12px;
  background:
    radial-gradient(circle at 90% 10%, rgba(231,159,184,.35), transparent 34%),
    linear-gradient(135deg, rgba(36,79,138,.96), rgba(24,60,109,.98));
  color: #fff;
  box-shadow: 0 12px 28px rgba(24,60,109,.18);
}

.cacahead-banner {
  padding: 16px;
  border-color: rgba(231,159,184,.95);
  background:
    radial-gradient(circle at 86% 14%, rgba(231,159,184,.55), transparent 34%),
    linear-gradient(135deg, #102a4d, var(--blue));
  box-shadow:
    0 0 0 3px rgba(231,159,184,.28),
    0 18px 34px rgba(24,60,109,.22);
}

.human-cacahead .cacahead-banner {
  animation: cacaheadPop .78s cubic-bezier(.2, 1.5, .35, 1) both;
}

.human-cacahead .topbar,
.human-cacahead .table {
  animation: cacaheadGlow 1.1s ease both;
}

.safe-banner strong,
.cacahead-banner strong {
  font-size: 24px;
  line-height: 1;
}

.cacahead-banner strong {
  font-size: 30px;
}

.safe-banner span,
.cacahead-banner span:not(.eyebrow) {
  max-width: 360px;
  color: rgba(255,255,255,.82);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.row-wrap {
  grid-column: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  margin-top: 0;
}

.hand-wrap {
  grid-row: 2;
  align-self: start;
}

.table-wrap {
  grid-row: 3;
  align-self: start;
}

.player-panel.guidance-off .row-wrap {
  margin-top: 0;
}

.player-panel.guidance-off .hand-wrap {
  grid-row: 1;
  align-self: start;
  padding-top: 0;
}

.player-panel.guidance-off .table-wrap {
  grid-row: 2;
}

.row-wrap p {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.row-head {
  min-height: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-row-wrap {
  position: relative;
  min-width: 0;
}

.card-row {
  width: 100%;
  min-width: 0;
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: visible;
  padding: 2px 2px 6px;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.card-row::-webkit-scrollbar {
  display: none;
}

.board-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(68px, 1fr));
  gap: 8px;
  max-width: 280px;
}

.board-slot {
  position: relative;
  min-height: 86px;
}

.card {
  appearance: none;
  position: relative;
  width: 60px;
  aspect-ratio: 62 / 86;
  min-height: 0;
  padding: 0;
  flex: 0 0 auto;
  overflow: visible;
  border: 0;
  border-radius: 9px;
  background: none;
  box-shadow: none;
  line-height: 0;
  transition: transform .16s ease, box-shadow .16s ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card:not([data-special]):not(.face-down-card) {
  box-shadow:
    0 0 0 1px rgba(231, 159, 184, .72),
    0 9px 18px rgba(36,79,138,.12);
}

.board-slot .card {
  position: absolute;
  left: 12px;
  top: 0;
  width: 60px;
}

.board-slot .face-down-card {
  left: 0;
  top: 14px;
  z-index: 1;
}

.board-slot .card:not(.face-down-card) {
  top: 0;
  left: 16px;
  z-index: 2;
}

.board-slot.revealed .face-down-card {
  left: 16px;
  top: 0;
  z-index: 2;
}

.pile-stack .card {
  position: absolute;
  width: 60px;
}

.pile-stack .pile-layer {
  --pile-middle: calc((var(--pile-total) - 1) / 2);
  --pile-distance: calc(var(--pile-index) - var(--pile-middle));
  z-index: calc(var(--pile-index) + 1);
  transform:
    translate(
      calc(var(--pile-distance) * 2px),
      calc(var(--pile-distance) * -1px)
    )
    rotate(calc(var(--pile-distance) * 5deg));
  transform-origin: 50% 58%;
}

.pile-stack .pile-layer:nth-child(2n) {
  transform:
    translate(
      calc(var(--pile-distance) * -2px),
      calc(var(--pile-distance) * -1px)
    )
    rotate(calc(var(--pile-distance) * -4deg));
}

.pile-stack .pile-layer:last-child {
  transform: translate(0, -2px) rotate(2deg);
}

.card img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: transparent;
  border-radius: 8px;
  box-shadow: 0 9px 18px rgba(36,79,138,.14);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.card:not([data-special]):not(.face-down-card) img {
  box-shadow: none;
}

.card[data-special] img,
.card.face-down-card img {
  box-shadow: 0 9px 18px rgba(36,79,138,.14);
}

.card[data-special] img {
  box-shadow: none;
}

.card:not(.face-down-card)::before {
  content: attr(data-rank);
  position: absolute;
  z-index: 2;
  right: 5px;
  top: 5px;
  min-width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.card[data-special]::after {
  content: attr(data-special);
  position: absolute;
  z-index: 2;
  left: 5px;
  bottom: 5px;
  padding: 3px 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.card.playable {
  box-shadow: 0 0 0 3px rgba(36,79,138,.18), 0 9px 18px rgba(36,79,138,.14);
  touch-action: none;
}

.card.setup-draggable {
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: none;
}

.card.setup-draggable:active {
  cursor: grabbing;
}

body.is-dragging-card {
  overflow: hidden;
  overscroll-behavior: none;
}

.card.selected {
  transform: scale(1.035);
  z-index: 3;
  filter:
    drop-shadow(0 0 8px rgba(231,159,184,.72))
    drop-shadow(0 10px 18px rgba(36,79,138,.18));
}

.dragging-source {
  opacity: 1;
}

.drag-ghost,
.card-flyer {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  aspect-ratio: 62 / 86;
  border-radius: 9px;
  overflow: visible;
  filter: drop-shadow(0 14px 22px rgba(36,79,138,.24));
  will-change: transform;
}

.drag-ghost {
  margin: 0;
  display: block;
  object-fit: fill;
  transform-origin: center;
  transition: none !important;
  animation: none !important;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card-flyer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.card-flyer {
  line-height: 0;
}

.card.unplayable {
  opacity: 1;
  filter: none;
}

.card-label {
  display: none;
}

.log-panel {
  display: none;
}

dialog {
  width: min(760px, calc(100% - 24px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}

dialog::backdrop {
  background: rgba(31,41,55,.56);
}

@keyframes surfaceIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(.985);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    filter: blur(3px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes previewDeal {
  from {
    opacity: 0;
    scale: .9;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    scale: 1;
    filter: blur(0);
  }
}

@keyframes cacaheadGroove {
  0%, 100% { transform: translateY(0) rotate(-3deg) scale(1); }
  13% { transform: translateY(-3px) rotate(4deg) scale(1.035); }
  28% { transform: translateY(1px) rotate(-6deg) scale(.99); }
  44% { transform: translateY(-5px) rotate(2deg) scale(1.045); }
  63% { transform: translateY(0) rotate(6deg) scale(1.01); }
  78% { transform: translateY(-2px) rotate(-2deg) scale(1.025); }
}

@keyframes musicBarOne {
  0%, 100% { transform: scaleY(.42); opacity: .52; }
  22% { transform: scaleY(1.1); opacity: .95; }
  47% { transform: scaleY(.65); opacity: .7; }
  72% { transform: scaleY(1.35); opacity: 1; }
}

@keyframes musicBarTwo {
  0%, 100% { transform: scaleY(.72); opacity: .68; }
  18% { transform: scaleY(1.32); opacity: 1; }
  38% { transform: scaleY(.48); opacity: .55; }
  65% { transform: scaleY(1.12); opacity: .92; }
}

@keyframes musicBarThree {
  0%, 100% { transform: scaleY(.5); opacity: .58; }
  31% { transform: scaleY(1.22); opacity: .98; }
  54% { transform: scaleY(.38); opacity: .5; }
  84% { transform: scaleY(1.05); opacity: .86; }
}

@keyframes logoIntroSpin {
  0% { transform: rotateY(0deg) rotateZ(0deg); }
  48% { transform: rotateY(180deg) rotateZ(180deg); }
  100% { transform: rotateY(360deg) rotateZ(360deg); }
}

@keyframes cacaheadPop {
  0% { transform: scale(.86) rotate(-2deg); filter: blur(5px); opacity: 0; }
  55% { transform: scale(1.045) rotate(1deg); filter: blur(0); opacity: 1; }
  100% { transform: scale(1) rotate(0); filter: blur(0); opacity: 1; }
}

@keyframes cacaheadGlow {
  0% { box-shadow: 0 0 0 rgba(231,159,184,0); }
  45% { box-shadow: 0 0 0 5px rgba(231,159,184,.32), 0 18px 34px rgba(36,79,138,.22); }
  100% { box-shadow: var(--shadow); }
}

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

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: linear-gradient(90deg, var(--theme-surface), var(--theme-surface-3));
  color: var(--theme-contrast);
}

.dialog-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}

.rules-grid {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--paper);
}

.rules-grid article {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.rules-grid h3 {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 16px;
}

.rules-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.companion-dialog {
  width: min(94vw, 520px);
  max-height: 90svh;
  padding: 0;
  border: 1px solid rgba(36,79,138,.2);
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.companion-dialog::backdrop {
  background: rgba(24,60,109,.38);
  backdrop-filter: blur(4px);
}

.companion-tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
}

.companion-dialog:not(.profile-only) .companion-tabs {
  display: none;
}

.companion-tabs button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
  flex: 0 0 auto;
}

.companion-tabs button.active {
  background: var(--theme-contrast);
  color: var(--theme-button-text);
  border-color: color-mix(in srgb, var(--theme-contrast) 70%, #fff);
}

.companion-panel {
  display: none;
  gap: 10px;
  padding: 12px;
  max-height: calc(90svh - 112px);
  overflow-y: auto;
}

.companion-dialog:not(.profile-only) .companion-panel {
  max-height: calc(90svh - 62px);
}

.companion-panel.active {
  display: grid;
}

.companion-panel label {
  display: grid;
  gap: 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.companion-panel input,
.companion-panel select,
.companion-panel textarea {
  width: 100%;
  border: 1px solid rgba(36,79,138,.22);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.auth-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(36,79,138,.16);
  border-radius: 12px;
  background: color-mix(in srgb, var(--theme-bg) 14%, #fff);
  box-shadow: 0 10px 24px rgba(36,79,138,.08);
}

.auth-box strong,
.auth-box span {
  display: block;
}

.auth-box strong {
  color: var(--blue);
  font-size: 16px;
  line-height: 1.1;
}

.auth-box span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.auth-form {
  display: grid;
  gap: 8px;
}

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

.auth-actions .danger-button {
  grid-column: 1 / -1;
  background: #fff;
  color: #b42318;
  border-color: rgba(180,35,24,.28);
}

.signed-in-actions[hidden],
.auth-form[hidden] {
  display: none;
}

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

.stat-card {
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
}

.physical-builder,
.timer-controls,
.history-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.timer-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.timer-options label:not(.toggle-row) {
  grid-column: 1 / -1;
}

.timer-options button {
  grid-column: 1 / -1;
}

.wide-toggle {
  grid-column: 1 / -1;
}

.toggle-row {
  min-height: 38px;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
  padding: 9px 10px;
  border: 1px solid rgba(36,79,138,.16);
  border-radius: 8px;
  background: #fff;
  color: var(--blue);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.physical-builder label {
  flex: 1 1 180px;
}

.chip-row {
  min-height: 34px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(36,79,138,.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.timer-face {
  min-height: 132px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--theme-surface), var(--theme-contrast));
  color: var(--theme-button-text);
  font-size: 64px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 14px 28px rgba(36,79,138,.18);
}

.timer-face.warning {
  background: linear-gradient(135deg, #e8532f, var(--pink));
}

.timer-face.timer-running {
  box-shadow:
    0 0 0 3px rgba(231,159,184,.24),
    0 14px 28px rgba(36,79,138,.18);
}

.big-screen-dialog {
  width: min(96vw, 1180px);
  max-height: 94svh;
  border-radius: 18px;
  overflow: hidden;
  background: var(--theme-surface);
  color: var(--theme-contrast);
}

.big-screen-dialog::backdrop {
  background: rgba(10, 24, 44, .68);
  backdrop-filter: blur(6px);
}

.big-screen-stage {
  min-height: min(720px, 92svh);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: clamp(16px, 3vw, 34px);
  background:
    radial-gradient(circle at 84% 12%, rgba(255,255,255,.28), transparent 34%),
    linear-gradient(145deg, var(--theme-surface), var(--theme-surface-3));
}

.big-screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.big-screen-wordmark {
  width: min(440px, 62vw);
  height: auto;
  filter: drop-shadow(0 12px 28px rgba(24,60,109,.18));
}

.big-screen-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, .9fr);
  gap: 18px;
  align-items: stretch;
}

.big-card {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: 250px;
  padding: clamp(18px, 3vw, 36px);
  border: 1px solid color-mix(in srgb, var(--theme-contrast) 32%, transparent);
  border-radius: 14px;
  background: rgba(255,255,255,.18);
  box-shadow: 0 24px 48px rgba(24,60,109,.18);
}

.big-card strong {
  display: block;
  font-size: clamp(38px, 7vw, 92px);
  line-height: .95;
  letter-spacing: 0;
}

.big-card p {
  max-width: 720px;
  margin: 0;
  font-size: clamp(18px, 2.4vw, 30px);
  line-height: 1.2;
  font-weight: 900;
}

.big-timer-card {
  text-align: center;
}

.big-timer-card strong {
  font-size: clamp(92px, 16vw, 190px);
}

.big-timer-controls,
.big-screen-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.big-timer-controls button,
.big-screen-actions button,
.big-screen-head button {
  min-height: 48px;
  font-size: 14px;
}

@media (max-width: 759px) {
  .big-screen-dialog {
    width: min(96vw, 520px);
  }

  .big-screen-stage {
    min-height: 86svh;
    gap: 12px;
    padding: 14px;
  }

  .big-screen-grid {
    grid-template-columns: 1fr;
  }

  .big-card {
    min-height: 170px;
  }

  .big-timer-controls,
  .big-screen-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}



body.big-screen-open {
  overflow: hidden;
}

body.big-screen-open .big-screen-dialog[open] {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
}

body.big-screen-open .big-screen-stage {
  min-height: 100dvh;
  height: 100dvh;
}

@media (orientation: landscape) {
  body.big-screen-open .big-screen-stage {
    grid-template-rows: auto 1fr auto;
    padding: clamp(12px, 2.2vw, 28px);
  }

  body.big-screen-open .big-screen-grid {
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr);
  }

  body.big-screen-open .big-card {
    min-height: min(48dvh, 360px);
  }

  body.big-screen-open .big-screen-wordmark {
    width: min(360px, 34vw);
  }
}

.companion-note {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: rgba(36,79,138,.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.settings-info {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.72);
}

.settings-info h3 {
  margin: 0;
  color: var(--blue);
  font-size: 13px;
  line-height: 1.1;
}

.settings-info p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.settings-info button {
  min-height: 42px;
}

.happiness-tips-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.settings-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.settings-links a {
  background: #fff;
  color: var(--blue);
  border-color: rgba(36,79,138,.18);
}

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

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

.history-list li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.history-list strong {
  color: var(--blue);
}

.history-list span,
.rules-copy p {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.rules-copy {
  display: grid;
  gap: 8px;
}

.rules-copy article {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.rules-copy h3 {
  margin: 0;
  color: var(--blue);
  font-size: 15px;
}

@media (min-width: 1000px) {
  .app {
    width: min(100%, 1380px);
    height: 100svh;
    min-height: 0;
    padding: clamp(8px, 1vw, 14px);
    overflow: hidden;
  }

  .game-shell {
    display: grid;
    grid-template-columns: minmax(420px, .95fr) minmax(620px, 1.05fr);
    grid-template-rows: 62px clamp(118px, 16svh, 150px) minmax(0, 1fr);
    gap: clamp(8px, 1.2vw, 14px);
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .topbar {
    grid-column: 1 / -1;
    min-height: 0;
    height: 100%;
    padding: 7px 10px;
  }

  .table {
    grid-column: 1;
    grid-row: 2 / span 2;
    min-height: 0;
    height: 100%;
  }

  .opponents {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: start;
    gap: 10px;
    overflow: visible;
    min-height: 0;
    height: 100%;
  }

  .opponent {
    min-height: 0;
    padding: 0;
  }

  .opponent-name,
  .counts {
    max-width: none;
    min-height: 28px;
    font-size: 12px;
  }

  .mini-board,
  .mini-slot {
    min-height: clamp(70px, 10svh, 92px);
  }

  .mini-layout {
    min-height: 0;
    height: calc(100% - 33px);
    padding: 8px;
  }

  .mini-card {
    width: clamp(38px, 3.2vw, 50px);
  }

  .table {
    min-height: 100%;
    grid-template-columns: minmax(82px, 104px) minmax(120px, 1fr) minmax(82px, 104px);
    gap: clamp(12px, 1.6vw, 24px);
    padding: clamp(22px, 2.4vw, 34px);
  }

  .pile-card {
    width: 100%;
    max-width: 104px;
    min-height: 0;
  }

  .pile-stack {
    min-height: 0;
    height: 100%;
  }

  .pile-stack .card {
    width: clamp(76px, 6vw, 112px);
  }

  .pile-card strong {
    font-size: clamp(28px, 3vw, 40px);
  }

  .player-panel {
    grid-column: 2;
    grid-row: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, auto) minmax(0, auto) auto;
    align-content: start;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: clamp(10px, 1.2vw, 16px);
    row-gap: clamp(4px, .7svh, 8px);
  }

  .player-heading {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    align-content: start;
    align-items: start;
    gap: 8px;
    text-align: center;
  }

  .player-heading h3 {
    min-height: 34px;
    margin: 0;
  }

  .player-panel .message {
    grid-column: 1;
    grid-row: 2;
    min-height: clamp(52px, 8svh, 74px);
    padding: 8px 10px;
  }

  .player-panel:not(.guidance-off) .message {
    min-height: clamp(52px, 8svh, 74px);
  }

  .hand-wrap {
    grid-row: 3;
  }

  .table-wrap {
    grid-row: 4;
  }

  .player-panel.guidance-off .hand-wrap {
    grid-row: 2;
  }

  .player-panel.guidance-off .table-wrap {
    grid-row: 3;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .actions button {
    min-height: 34px;
    font-size: 12px;
  }

  .secondary-actions {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    margin-top: 6px;
  }

  .secondary-actions button {
    min-height: 34px;
    font-size: 12px;
  }

  .card {
    width: clamp(76px, 5.1vw, 102px);
  }

  .board-row {
    max-width: none;
    width: 100%;
    grid-template-columns: repeat(3, minmax(96px, 1fr));
    gap: clamp(12px, 2vw, 32px);
  }

  .board-slot {
    min-height: clamp(118px, 15svh, 158px);
  }

  .board-slot .card {
    width: clamp(78px, 5.3vw, 106px);
  }

  .board-slot .face-down-card {
    left: 0;
    top: clamp(18px, 1.6vw, 28px);
  }

  .board-slot .card:not(.face-down-card) {
    left: clamp(36px, 3vw, 58px);
  }

  .board-slot.revealed .face-down-card {
    left: clamp(36px, 3vw, 58px);
    top: 0;
  }

  .card-row {
    gap: clamp(10px, 1.5vw, 22px);
    width: 100%;
    justify-content: flex-start;
    min-height: clamp(106px, 14svh, 142px);
    overflow-x: visible;
  }

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

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


/* Home and screen-mode polish */
.intro {
  min-height: 100svh;
  justify-content: start;
  gap: clamp(8px, 1.25svh, 14px);
  padding-block: clamp(10px, 1.8svh, 18px);
}

.intro-logo {
  width: clamp(76px, 14svh, 118px);
  height: clamp(76px, 14svh, 118px);
}

.wordmark {
  width: min(330px, 78vw);
}

.intro-line {
  margin-top: 4px;
}

.intro-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(7px, 1.1svh, 10px);
}

.intro-actions button {
  min-height: clamp(37px, 5.1svh, 44px);
}

#companionIntroBtn,
#rulesBtn,
#homeSettingsBtn {
  grid-column: 1;
}

#homeTimerBtn,
#homeIrlBtn,
#homeBigScreenBtn {
  grid-column: 2;
}

#companionIntroBtn { grid-row: 3; }
#homeTimerBtn { grid-row: 3; }
#rulesBtn { grid-row: 4; }
#homeIrlBtn { grid-row: 4; }
#homeSettingsBtn { grid-row: 5; }
#homeBigScreenBtn { grid-row: 5; }
#themeToggleBtn { grid-row: 6; }
#homeFartBtn { grid-row: 7; }

.kickstarter-promo {
  margin-top: auto;
  padding: 8px 10px;
}

body.big-screen-open .big-screen-actions {
  grid-template-columns: minmax(0, 1fr);
  max-width: 360px;
  width: 100%;
  margin-inline: auto;
}

body.big-screen-open .big-screen-actions button {
  width: 100%;
}

.player-panel {
  overflow: hidden;
}

.table-wrap {
  padding-bottom: 10px;
}

.secondary-actions {
  position: relative;
  z-index: 6;
  align-self: end;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.96) 28%);
  padding-top: 8px;
}

.board-slot {
  overflow: visible;
}

@media (max-width: 759px) {
  .player-panel {
    grid-template-rows: auto auto minmax(112px, auto) minmax(156px, 1fr) auto;
  }

  .board-row {
    gap: clamp(12px, 5vw, 28px);
  }

  .board-slot {
    min-height: clamp(118px, 20svh, 152px);
  }

  .table-wrap {
    padding-bottom: 34px;
  }

  .secondary-actions {
    margin-top: 0;
  }
}

@media (max-height: 760px) {
  .daily-card {
    gap: 4px;
    padding: 6px;
  }

  .daily-quote,
  .daily-song {
    padding: 6px 8px;
  }

  .daily-quote blockquote {
    font-size: 13px;
  }

  .kickstarter-promo span {
    display: none;
  }
}

@media (min-width: 1000px) {
  .player-panel {
    overflow: hidden;
  }

  .table-wrap {
    padding-bottom: clamp(50px, 7svh, 78px);
  }

  .secondary-actions {
    position: absolute;
    left: clamp(18px, 2vw, 26px);
    right: clamp(18px, 2vw, 26px);
    bottom: clamp(12px, 1.4vw, 18px);
  }
}


/* Center desktop home and keep Big Screen tools inside Big Screen. */
.intro {
  align-content: center;
  justify-content: center;
}

@media (min-width: 1000px) {
  body:not(.is-playing) .app {
    width: min(100%, 1380px);
  }

  body:not(.is-playing) .intro {
    justify-content: center;
    justify-items: center;
  }
}

.big-irl-card {
  display: none;
}

.big-screen-dialog[data-mode="timer"] .big-status,
.big-screen-dialog[data-mode="timer"] .big-irl-card,
.big-screen-dialog[data-mode="irl"] .big-status,
.big-screen-dialog[data-mode="irl"] .big-timer-card {
  display: none;
}

.big-screen-dialog[data-mode="timer"] .big-timer-card,
.big-screen-dialog[data-mode="irl"] .big-irl-card {
  display: grid;
  grid-column: 1 / -1;
  min-height: min(58dvh, 520px);
}

.big-screen-dialog[data-mode="timer"] .big-screen-grid,
.big-screen-dialog[data-mode="irl"] .big-screen-grid {
  grid-template-columns: 1fr;
}

.big-screen-dialog[data-mode="irl"] .big-irl-card strong {
  font-size: clamp(36px, 6vw, 78px);
}

.big-screen-dialog[data-mode="irl"] .big-irl-card p {
  max-width: none;
  font-size: clamp(20px, 3vw, 36px);
}

body.big-screen-open .big-screen-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: min(760px, 100%);
}

/* Mobile rescue: keep controls visible and make landscape usable. */
@media (max-width: 999px) {
  .player-panel {
    grid-template-rows: auto auto auto auto auto;
    align-content: start;
    min-height: auto;
  }

  .player-panel:not(.guidance-off) .message {
    min-height: clamp(74px, 11svh, 118px);
  }

  .hand-wrap,
  .table-wrap,
  .player-panel.guidance-off .hand-wrap,
  .player-panel.guidance-off .table-wrap {
    align-self: start;
  }

  .board-row {
    align-items: start;
  }

  .board-slot {
    min-height: clamp(112px, 17svh, 148px);
  }

  .table-wrap {
    padding-bottom: 8px;
  }

  .secondary-actions {
    position: static;
    grid-row: auto;
    align-self: start;
    margin-top: 6px;
    padding-top: 0;
    background: transparent;
  }
}

@media (max-width: 999px) and (orientation: landscape) {
  body,
  body.is-playing {
    overflow: auto;
  }

  .app {
    width: 100%;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .game-shell {
    min-height: auto;
    height: auto;
    overflow: visible;
    gap: 6px;
  }

  .topbar {
    min-height: 50px;
    padding: 6px 8px;
  }

  .topbar .logo-flip {
    width: 42px;
    height: 42px;
  }

  .topbar-wordmark {
    width: min(280px, 42vw);
  }

  .opponents {
    gap: 6px;
  }

  .opponent {
    min-height: 96px;
    padding: 4px;
  }

  .mini-layout {
    min-height: 70px;
    padding: 5px;
  }

  .mini-card {
    width: clamp(34px, 7vw, 48px);
  }

  .table {
    min-height: 116px;
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    padding: 6px;
  }

  .pile-card {
    min-height: 78px;
  }

  .pile-stack {
    min-height: 84px;
  }

  .player-panel {
    grid-template-columns: minmax(0, 1fr) minmax(128px, 30vw);
    padding: 7px;
    row-gap: 4px;
  }

  .player-panel:not(.guidance-off) .message {
    min-height: 74px;
    padding: 8px 10px;
  }

  .card {
    width: clamp(64px, 12vw, 82px);
  }

  .board-row {
    grid-template-columns: repeat(3, minmax(76px, 1fr));
    gap: clamp(8px, 3vw, 22px);
  }

  .board-slot {
    min-height: 104px;
  }

  .actions button,
  .secondary-actions button {
    min-height: 30px;
    font-size: 11px;
  }
}

@media (max-width: 999px) and (orientation: landscape) {
  body:not(.is-playing) .intro {
    min-height: 100svh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(220px, .75fr);
    grid-template-areas:
      "logo actions"
      "copy actions"
      "daily actions"
      "kick actions";
    align-content: center;
    align-items: center;
    justify-content: center;
    justify-items: center;
    gap: clamp(8px, 2vw, 16px);
    padding: clamp(10px, 2vw, 18px);
  }

  body:not(.is-playing) .intro-logo {
    grid-area: logo;
    width: clamp(66px, 16svh, 98px);
    height: clamp(66px, 16svh, 98px);
  }

  body:not(.is-playing) .intro-copy {
    grid-area: copy;
  }

  body:not(.is-playing) .wordmark {
    width: min(420px, 48vw);
  }

  body:not(.is-playing) .intro-line {
    white-space: normal;
  }

  body:not(.is-playing) .daily-card {
    grid-area: daily;
    width: min(520px, 52vw);
  }

  body:not(.is-playing) .intro-actions {
    grid-area: actions;
    width: min(310px, 34vw);
    align-self: center;
  }

  body:not(.is-playing) .intro-actions button {
    min-height: clamp(34px, 7svh, 44px);
  }

  body:not(.is-playing) .kickstarter-promo {
    grid-area: kick;
    width: min(520px, 52vw);
    margin-top: 0;
  }
}


/* Landscape cleanup: park Big Screen, polish home/deal/game on wide phones. */
.intro-actions {
  gap: 10px;
}

@media (max-width: 999px) and (orientation: landscape) {
  body,
  body.is-playing {
    overflow-y: auto;
    overflow-x: hidden;
  }

  body:not(.is-playing) .app {
    width: 100%;
    max-width: none;
    min-height: 100svh;
    height: auto;
    overflow: visible;
  }

  body:not(.is-playing) .intro {
    min-height: 100svh;
    grid-template-columns: minmax(0, 1.08fr) minmax(250px, .78fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "logo actions"
      "copy actions"
      "daily actions"
      "daily kick";
    align-content: center;
    align-items: center;
    gap: clamp(10px, 2vw, 18px) clamp(18px, 3vw, 34px);
    padding: clamp(12px, 2vw, 22px);
  }

  body:not(.is-playing) .intro-logo {
    grid-area: logo;
    width: clamp(62px, 15svh, 92px);
    height: clamp(62px, 15svh, 92px);
  }

  body:not(.is-playing) .intro-copy {
    grid-area: copy;
  }

  body:not(.is-playing) .wordmark {
    width: min(430px, 47vw);
  }

  body:not(.is-playing) .intro-line {
    white-space: normal;
    max-width: 52vw;
    margin-top: 4px;
  }

  body:not(.is-playing) .daily-card {
    grid-area: daily;
    width: min(540px, 52vw);
    align-self: stretch;
  }

  body:not(.is-playing) .intro-actions {
    grid-area: actions;
    width: min(360px, 34vw);
    align-self: end;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  body:not(.is-playing) .intro-actions button {
    min-height: clamp(34px, 7svh, 44px);
  }

  body:not(.is-playing) .kickstarter-promo {
    grid-area: kick;
    width: min(360px, 34vw);
    align-self: end;
    margin: 0;
  }
}

@media (max-width: 999px) and (orientation: landscape) {
  body:not(.is-playing) .deal-screen {
    min-height: 100svh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .9fr);
    grid-template-areas:
      "logo preview"
      "copy preview"
      "copy actions";
    align-content: center;
    align-items: center;
    gap: clamp(12px, 3vw, 28px);
    padding: clamp(14px, 3vw, 28px);
  }

  body:not(.is-playing) .deal-screen .intro-logo {
    grid-area: logo;
    width: clamp(58px, 15svh, 86px);
    height: clamp(58px, 15svh, 86px);
  }

  body:not(.is-playing) .deal-copy {
    grid-area: copy;
  }

  body:not(.is-playing) .deal-screen h1 {
    font-size: clamp(48px, 12vw, 92px);
  }

  body:not(.is-playing) .deal-preview {
    grid-area: preview;
    width: min(230px, 26vw);
    height: min(160px, 32svh);
    margin: 0;
  }

  body:not(.is-playing) .deal-screen .intro-actions {
    grid-area: actions;
    width: min(360px, 34vw);
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body:not(.is-playing) .deal-screen .intro-actions button {
    width: 100%;
  }
}

@media (max-width: 999px) and (orientation: landscape) {
  body.is-playing .app {
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 100svh;
    overflow: visible;
    padding: 6px;
  }

  body.is-playing .game-shell {
    height: auto;
    min-height: 100svh;
    overflow: visible;
    gap: 6px;
  }

  body.is-playing .topbar {
    min-height: 48px;
    padding: 5px 8px;
  }

  body.is-playing .topbar .logo-flip {
    width: 40px;
    height: 40px;
  }

  body.is-playing .topbar-wordmark {
    width: min(270px, 40vw);
  }

  body.is-playing .opponents {
    gap: 6px;
    overflow: visible;
  }

  body.is-playing .opponent {
    min-height: 92px;
    padding: 4px;
  }

  body.is-playing .mini-layout {
    min-height: 68px;
    padding: 5px;
  }

  body.is-playing .mini-card {
    width: clamp(34px, 6.6vw, 48px);
  }

  body.is-playing .table {
    min-height: 108px;
    padding: 6px;
  }

  body.is-playing .player-panel {
    grid-template-columns: minmax(0, 1fr) minmax(132px, 30vw);
    grid-template-rows: auto auto auto auto auto;
    min-height: auto;
    overflow: visible;
    padding: 7px;
  }

  body.is-playing .player-panel:not(.guidance-off) .message {
    min-height: 70px;
    padding: 8px 10px;
  }

  body.is-playing .actions {
    gap: 8px;
  }

  body.is-playing .actions button,
  body.is-playing .secondary-actions button {
    min-height: 34px;
  }

  body.is-playing .secondary-actions {
    position: static;
    margin-top: 8px;
    padding-top: 0;
    background: transparent;
  }

  body.is-playing .card {
    width: clamp(62px, 11vw, 82px);
  }

  body.is-playing .board-row {
    gap: clamp(10px, 3vw, 22px);
  }
}

/* Final landscape rule: use the desktop-style board on phones/tablets too. */
@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing {
    overflow: hidden;
  }

  body.is-playing .app {
    width: 100%;
    max-width: none;
    height: 100svh;
    min-height: 0;
    padding: 5px;
    overflow: hidden;
  }

  body.is-playing .game-shell {
    display: grid;
    grid-template-columns: minmax(330px, .9fr) minmax(430px, 1.1fr);
    grid-template-rows: 48px 96px minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.is-playing .topbar {
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 0;
    height: 48px;
    padding: 5px 8px;
  }

  body.is-playing .topbar .logo-flip {
    width: 38px;
    height: 38px;
  }

  body.is-playing .topbar-wordmark {
    width: min(250px, 34vw);
  }

  body.is-playing .opponents {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-content: stretch;
    gap: 6px;
    height: 96px;
    min-height: 0;
    overflow: hidden;
  }

  body.is-playing .opponent {
    min-height: 0;
    height: 96px;
    padding: 0;
  }

  body.is-playing .opponent-name,
  body.is-playing .counts {
    min-height: 24px;
    font-size: 11px;
    border-radius: 7px;
  }

  body.is-playing .mini-layout {
    min-height: 0;
    height: 68px;
    padding: 5px;
  }

  body.is-playing .mini-card {
    width: clamp(32px, 4.8vw, 42px);
  }

  body.is-playing .table {
    grid-column: 1;
    grid-row: 2 / span 2;
    height: 100%;
    min-height: 0;
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    gap: 8px;
    padding: 8px;
  }

  body.is-playing .pile-card {
    min-height: 76px;
  }

  body.is-playing .pile-stack {
    min-height: 84px;
  }

  body.is-playing .pile-stack .card {
    width: clamp(58px, 7vw, 82px);
  }

  body.is-playing .player-panel {
    grid-column: 2;
    grid-row: 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 25vw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 7px;
    gap: 5px 7px;
  }

  body.is-playing .player-heading {
    grid-column: 2;
    grid-row: 1 / span 3;
    gap: 6px;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button,
  body.is-playing .secondary-actions button {
    min-height: 28px;
    font-size: 10px;
  }

  body.is-playing .actions {
    gap: 5px;
  }

  body.is-playing .player-panel .message {
    grid-column: 1;
    grid-row: 1;
    min-height: 54px;
    max-height: 72px;
    padding: 7px 9px;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.18;
  }

  body.is-playing .message #message {
    font-size: 12px;
    line-height: 1.18;
  }

  body.is-playing .message button {
    min-height: 26px;
    padding: 0 8px;
    font-size: 10px;
  }

  body.is-playing .hand-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  body.is-playing .table-wrap {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  body.is-playing .card-row {
    gap: 8px;
  }

  body.is-playing .card {
    width: clamp(52px, 7.5vw, 72px);
  }

  body.is-playing .board-row {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
    gap: 8px;
  }

  body.is-playing .board-slot {
    min-height: clamp(78px, 17svh, 108px);
  }

  body.is-playing .secondary-actions {
    grid-column: 1 / -1;
    grid-row: 4;
    position: static;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 0;
    padding: 0;
    background: transparent;
  }

  body.is-playing .log-panel {
    display: none;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body:not(.is-playing) .deal-screen {
    min-height: 100svh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, .72fr);
    grid-template-areas:
      "copy preview"
      "copy actions";
    align-content: center;
    align-items: center;
    justify-content: center;
    gap: clamp(14px, 3vw, 28px);
    padding: clamp(12px, 2.4vw, 22px);
  }

  body:not(.is-playing) .deal-screen .intro-logo {
    display: none;
  }

  body:not(.is-playing) .deal-copy {
    grid-area: copy;
  }

  body:not(.is-playing) .deal-screen h1 {
    font-size: clamp(48px, 11vw, 86px);
  }

  body:not(.is-playing) .deal-preview {
    grid-area: preview;
    width: min(220px, 24vw);
    height: min(150px, 31svh);
    margin: 0 auto;
  }

  body:not(.is-playing) .deal-screen .intro-actions {
    grid-area: actions;
    width: min(340px, 32vw);
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

/* Landscape board refinement: opponents above the play/table area. */
@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .game-shell {
    grid-template-columns: minmax(330px, .9fr) minmax(430px, 1.1fr);
    grid-template-rows: 48px 98px minmax(0, 1fr);
    gap: 6px;
  }

  body.is-playing .opponents {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: 98px;
    gap: 8px;
    padding-inline: 4px;
  }

  body.is-playing .opponent {
    height: 98px;
    min-height: 0;
  }

  body.is-playing .mini-layout {
    height: 70px;
    min-height: 0;
    padding: 5px 8px;
  }

  body.is-playing .mini-card {
    width: clamp(34px, 4.6vw, 46px);
  }

  body.is-playing .table {
    grid-column: 1;
    grid-row: 3;
  }

  body.is-playing .player-panel {
    grid-column: 2;
    grid-row: 3;
    grid-template-columns: minmax(0, 1fr) minmax(104px, 21vw);
    gap: 5px 7px;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button,
  body.is-playing .secondary-actions button {
    min-height: 26px;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 9.5px;
    line-height: 1;
  }

  body.is-playing .actions {
    gap: 5px;
  }

  body.is-playing .player-panel .message {
    max-height: 64px;
    min-height: 52px;
  }

  body.is-playing .card {
    width: clamp(50px, 6.9vw, 68px);
  }

  body.is-playing .board-slot {
    min-height: clamp(74px, 15svh, 100px);
  }

  body.is-playing .secondary-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Landscape correction: computer players + table on left, human player full right. */
@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .game-shell {
    grid-template-columns: minmax(360px, .92fr) minmax(420px, 1.08fr);
    grid-template-rows: 48px 112px minmax(0, 1fr);
    gap: 6px;
  }

  body.is-playing .topbar {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  body.is-playing .opponents {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: 112px;
    min-height: 0;
    gap: 6px;
    padding: 0;
    overflow: hidden;
  }

  body.is-playing .opponent {
    height: 112px;
    min-height: 0;
    padding: 0;
  }

  body.is-playing .opponent-name,
  body.is-playing .counts {
    min-height: 22px;
    max-width: none;
    border-radius: 7px;
    font-size: 10px;
  }

  body.is-playing .mini-layout {
    height: 84px;
    min-height: 0;
    padding: 5px;
  }

  body.is-playing .mini-card {
    width: clamp(30px, 4vw, 40px);
  }

  body.is-playing .table {
    grid-column: 1;
    grid-row: 3;
    height: 100%;
    min-height: 0;
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    padding: 8px;
  }

  body.is-playing .player-panel {
    grid-column: 2;
    grid-row: 2 / span 2;
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(92px, 18vw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 5px 7px;
    padding: 7px;
    overflow: hidden;
  }

  body.is-playing .player-heading {
    grid-column: 2;
    grid-row: 1 / span 3;
    gap: 4px;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button {
    min-height: 23px;
    height: 23px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 8.5px;
    line-height: 1;
  }

  body.is-playing .actions {
    gap: 4px;
  }

  body.is-playing .player-panel .message {
    grid-column: 1;
    grid-row: 1;
    min-height: 48px;
    max-height: 62px;
    padding: 7px 9px;
    overflow: hidden;
  }

  body.is-playing .message #message {
    font-size: 11px;
    line-height: 1.15;
  }

  body.is-playing .message button {
    min-height: 24px;
    height: 24px;
    padding: 0 8px;
    font-size: 9px;
  }

  body.is-playing .hand-wrap {
    grid-column: 1;
    grid-row: 2;
  }

  body.is-playing .table-wrap {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
  }

  body.is-playing .card {
    width: clamp(46px, 6vw, 62px);
  }

  body.is-playing .card-row {
    gap: 7px;
  }

  body.is-playing .board-row {
    grid-template-columns: repeat(3, minmax(58px, 1fr));
    gap: 7px;
  }

  body.is-playing .board-slot {
    min-height: clamp(68px, 14svh, 92px);
  }

  body.is-playing .secondary-actions {
    grid-column: 1 / -1;
    grid-row: 4;
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin-top: 0;
    padding: 0;
    background: transparent;
  }

  body.is-playing .secondary-actions button {
    min-height: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 8.5px;
    line-height: 1;
  }
}

/* Game layout polish: solid background, no floating bottom controls. */
body {
  background: var(--pink-3);
}

body.theme-blue {
  background: #edf3fb;
}

.secondary-actions {
  background: transparent;
}

.secondary-actions:has(#tipsMenuBtn[hidden]) {
  display: none;
}

.topbar {
  padding-left: clamp(10px, 2vw, 18px);
}

@media (max-width: 999px) {
  .player-panel {
    margin-top: -2px;
  }

  .opponent {
    padding-bottom: 4px;
  }

  .mini-layout {
    min-height: 74px;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body {
    background: var(--pink-3);
  }

  body.is-playing .topbar {
    padding: 7px 12px;
  }

  body.is-playing .topbar .logo-flip {
    margin-left: 2px;
  }

  body.is-playing .game-shell {
    grid-template-rows: 52px 94px minmax(0, 1fr);
  }

  body.is-playing .opponents {
    height: 94px;
  }

  body.is-playing .opponent {
    height: 94px;
  }

  body.is-playing .mini-layout {
    height: 66px;
    padding: 4px 5px;
  }

  body.is-playing .mini-card {
    width: clamp(28px, 3.8vw, 38px);
  }

  body.is-playing .player-panel {
    margin-top: -2px;
    grid-template-columns: minmax(0, 1fr) minmax(92px, 17vw);
  }

  body.is-playing .player-heading {
    grid-row: 1 / span 4;
  }

  body.is-playing .actions {
    gap: 4px;
  }

  body.is-playing .actions button {
    min-height: 22px;
    height: 22px;
    font-size: 8px;
  }

  body.is-playing .secondary-actions {
    display: none;
  }

  body.is-playing .table-wrap {
    padding-bottom: 6px;
  }

  body.is-playing .board-slot {
    min-height: clamp(76px, 16svh, 98px);
  }
}

@media (max-width: 759px) and (orientation: portrait) {
  body.is-playing {
    overflow-y: auto;
  }

  body.is-playing .app {
    min-height: 100svh;
    height: auto;
    overflow: visible;
  }

  body.is-playing .game-shell {
    min-height: 100svh;
    height: auto;
    overflow: visible;
  }

  body.is-playing .player-panel {
    min-height: auto;
    padding-bottom: 10px;
  }

  body.is-playing .secondary-actions {
    display: none;
  }
}

/* Game layout polish: solid background, no floating bottom controls. */
body {
  background: var(--pink-3);
}

body.theme-blue {
  background: #edf3fb;
}

.secondary-actions {
  background: transparent;
}

.secondary-actions:has(#tipsMenuBtn[hidden]) {
  display: none;
}

.topbar {
  padding-left: clamp(10px, 2vw, 18px);
}

@media (max-width: 999px) {
  .player-panel {
    margin-top: -2px;
  }

  .opponent {
    padding-bottom: 4px;
  }

  .mini-layout {
    min-height: 74px;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body {
    background: var(--pink-3);
  }

  body.is-playing .topbar {
    padding: 7px 12px;
  }

  body.is-playing .topbar .logo-flip {
    margin-left: 2px;
  }

  body.is-playing .game-shell {
    grid-template-rows: 52px 94px minmax(0, 1fr);
  }

  body.is-playing .opponents {
    height: 94px;
  }

  body.is-playing .opponent {
    height: 94px;
  }

  body.is-playing .mini-layout {
    height: 66px;
    padding: 4px 5px;
  }

  body.is-playing .mini-card {
    width: clamp(28px, 3.8vw, 38px);
  }

  body.is-playing .player-panel {
    margin-top: -2px;
    grid-template-columns: minmax(0, 1fr) minmax(92px, 17vw);
  }

  body.is-playing .player-heading {
    grid-row: 1 / span 4;
  }

  body.is-playing .actions {
    gap: 4px;
  }

  body.is-playing .actions button {
    min-height: 22px;
    height: 22px;
    font-size: 8px;
  }

  body.is-playing .secondary-actions {
    display: none;
  }

  body.is-playing .table-wrap {
    padding-bottom: 6px;
  }

  body.is-playing .board-slot {
    min-height: clamp(76px, 16svh, 98px);
  }
}

@media (max-width: 759px) and (orientation: portrait) {
  body.is-playing {
    overflow-y: auto;
  }

  body.is-playing .app {
    min-height: 100svh;
    height: auto;
    overflow: visible;
  }

  body.is-playing .game-shell {
    min-height: 100svh;
    height: auto;
    overflow: visible;
  }

  body.is-playing .player-panel {
    min-height: auto;
    padding-bottom: 10px;
  }

  body.is-playing .secondary-actions {
    display: none;
  }
}

/* Visual cleanup: remove pale wrapper, fit logo, tighten player area. */
body,
body.theme-blue,
body.is-playing,
body.theme-blue.is-playing {
  background: var(--theme-surface);
}

body.is-playing .app {
  background: var(--theme-surface);
}

.game-shell {
  background: var(--theme-surface);
}

@media (max-width: 759px) and (orientation: portrait) {
  body.is-playing .app {
    padding: 4px;
  }

  body.is-playing .game-shell {
    gap: 6px;
  }

  body.is-playing .player-panel {
    margin-top: -6px;
    border-radius: 10px;
  }

  body.is-playing .player-panel:not(.guidance-off) .message {
    min-height: 92px;
  }

  body.is-playing .actions button {
    min-height: 31px;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .app,
  body.is-playing .game-shell {
    background: var(--theme-surface);
  }

  body.is-playing .topbar {
    height: 44px;
    min-height: 44px;
    padding: 5px 10px;
    overflow: hidden;
  }

  body.is-playing .topbar .logo-flip {
    width: 34px;
    height: 34px;
  }

  body.is-playing .topbar-wordmark {
    width: min(230px, 30vw);
    max-height: 34px;
    object-fit: contain;
  }

  body.is-playing .game-shell {
    grid-template-rows: 44px 88px minmax(0, 1fr);
  }

  body.is-playing .opponents {
    height: 88px;
  }

  body.is-playing .opponent {
    height: 88px;
  }

  body.is-playing .opponent-name,
  body.is-playing .counts {
    min-height: 20px;
    font-size: 9px;
  }

  body.is-playing .mini-layout {
    height: 62px;
    padding: 4px;
  }

  body.is-playing .mini-card {
    width: clamp(27px, 3.6vw, 36px);
  }

  body.is-playing .player-panel {
    margin-top: -4px;
    grid-template-columns: minmax(0, 1fr) minmax(86px, 16vw);
    border-radius: 10px;
    padding: 6px;
  }

  body.is-playing .player-panel .message {
    min-height: 44px;
    max-height: 56px;
    padding: 6px 8px;
  }

  body.is-playing .message #message {
    font-size: 10px;
    line-height: 1.12;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button {
    min-height: 20px;
    height: 20px;
    font-size: 7.8px;
  }

  body.is-playing .actions {
    gap: 3px;
  }

  body.is-playing .card {
    width: clamp(44px, 5.4vw, 58px);
  }

  body.is-playing .board-slot {
    min-height: clamp(72px, 15svh, 96px);
  }

  body.is-playing .table-wrap {
    overflow: visible;
  }
}

/* Home tips are separate from Settings; flatten backgrounds and reduce empty height. */
body:not(.theme-blue) {
  background: var(--pink);
}

body:not(.theme-blue) .intro,
body:not(.theme-blue) .deal-screen {
  background: var(--pink);
}

body.theme-blue,
body.theme-blue .intro,
body.theme-blue .deal-screen,
body.theme-blue.is-playing,
body.theme-blue.is-playing .app,
body.theme-blue.is-playing .game-shell {
  background: var(--blue);
}

.intro-actions {
  gap: 8px;
}

.intro-actions button {
  min-height: 38px;
  padding-block: 0;
}

.tips-dialog {
  width: min(92vw, 520px);
}

.tips-panel {
  padding: 14px;
}

.tips-panel .happiness-tips-list {
  margin: 0;
}

.settings-info {
  gap: 8px;
}

@media (max-width: 759px) and (orientation: portrait) {
  .intro {
    gap: 10px;
    padding-block: 12px;
  }

  .intro-logo {
    width: 100px;
    height: 100px;
  }

  .daily-card,
  .kickstarter-promo,
  .intro-actions {
    width: min(430px, calc(100vw - 34px));
  }

  .intro-actions {
    gap: 8px;
  }

  .intro-actions button {
    min-height: 38px;
  }

  body.is-playing .player-panel {
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 6px;
  }

  body.is-playing .row-wrap {
    margin-top: 0;
  }

  body.is-playing .table-wrap {
    padding-bottom: 10px;
  }

  body.is-playing .board-slot {
    min-height: 128px;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body:not(.theme-blue),
  body:not(.theme-blue).is-playing,
  body:not(.theme-blue).is-playing .app,
  body:not(.theme-blue).is-playing .game-shell {
    background: var(--pink);
  }

  body.is-playing .player-panel {
    align-self: start;
    height: auto;
    min-height: min(100%, 360px);
  }

  body.is-playing .actions {
    gap: 3px;
  }

  body.is-playing .actions button {
    min-height: 20px;
    height: 20px;
    font-size: 7.5px;
  }
}

/* Final polish: app icon setting row */
.settings-icon-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(36, 79, 138, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.settings-icon-row strong,
.settings-icon-row span {
  display: block;
}

.settings-icon-row span {
  margin-top: 4px;
  color: rgba(36, 79, 138, 0.82);
  font-size: 0.9rem;
  line-height: 1.25;
}

.settings-icon-row button {
  min-width: 150px;
}

/* Final spacing pass: home rhythm, landscape board fit, matching theme background. */
body:not(.theme-blue),
body:not(.theme-blue) .app,
body:not(.theme-blue) .intro,
body:not(.theme-blue) .deal-screen,
body:not(.theme-blue).is-playing,
body:not(.theme-blue).is-playing .app,
body:not(.theme-blue).is-playing .game-shell {
  background: var(--pink) !important;
}

body.theme-blue,
body.theme-blue .app,
body.theme-blue .intro,
body.theme-blue .deal-screen,
body.theme-blue.is-playing,
body.theme-blue.is-playing .app,
body.theme-blue.is-playing .game-shell {
  background: var(--blue) !important;
}

body:not(.is-playing) .app {
  width: 100%;
  max-width: none;
}

body:not(.is-playing) .intro {
  box-shadow: none;
}

.intro-actions {
  gap: 8px !important;
}

.intro-actions button {
  min-height: 38px !important;
  height: 38px !important;
}

@media (max-width: 759px) and (orientation: portrait) {
  .intro {
    padding-block: 12px 16px !important;
  }

  .intro-actions {
    gap: 8px !important;
  }

  .intro-actions button {
    min-height: 37px !important;
    height: 37px !important;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  html,
  body,
  body.is-playing .app {
    height: 100svh;
    min-height: 100svh;
    overflow: hidden;
  }

  body.is-playing .app {
    width: 100%;
    max-width: none;
    padding: 4px;
  }

  body.is-playing .game-shell {
    height: calc(100svh - 8px);
    max-height: calc(100svh - 8px);
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 49%) minmax(0, 51%);
    grid-template-rows: 42px 76px minmax(0, 1fr);
    grid-template-areas:
      "topbar topbar"
      "opponents opponents"
      "table player";
    gap: 4px;
    overflow: hidden;
  }

  body.is-playing .topbar {
    grid-area: topbar;
    height: 42px;
    min-height: 42px;
    padding: 5px 10px;
    border-radius: 8px;
  }

  body.is-playing .topbar .logo-flip {
    width: 32px;
    height: 32px;
  }

  body.is-playing .topbar-wordmark {
    width: min(205px, 28vw);
    max-height: 32px;
    object-fit: contain;
  }

  body.is-playing .opponents {
    grid-area: opponents;
    height: 76px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    overflow: hidden;
  }

  body.is-playing .opponent {
    height: 76px;
    min-height: 0;
    padding: 0 4px 3px;
    overflow: hidden;
  }

  body.is-playing .opponent-name {
    min-height: 18px;
    height: 18px;
    width: 58%;
    margin: 0 auto 2px;
    border-radius: 6px;
    font-size: 9px;
  }

  body.is-playing .mini-layout {
    height: 54px;
    padding: 3px;
  }

  body.is-playing .mini-card {
    width: clamp(28px, 4.5vw, 37px);
  }

  body.is-playing .table {
    grid-area: table;
    height: 100%;
    min-height: 0;
    margin: 0;
    border-radius: 9px;
  }

  body.is-playing .player-panel {
    grid-area: player;
    height: 100%;
    min-height: 0;
    margin: 0;
    align-self: stretch;
    overflow: hidden;
    border-radius: 9px;
    padding: 6px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(104px, 18vw, 140px);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 4px;
  }

  body.is-playing .player-heading {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(104px, 18vw, 140px);
    gap: 6px;
    align-items: start;
  }

  body.is-playing .player-heading > div:first-child {
    display: none;
  }

  body.is-playing .player-panel .message {
    grid-column: 1;
    grid-row: 1;
    min-height: 46px;
    height: 46px;
    max-height: 46px;
    padding: 6px 8px;
  }

  body.is-playing .message #message {
    font-size: 10px;
    line-height: 1.1;
  }

  body.is-playing .actions {
    grid-column: 2;
    grid-row: 1 / 4;
    display: grid;
    grid-auto-rows: 31px;
    align-content: start;
    gap: 5px;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button {
    height: 31px !important;
    min-height: 31px !important;
    padding: 0 8px;
    border-radius: 7px;
    font-size: 9px;
  }

  body.is-playing .hand-wrap {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    margin: 0;
  }

  body.is-playing .table-wrap {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    margin: 0;
    padding-bottom: 2px;
    overflow: visible;
  }

  body.is-playing .card {
    width: clamp(44px, 7.2vw, 62px);
  }

  body.is-playing .board-row,
  body.is-playing .card-row {
    gap: clamp(8px, 3vw, 24px);
  }

  body.is-playing .board-slot {
    min-height: clamp(72px, 21svh, 118px);
  }
}

@media (orientation: landscape) and (min-width: 1000px) {
  body.is-playing .player-panel {
    margin-top: 6px;
  }

  body.is-playing .actions button {
    min-height: 36px;
    height: 36px;
  }
}

/* Clean Happiness Tips modal + less confusing icon toggle. */
.tips-dialog {
  width: min(90vw, 430px) !important;
  max-height: min(86svh, 620px);
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--theme-contrast) 36%, #fff);
  border-radius: 22px;
  overflow: hidden;
  background: var(--paper);
  color: var(--blue);
  box-shadow: 0 22px 60px rgba(24, 60, 109, .28);
}

.tips-dialog::backdrop {
  background: rgba(24, 36, 58, .48);
  backdrop-filter: blur(8px);
}

.tips-dialog .companion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: var(--theme-contrast);
  color: var(--theme-button-text);
}

.tips-dialog .companion-head .eyebrow {
  display: none;
}

.tips-dialog h2 {
  margin: 0;
  color: var(--theme-button-text);
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1;
}

.tips-dialog #closeHappinessTips {
  flex: 0 0 auto;
  min-height: 36px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--theme-button-text) 92%, transparent);
  color: var(--theme-contrast);
  border-color: transparent;
  box-shadow: none;
}

.tips-dialog .tips-panel {
  padding: 14px;
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--theme-surface) 34%, transparent), transparent 34%),
    var(--paper);
}

.tips-dialog .happiness-tips-list {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: var(--blue);
  font-size: clamp(14px, 3.6vw, 16px);
  line-height: 1.22;
}

.tips-dialog .happiness-tips-list li {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid rgba(36, 79, 138, .12);
  border-radius: 12px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 8px 20px rgba(36, 79, 138, .08);
}

.tips-dialog .happiness-tips-list li::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: .36em;
  border-radius: 999px;
  background: var(--theme-contrast);
}

.settings-icon-row button {
  white-space: normal;
  line-height: 1.1;
}

/* Production tidy pass: one section language across home and game. */
:root {
  --caca-section-border: rgba(255, 255, 255, .58);
  --caca-section-fill: rgba(255, 255, 255, .16);
  --caca-section-gap: 8px;
}

body.theme-blue {
  --caca-section-border: rgba(231, 159, 184, .52);
  --caca-section-fill: rgba(231, 159, 184, .12);
}

body:not(.is-playing) .intro-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: 38px;
  gap: var(--caca-section-gap) !important;
  align-items: stretch;
}

body:not(.is-playing) .intro-actions button {
  height: 38px !important;
  min-height: 38px !important;
  margin: 0 !important;
}

body:not(.is-playing) .intro-actions .primary,
body:not(.is-playing) .theme-home-button {
  grid-column: 1 / -1;
}

#startBtn,
#resumeBtn,
#startBtn + #resumeBtn,
#startBtn ~ button {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.is-playing .game-shell {
  gap: var(--caca-section-gap) !important;
}

body.is-playing .opponents,
body.is-playing .table,
body.is-playing .player-panel {
  border: 2px solid var(--caca-section-border) !important;
  border-radius: 16px !important;
  background: var(--caca-section-fill) !important;
  box-shadow: none !important;
}

body.is-playing .opponents {
  padding: 8px !important;
}

body.is-playing .table {
  padding: 10px !important;
}

body.is-playing .player-panel {
  padding: 10px !important;
}

body.is-playing .topbar {
  margin-bottom: 0 !important;
}

body.is-playing .opponent {
  box-shadow: none !important;
}

body.is-playing .opponent > .mini-layout,
body.is-playing .opponent {
  background: rgba(255, 255, 255, .82) !important;
  border: 1px solid rgba(255, 255, 255, .45) !important;
  border-radius: 12px !important;
}

body.is-playing .opponent-name,
body.is-playing .player-heading h3,
body.is-playing .actions button,
body.is-playing .secondary-actions button {
  box-shadow: none !important;
}

@media (max-width: 759px) and (orientation: portrait) {
  body.is-playing .game-shell {
    gap: 7px !important;
  }

  body.is-playing .opponents,
  body.is-playing .table,
  body.is-playing .player-panel {
    border-radius: 14px !important;
  }

  body.is-playing .opponents {
    padding: 7px !important;
  }

  body.is-playing .table,
  body.is-playing .player-panel {
    padding: 8px !important;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .game-shell {
    gap: 7px !important;
    grid-template-rows: 42px 74px minmax(0, 1fr) !important;
  }

  body.is-playing .opponents {
    height: 74px !important;
    padding: 5px !important;
  }

  body.is-playing .opponent {
    height: 62px !important;
    min-height: 0 !important;
    padding: 0 3px 2px !important;
  }

  body.is-playing .mini-layout {
    height: 43px !important;
    min-height: 0 !important;
    padding: 2px !important;
  }

  body.is-playing .mini-card {
    width: clamp(26px, 4.2vw, 35px) !important;
  }

  body.is-playing .table,
  body.is-playing .player-panel {
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 7px !important;
  }

  body.is-playing .player-panel {
    align-self: stretch !important;
    grid-template-columns: minmax(0, 1fr) clamp(104px, 16vw, 128px) !important;
    row-gap: 5px !important;
    column-gap: 7px !important;
  }

  body.is-playing .actions {
    gap: 5px !important;
    grid-auto-rows: 31px !important;
  }

  body.is-playing .player-heading h3,
  body.is-playing .actions button {
    height: 31px !important;
    min-height: 31px !important;
    font-size: 9px !important;
  }

  body.is-playing .player-panel .message {
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
  }

  body.is-playing .hand-wrap,
  body.is-playing .table-wrap {
    min-height: 0 !important;
  }
}

@media (orientation: landscape) and (min-width: 1000px) {
  body.is-playing .game-shell {
    gap: 10px !important;
  }

  body.is-playing .opponents,
  body.is-playing .table,
  body.is-playing .player-panel {
    border-radius: 14px !important;
  }

  body.is-playing .player-panel {
    margin-top: 0 !important;
    height: 100% !important;
  }
}

/* Final header breathing + equal game section rhythm. */
body.is-playing .app {
  padding-top: 12px !important;
}

body.is-playing .game-shell {
  --game-section-gap: 10px;
  gap: var(--game-section-gap) !important;
}

body.is-playing .topbar {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
  margin: 0 0 var(--game-section-gap) !important;
}

body.is-playing .opponents,
body.is-playing .table,
body.is-playing .player-panel {
  margin: 0 !important;
}

@media (max-width: 759px) and (orientation: portrait) {
  body.is-playing .app {
    padding: 10px 8px 8px !important;
  }

  body.is-playing .game-shell {
    --game-section-gap: 9px;
    gap: var(--game-section-gap) !important;
  }

  body.is-playing .topbar {
    margin-bottom: 0 !important;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .app {
    padding: 8px !important;
  }

  body.is-playing .game-shell {
    --game-section-gap: 7px;
    gap: var(--game-section-gap) !important;
  }

  body.is-playing .topbar {
    margin-bottom: 0 !important;
  }
}

/* Final first-load polish: keep the home action grid consistent before any game state exists. */
body:not(.is-playing) .intro-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  grid-auto-rows: 42px !important;
  gap: 10px !important;
  align-items: stretch !important;
}

body:not(.is-playing) .intro-actions button {
  width: 100% !important;
  min-height: 42px !important;
  height: 42px !important;
  margin: 0 !important;
}

body:not(.is-playing) #startBtn {
  grid-column: 1 / -1 !important;
  order: 1 !important;
}

body:not(.is-playing) #resumeBtn[hidden] {
  display: none !important;
}

body:not(.is-playing) #resumeBtn:not([hidden]) {
  grid-column: 1 / -1 !important;
  order: 2 !important;
}

body:not(.is-playing) #companionIntroBtn { order: 3 !important; }
body:not(.is-playing) #homeTimerBtn { order: 4 !important; }
body:not(.is-playing) #rulesBtn { order: 5 !important; }
body:not(.is-playing) #homeIrlBtn { order: 6 !important; }
body:not(.is-playing) #homeSettingsBtn { order: 7 !important; }
body:not(.is-playing) #homeBigScreenBtn { order: 8 !important; }
body:not(.is-playing) #themeToggleBtn {
  grid-column: 1 / -1 !important;
  order: 9 !important;
}
body:not(.is-playing) #homeFartBtn {
  grid-column: 1 / -1 !important;
  order: 10 !important;
}

/* Blue theme readability: labels need to sit above the blue background. */
body.theme-blue.is-playing .row-head p,
body.theme-blue.is-playing .row-wrap > p,
body.theme-blue.is-playing .table-wrap > p,
body.theme-blue.is-playing .player-panel [data-i18n="hand"],
body.theme-blue.is-playing .player-panel [data-i18n="tableCards"] {
  color: var(--pink) !important;
  opacity: 1 !important;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18) !important;
}

body:not(.theme-blue).is-playing .row-head p,
body:not(.theme-blue).is-playing .row-wrap > p,
body:not(.theme-blue).is-playing .table-wrap > p,
body:not(.theme-blue).is-playing .player-panel [data-i18n="hand"],
body:not(.theme-blue).is-playing .player-panel [data-i18n="tableCards"] {
  opacity: 1 !important;
}

/* Ready-ish polish: first-load home rhythm, cleaner opponents, readable blue labels. */
body:not(.is-playing) .intro-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  grid-auto-flow: row dense !important;
  grid-auto-rows: 42px !important;
  gap: 10px !important;
}

body:not(.is-playing) .intro-actions > * {
  grid-row: auto !important;
  margin: 0 !important;
}

body:not(.is-playing) .intro-actions button {
  height: 42px !important;
  min-height: 42px !important;
}

body:not(.is-playing) #startBtn {
  grid-column: 1 / -1 !important;
  order: 1 !important;
}

body:not(.is-playing) #resumeBtn[hidden] {
  display: none !important;
  visibility: hidden !important;
  position: absolute !important;
  pointer-events: none !important;
}

body:not(.is-playing) #resumeBtn:not([hidden]) {
  grid-column: 1 / -1 !important;
  order: 2 !important;
}

body:not(.is-playing) #companionIntroBtn { grid-column: auto !important; order: 3 !important; }
body:not(.is-playing) #homeTimerBtn { grid-column: auto !important; order: 4 !important; }
body:not(.is-playing) #rulesBtn { grid-column: auto !important; order: 5 !important; }
body:not(.is-playing) #homeIrlBtn { grid-column: auto !important; order: 6 !important; }
body:not(.is-playing) #homeSettingsBtn { grid-column: auto !important; order: 7 !important; }
body:not(.is-playing) #homeBigScreenBtn { grid-column: auto !important; order: 8 !important; }
body:not(.is-playing) #themeToggleBtn { grid-column: 1 / -1 !important; order: 9 !important; }
body:not(.is-playing) #homeFartBtn { grid-column: 1 / -1 !important; order: 10 !important; }

body.is-playing .opponent {
  min-height: 0 !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.is-playing .opponent .mini-layout,
body.is-playing .opponent.active .mini-layout,
body.is-playing .opponent.cacahead .mini-layout {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

body.is-playing .opponent .mini-board {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.opponent-name {
  border: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  cursor: pointer;
  font-family: inherit;
}

body.theme-blue.is-playing .row-head p,
body.theme-blue.is-playing .row-wrap > p,
body.theme-blue.is-playing .table-wrap > p,
body.theme-blue.is-playing .player-panel [data-i18n="hand"],
body.theme-blue.is-playing .player-panel [data-i18n="tableCards"] {
  color: var(--pink) !important;
  opacity: 1 !important;
}

/* Tiny launch polish: slimmer home buttons and individual computer player boxes. */
body:not(.is-playing) .intro-actions {
  grid-auto-rows: 40px !important;
  gap: 9px !important;
}

body:not(.is-playing) .intro-actions button {
  min-height: 40px !important;
  height: 40px !important;
}

@media (max-width: 520px) {
  body:not(.is-playing) .intro-actions {
    grid-auto-rows: 39px !important;
    gap: 8px !important;
  }

  body:not(.is-playing) .intro-actions button {
    min-height: 39px !important;
    height: 39px !important;
  }
}

body.is-playing .opponents {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  gap: var(--caca-section-gap, 10px) !important;
}

body.is-playing .opponent {
  border: 2px solid var(--caca-section-border) !important;
  border-radius: 16px !important;
  background: var(--caca-section-fill) !important;
  padding: 8px !important;
  box-shadow: none !important;
}

body.is-playing .opponent .mini-layout,
body.is-playing .opponent.active .mini-layout,
body.is-playing .opponent.cacahead .mini-layout {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

body.is-playing .opponent.out {
  opacity: 0.68 !important;
}

@media (max-width: 520px) {
  body.is-playing .opponent {
    padding: 7px !important;
  }
}

@media (orientation: landscape) and (max-width: 999px) {
  body.is-playing .opponents {
    gap: 6px !important;
  }

  body.is-playing .opponent {
    padding: 5px !important;
  }
}

/* Settings polish: helper notes sit with their own controls, not at the bottom. */
.companion-note.inline-note {
  margin-top: -4px !important;
  margin-bottom: 4px !important;
}

.settings-links a {
  cursor: pointer;
}

/* Reversed card backs: pink game gets blue backs with pink logo for better contrast. */
body:not(.theme-blue) .deck-card,
body:not(.theme-blue) .draw-card,
body:not(.theme-blue) .burn-card {
  background-image: url("./assets/cards/card-back-premium-blue.png") !important;
}
