:root {
  --bg-dark: #100c08;
  --bg-brown: #1b120b;
  --panel: rgba(30, 20, 12, 0.94);
  --panel-2: rgba(52, 35, 20, 0.88);
  --wood: #3a2515;
  --wood-2: #6b3d1b;
  --gold: #c8943a;
  --gold-light: #f0c56c;
  --gold-dark: #8f5f1d;
  --cream: #fff3d6;
  --muted: #d8bd82;
  --good: #42b96b;
  --bad: #d84b3f;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.42);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(circle at 18% 7%, rgba(240, 197, 108, 0.16), transparent 30%),
    radial-gradient(circle at 86% 92%, rgba(143, 95, 29, 0.22), transparent 34%),
    linear-gradient(145deg, var(--bg-dark), var(--bg-brown) 52%, #120b06);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.screen {
  width: 100%;
  height: 100dvh;
  display: none;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
}

.screen.active {
  display: flex;
}

.start-screen {
  position: relative;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-direction: column;
  gap: 6px;
}

.start-card {
  width: min(560px, calc(100vw - 16px));
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, rgba(48, 31, 18, 0.96), rgba(24, 16, 10, 0.96));
  border: 2px solid rgba(200, 148, 58, 0.78);
  border-radius: 24px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 243, 214, 0.06);
  padding: clamp(10px, 2.2dvh, 16px) clamp(10px, 2.2dvh, 16px) clamp(9px, 1.5dvh, 13px);
  text-align: center;
}

.logo {
  width: clamp(36px, 6dvh, 50px);
  height: clamp(36px, 6dvh, 50px);
  margin: 0 auto 6px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #201207;
  font-size: clamp(17px, 2.9dvh, 22px);
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
}

h1 {
  margin: 0 0 4px;
  color: var(--gold-light);
  font-size: clamp(24px, 4.4dvh, 38px);
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.38);
}

.lead {
  margin: 0 auto 8px;
  max-width: 450px;
  color: var(--muted);
  font-size: clamp(12px, 1.8dvh, 15px);
  line-height: 1.25;
}

.players-setup {
  display: block;
  margin: 0 auto 8px;
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  text-align: left;
  min-width: 0;
}

label {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: var(--cream);
  font-weight: 850;
}

input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 8px 11px;
  border: 2px solid rgba(200, 148, 58, 0.72);
  border-radius: 14px;
  background: rgba(255, 243, 214, 0.96);
  color: #201207;
  font-size: clamp(15px, 2dvh, 17px);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input[type="text"]:focus {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 4px rgba(200, 148, 58, 0.22);
}

.player-count-box,
.difficulty-box,
.theme-box {
  width: 100%;
  min-inline-size: 0;
  border: 2px solid rgba(200, 148, 58, 0.68);
  border-radius: 16px;
  padding: 8px;
  margin: 0 0 8px;
  background: rgba(255, 243, 214, 0.045);
}

.player-count-box legend,
.difficulty-box legend,
.theme-box legend {
  padding: 0 8px;
  color: var(--gold-light);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-count-options,
.difficulty-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.player-count-option,
.difficulty-option {
  position: relative;
  display: grid;
  place-items: center;
  gap: 0;
  min-height: clamp(38px, 5.6dvh, 46px);
  border: 2px solid rgba(200, 148, 58, 0.58);
  border-radius: 14px;
  background: rgba(32, 20, 10, 0.72);
  color: var(--cream);
  cursor: pointer;
  overflow: hidden;
}

.player-count-option input,
.difficulty-option input,
.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  flex: 0 0 auto;
}

.player-count-option span,
.difficulty-option span {
  color: var(--cream);
  font-size: clamp(14px, 2dvh, 17px);
  font-weight: 950;
}

.difficulty-option small {
  color: var(--muted);
  font-weight: 800;
  font-size: clamp(10px, 1.55dvh, 12px);
}


.difficulty-option {
  min-height: clamp(46px, 6.8dvh, 56px);
}

.player-count-box {
  padding-top: 5px;
  padding-bottom: 5px;
}

.player-count-option:has(input:checked),
.difficulty-option:has(input:checked),
.theme-option:has(input:checked) {
  border-color: var(--gold-light);
  background: linear-gradient(180deg, rgba(200, 148, 58, 0.33), rgba(70, 43, 18, 0.78));
  box-shadow: 0 0 0 2px rgba(240, 197, 108, 0.13), 0 8px 20px rgba(0, 0, 0, 0.25);
}

.theme-slider {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: stretch;
  gap: 6px;
}

.theme-scroll-btn {
  border: 2px solid rgba(200, 148, 58, 0.62);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(200, 148, 58, 0.26), rgba(39, 23, 11, 0.9));
  color: var(--cream);
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 7px 14px rgba(0, 0, 0, 0.22);
}

.theme-scroll-btn:active {
  transform: translateY(1px);
}

.theme-options {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  align-items: stretch;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.theme-options::-webkit-scrollbar {
  display: none;
}

.theme-option {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: stretch;
  flex: 0 0 calc((100% - 14px) / 3);
  width: calc((100% - 14px) / 3);
  min-width: calc((100% - 14px) / 3);
  max-width: calc((100% - 14px) / 3);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  border: 2px solid rgba(200, 148, 58, 0.58);
  border-radius: 14px;
  padding: 6px;
  background: rgba(32, 20, 10, 0.72);
  cursor: pointer;
  overflow: hidden;
  scroll-snap-align: start;
}

.theme-preview {
  width: 100%;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 243, 214, 0.08);
  display: grid;
  place-items: center;
}

.theme-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.theme-title {
  min-height: 30px;
  display: grid;
  place-items: center;
  color: var(--cream);
  font-size: clamp(8.4px, 1.35dvh, 10.5px);
  font-weight: 900;
  line-height: 1.08;
  text-align: center;
}

.primary-btn {
  width: 100%;
  border: 2px solid rgba(255, 243, 214, 0.34);
  border-radius: 16px;
  padding: clamp(10px, 2dvh, 13px) 18px;
  color: #211407;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.34);
  font-size: clamp(18px, 2.6dvh, 21px);
  font-weight: 950;
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}

.start-card > .primary-btn:last-child {
  margin-bottom: 0;
}

.primary-btn:active,
.small-btn:active {
  transform: scale(0.98);
}


label.disabled-player {
  opacity: 0.45;
}

label.disabled-player input[type="text"] {
  cursor: not-allowed;
  filter: grayscale(0.45);
}


.more-games-line {
  position: static;
  width: min(560px, calc(100vw - 16px));
  display: block;
  text-align: center;
  color: #ffffff;
  font-size: clamp(11px, 1.65dvh, 14px);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  z-index: 4;
  flex: 0 0 auto;
  margin-top: 2px;
}

.more-games-line a {
  color: #ffffff;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.more-games-line a:hover,
.more-games-line a:focus-visible {
  color: #ffffff;
  text-decoration-thickness: 2px;
}

.start-stats {
  position: static;
  width: min(560px, calc(100vw - 16px));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 3vw, 22px);
  flex-wrap: wrap;
  color: rgba(255, 243, 214, 0.74);
  font-size: clamp(9px, 1.45dvh, 12px);
  line-height: 1.15;
  text-align: center;
  pointer-events: none;
}

.start-stats strong {
  color: var(--gold-light);
  font-weight: 950;
}

.game-screen {
  flex-direction: column;
  gap: clamp(4px, 0.8dvh, 7px);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
  width: min(920px, 100%);
  margin: 0 auto;
  flex: 0 0 auto;
}

.game-screen.solo-mode .topbar {
  grid-template-columns: 1fr auto;
}

.game-screen.solo-mode #player2Box {
  display: none;
}

.end-screen.solo-mode .final-score {
  grid-template-columns: 1fr;
}

.end-screen.solo-mode .final-score div:nth-child(2) {
  display: none;
}

.player-box {
  min-width: 0;
  border-radius: 16px;
  background: rgba(32, 20, 10, 0.82);
  border: 2px solid rgba(200, 148, 58, 0.36);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  padding: clamp(4px, 0.85dvh, 7px) 8px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.player-box.active-player {
  border-color: var(--gold-light);
  background: linear-gradient(180deg, rgba(94, 58, 24, 0.94), rgba(45, 27, 14, 0.94));
  transform: translateY(-1px);
}

.player-name {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: clamp(10px, 1.45dvh, 12px);
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.score {
  display: block;
  color: var(--cream);
  font-size: clamp(17px, 2.9dvh, 22px);
  line-height: 1;
  font-weight: 950;
}

.turn-box {
  min-width: 86px;
  text-align: center;
  padding: clamp(4px, 0.8dvh, 6px) 8px;
  border-radius: 16px;
  color: #211407;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.26);
  font-weight: 950;
}

.turn-label {
  display: block;
  color: rgba(33, 20, 7, 0.72);
  font-size: clamp(8px, 1.1dvh, 10px);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}


.game-screen.solo-mode .turn-box {
  display: none;
}

.turn-name {
  display: block;
  max-width: 115px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #211407;
  font-size: clamp(12px, 1.85dvh, 15px);
}

.message {
  min-height: clamp(16px, 2.2dvh, 22px);
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--gold-light);
  font-size: clamp(12px, 1.75dvh, 14px);
  font-weight: 850;
  flex: 0 0 auto;
}

.board-wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: visible;
}

.board {
  display: grid;
  gap: var(--board-gap);
  max-width: 100%;
  max-height: 100%;
}

.board-easy {
  --board-gap: clamp(12px, 2.2vmin, 20px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(92vw, 580px, calc((100dvh - 176px) * 0.68));
}

.board-medium {
  --board-gap: clamp(6px, 1.2vmin, 12px);
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(92vw, 580px, calc((100dvh - 176px) * 0.58));
}

.card {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
  perspective: 900px;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
}

.board-medium .card {
  border-radius: 14px;
}

.card[disabled] {
  cursor: default;
}

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.36s ease;
  box-shadow: var(--shadow);
}

.card.flipped .card-inner,
.card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  backface-visibility: hidden;
  overflow: hidden;
}

.card-back {
  color: var(--gold-light);
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 243, 214, 0.22), transparent 28%),
    linear-gradient(135deg, #5a3317, #1c1109);
  border: 3px solid rgba(200, 148, 58, 0.82);
}

.card-back::before {
  content: "?";
  width: clamp(32px, 9vw, 70px);
  height: clamp(32px, 9vw, 70px);
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255, 243, 214, 0.11);
  color: var(--gold-light);
  font-size: clamp(28px, 8vw, 56px);
  font-weight: 950;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(240, 197, 108, 0.18);
}

.board-medium .card-back::before {
  width: clamp(22px, 5vw, 42px);
  height: clamp(22px, 5vw, 42px);
  border-radius: 12px;
  font-size: clamp(20px, 4.6vw, 34px);
}

.card-front {
  transform: rotateY(180deg);
  background: var(--cream);
  border: 3px solid rgba(200, 148, 58, 0.82);
}

.card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  pointer-events: none;
}

.card.matched .card-inner {
  box-shadow: 0 10px 24px rgba(66, 185, 107, 0.2);
}

.card.matched .card-front {
  border-color: rgba(66, 185, 107, 0.72);
}

.bottom-actions {
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  flex: 0 0 auto;
  padding-bottom: 1px;
}

.small-btn {
  padding: clamp(6px, 1.15dvh, 8px) 9px;
  border-radius: 13px;
  border: 2px solid rgba(200, 148, 58, 0.62);
  background: linear-gradient(180deg, rgba(70, 43, 20, 0.95), rgba(27, 17, 9, 0.95));
  color: var(--cream);
  font-weight: 950;
  font-size: clamp(12px, 1.65dvh, 14px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.card.compare-zoom {
  z-index: 25;
  animation: compareZoom 0.75s ease-in-out both;
}

@keyframes compareZoom {
  0% { transform: scale(1); }
  45% { transform: scale(1.09); }
  65% { transform: scale(1.09); }
  100% { transform: scale(1); }
}

.end-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 7, 4, 0.82);
  backdrop-filter: blur(5px);
}

.end-screen.show {
  display: flex;
}

.end-card {
  width: min(500px, 100%);
  padding: 24px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(48, 31, 18, 0.98), rgba(24, 16, 10, 0.98));
  border: 2px solid rgba(200, 148, 58, 0.78);
  text-align: center;
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.42);
}

.end-card h2 {
  margin: 0 0 10px;
  color: var(--gold-light);
  font-size: clamp(32px, 7vw, 50px);
  line-height: 1;
}

.winner-text {
  margin: 0 0 18px;
  color: var(--cream);
  font-size: 20px;
  font-weight: 850;
}

.final-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}

.final-score div {
  border: 1px solid rgba(200, 148, 58, 0.42);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 243, 214, 0.07);
}

.final-score strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
}

.final-score span {
  display: block;
  color: var(--cream);
  font-size: 31px;
  font-weight: 950;
}


.secondary-end-btn {
  margin-bottom: 10px;
  background: linear-gradient(180deg, rgba(70, 43, 20, 0.95), rgba(27, 17, 9, 0.95));
  color: var(--cream);
  border-color: rgba(200, 148, 58, 0.72);
}

.secondary-end-btn[hidden] {
  display: none;
}

.end-menu-btn {
  margin-top: 10px;
  background: rgba(255, 243, 214, 0.08);
  color: var(--cream);
  border-color: rgba(200, 148, 58, 0.52);
  box-shadow: none;
}

.end-menu-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 243, 214, 0.14);
}

.times-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 7, 4, 0.86);
  backdrop-filter: blur(5px);
}

.times-modal.show {
  display: flex;
}

.times-card {
  position: relative;
  width: min(460px, 100%);
  max-height: min(78dvh, 620px);
  display: flex;
  flex-direction: column;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(48, 31, 18, 0.98), rgba(24, 16, 10, 0.98));
  border: 2px solid rgba(200, 148, 58, 0.78);
  box-shadow: 0 22px 62px rgba(0, 0, 0, 0.48);
}

.times-card h2 {
  margin: 0 42px 6px 0;
  color: var(--gold-light);
  font-size: clamp(26px, 6vw, 38px);
  line-height: 1;
}

.times-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 850;
}

.times-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(200, 148, 58, 0.58);
  border-radius: 50%;
  background: rgba(32, 20, 10, 0.86);
  color: var(--cream);
  font-size: 26px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
}

.times-list {
  overflow-y: auto;
  display: grid;
  gap: 7px;
  padding-right: 3px;
}

.times-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(200, 148, 58, 0.36);
  border-radius: 14px;
  background: rgba(255, 243, 214, 0.07);
}

.times-place {
  color: var(--muted);
  font-weight: 950;
}

.times-player {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--cream);
  font-weight: 850;
}

.times-time {
  color: var(--gold-light);
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.times-empty {
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(200, 148, 58, 0.36);
  border-radius: 14px;
  color: var(--cream);
  background: rgba(255, 243, 214, 0.07);
  text-align: center;
  font-weight: 800;
}


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

.confetti-piece {
  position: absolute;
  top: -18px;
  width: calc(10px * var(--scale, 1));
  height: calc(14px * var(--scale, 1));
  opacity: 0.95;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 230, 160, 0.25);
  animation-name: confettiFall;
  animation-timing-function: cubic-bezier(0.12, 0.64, 0.34, 1);
  animation-fill-mode: forwards;
}

.confetti-piece.circle {
  width: calc(9px * var(--scale, 1));
  height: calc(9px * var(--scale, 1));
  border-radius: 50%;
}

.confetti-piece.strip {
  width: calc(6px * var(--scale, 1));
  height: calc(18px * var(--scale, 1));
  border-radius: 2px;
}


.confetti-piece.diamond {
  width: calc(11px * var(--scale, 1));
  height: calc(11px * var(--scale, 1));
  border-radius: 2px;
  transform-origin: center;
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), calc(100dvh + 60px), 0) rotate(var(--rotate));
    opacity: 0;
  }
}

@media (max-width: 520px) {
  .screen {
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .start-card {
    width: min(100%, calc(100vw - 12px));
    border-radius: 20px;
    padding-bottom: 7px;
  }

  .start-card > .primary-btn:last-child {
    margin-bottom: 0;
  }

  .theme-slider {
    grid-template-columns: 26px minmax(0, 1fr) 26px;
    gap: 5px;
  }

  .theme-scroll-btn {
    border-radius: 11px;
    font-size: 24px;
  }

  .theme-options {
    gap: 5px;
  }

  .theme-option {
    flex: 0 0 calc((100% - 10px) / 3);
    width: calc((100% - 10px) / 3);
    min-width: calc((100% - 10px) / 3);
    max-width: calc((100% - 10px) / 3);
    padding: 4px;
    border-radius: 12px;
  }

  .theme-preview {
    border-radius: 8px;
  }

  .theme-title {
    min-height: 28px;
    font-size: 9px;
  }

  .players-setup {
    margin-bottom: 6px;
  }

  .form-grid {
    gap: 6px;
  }

  .topbar {
    grid-template-columns: 1fr auto 1fr;
    gap: 5px;
  }

  .game-screen.solo-mode .topbar {
    grid-template-columns: 1fr auto;
  }

  .turn-box {
    min-width: 78px;
    padding: 4px 6px;
  }

  .turn-name {
    max-width: 92px;
  }

  .player-box {
    padding: 4px 6px;
    border-radius: 13px;
  }

  .board-easy {
    --board-gap: clamp(8px, 1.7vmin, 12px);
    width: min(94vw, calc((100dvh - 136px) * 0.68));
  }

  .board-medium {
    --board-gap: clamp(4px, 1.1vmin, 7px);
    width: min(94vw, calc((100dvh - 136px) * 0.58));
  }
}

@media (max-height: 700px) {
  .start-card {
    padding: 9px 9px 8px;
  }

  .lead {
    display: none;
  }

  .form-grid {
    gap: 5px;
  }

  .players-setup {
    margin-bottom: 6px;
  }

  .player-count-box,
  .difficulty-box,
  .theme-box {
    padding: 6px;
    margin-bottom: 6px;
  }

  .player-count-option {
    min-height: 34px;
  }

  .difficulty-option {
    min-height: 42px;
  }

  .theme-title {
    min-height: 22px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .start-card {
    width: min(720px, calc(100vw - 16px));
  }

  .start-card {
    display: grid;
    grid-template-columns: 0.75fr 1.25fr;
    column-gap: 10px;
    align-items: start;
  }

  .logo,
  .start-card h1,
  .lead,
  .players-setup,
  .form-grid,
  .player-count-box,
  .difficulty-box,
  .theme-box,
  .primary-btn {
    grid-column: auto;
  }

  .logo,
  .start-card h1,
  .lead,
  .players-setup {
    grid-column: 1;
  }

  .player-count-box,
  .difficulty-box,
  .theme-box,
  .primary-btn {
    grid-column: 2;
  }

  .logo {
    margin-top: 0;
  }

  .game-screen {
    gap: 5px;
  }

  .topbar {
    grid-template-columns: 1fr auto 1fr;
  }

  .player-box {
    padding: 6px 9px;
  }

  .turn-box {
    padding: 6px 9px;
  }

  .message {
    min-height: 18px;
  }

  .bottom-actions {
    display: grid;
  }

  .board-easy {
    width: min(58vw, 560px, calc((100dvh - 112px) * 0.68));
  }

  .board-medium {
    width: min(60vw, 560px, calc((100dvh - 112px) * 0.58));
  }
}


/* v34 - poprawka wyboru tematów: 3 widoczne, wyższe ramki, całe zdjęcia */
.theme-options {
  align-items: stretch;
}

.theme-option {
  flex: 0 0 calc((100% - 14px) / 3) !important;
  width: calc((100% - 14px) / 3) !important;
  min-width: calc((100% - 14px) / 3) !important;
  max-width: calc((100% - 14px) / 3) !important;
  aspect-ratio: auto !important;
  height: clamp(118px, 18dvh, 150px) !important;
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) 30px !important;
  gap: 5px !important;
  padding: 6px !important;
}

.theme-preview {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
}

.theme-preview img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
}

.theme-title {
  min-height: 0 !important;
  height: 30px !important;
  display: grid !important;
  place-items: center !important;
}

@media (max-width: 560px) {
  .theme-option {
    flex: 0 0 calc((100% - 10px) / 3) !important;
    width: calc((100% - 10px) / 3) !important;
    min-width: calc((100% - 10px) / 3) !important;
    max-width: calc((100% - 10px) / 3) !important;
    height: clamp(108px, 16.5dvh, 134px) !important;
    grid-template-rows: minmax(0, 1fr) 28px !important;
    padding: 4px !important;
    gap: 4px !important;
  }

  .theme-title {
    height: 28px !important;
    font-size: 9px !important;
    line-height: 1.05 !important;
  }
}


@media (max-width: 560px) {
  .start-screen {
    gap: 3px !important;
    justify-content: flex-start !important;
  }

  .start-card {
    max-height: calc(100dvh - 52px) !important;
    padding-bottom: 8px !important;
  }
}


/* v36: mniejsze miejsce na podpis tematu */
.theme-title {
  height: 20px !important;
  min-height: 0 !important;
  font-size: clamp(8.2px, 1.2dvh, 10px) !important;
  line-height: 1 !important;
  padding: 0 1px !important;
}

.theme-option {
  grid-template-rows: minmax(0, 1fr) 20px !important;
}

@media (max-width: 560px) {
  .theme-title {
    height: 20px !important;
    font-size: 8.4px !important;
    line-height: 1 !important;
  }
  .theme-option {
    grid-template-rows: minmax(0, 1fr) 20px !important;
  }
}
