:root {
  color-scheme: light;
  --ink: #141714;
  --console: rgba(16, 16, 15, 0.88);
  --console-line: rgba(255, 255, 255, 0.18);
  --cream: #f4ead0;
  --cream-2: #dfc889;
  --green: #244f35;
  --blue: #1e5275;
  --red: #b52029;
  --gold: #d8a13a;
  --shadow: 0 14px 26px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--cream);
  background: #142016;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.game-stage {
  display: grid;
  grid-template-columns: minmax(980px, 1fr) 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(7, 11, 8, 0.08), rgba(7, 11, 8, 0.22) 58%, rgba(7, 11, 8, 0.42)),
    url("../public/assets/generated/table-background.png") center / cover no-repeat,
    #263823;
}

.playmat {
  position: relative;
  min-height: 100vh;
  padding: 10px 14px 320px;
  overflow: hidden;
}

.game-title {
  position: absolute;
  top: 8px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.74), rgba(0, 0, 0, 0.28));
  border-left: 4px solid var(--red);
  box-shadow: var(--shadow);
}

.game-title h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 0;
  text-shadow: 0 2px 2px #000;
}

.game-title span,
.nameplate span,
.deck-stack b,
.cost,
.pile-count {
  display: grid;
  place-items: center;
  border-radius: 5px;
  font-weight: 900;
}

.game-title span {
  min-width: 74px;
  min-height: 28px;
  background: #eef0e6;
  color: #222;
}

.player-banner {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
}

.opponent-zone {
  top: 8px;
  left: 0;
  right: auto;
  justify-content: flex-start;
}

.human-banner {
  left: 0;
  bottom: 12px;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.nameplate {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 170px;
  height: 54px;
  padding: 0 10px 0 12px;
  background: linear-gradient(90deg, rgba(4, 17, 34, 0.92), rgba(5, 33, 54, 0.72));
  border-left: 5px solid var(--red);
  box-shadow: var(--shadow);
}

.nameplate strong {
  flex: 1;
  overflow: hidden;
  min-width: 0;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  text-overflow: ellipsis;
  text-shadow: 0 2px 2px #000;
  white-space: nowrap;
}

.nameplate span,
.deck-stack b {
  width: 26px;
  height: 26px;
  background: #23364d;
  border: 2px solid rgba(255, 255, 255, 0.56);
  color: #fff;
  text-shadow: 0 1px 1px #000;
}

.nameplate .score-badge {
  display: inline-grid;
  place-items: center;
  width: auto;
  min-width: 74px;
  height: 30px;
  padding: 0 8px;
  border-color: rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  background: linear-gradient(180deg, #39506a, #17293d);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.deck-stack {
  position: relative;
  width: 118px;
  height: 52px;
}

.deck-stack span {
  position: absolute;
  width: 74px;
  height: 48px;
  border: 3px solid #050708;
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    repeating-linear-gradient(90deg, #264c6d 0 8px, #d5c792 8px 12px, #264c6d 12px 20px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.48);
}

.deck-stack span:nth-child(1) {
  left: 0;
  top: 4px;
}

.deck-stack span:nth-child(2) {
  left: 22px;
  top: 2px;
}

.deck-stack span:nth-child(3) {
  left: 44px;
  top: 0;
}

.deck-stack b {
  position: absolute;
  right: 0;
  bottom: 0;
  background: var(--red);
}

.played-strip {
  display: flex;
  gap: 5px;
  max-width: 38vw;
  overflow: hidden;
}

.empty-strip {
  color: rgba(255, 255, 255, 0.76);
}

.mini-card {
  width: 72px;
  min-height: 38px;
  border: 2px solid #111;
  border-radius: 5px;
  background: rgba(244, 234, 208, 0.92);
  color: #111;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.market-zone {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  width: calc(100% - 592px);
  margin-left: 592px;
  padding-top: 60px;
}

.supply-zone {
  position: absolute;
  top: 76px;
  bottom: 248px;
  left: 14px;
  z-index: 4;
  width: 568px;
  overflow: visible;
}

.supply-rail {
  display: grid;
  grid-template-columns: repeat(3, 184px);
  gap: 8px;
  align-content: start;
}

.kingdom-board {
  display: grid;
  grid-template-columns: repeat(5, 184px);
  gap: 14px 8px;
  padding-top: 4px;
}

.card {
  position: relative;
  display: grid;
  grid-template-rows: 48px auto 32px;
  gap: 0;
  width: 100%;
  min-width: 0;
  height: auto;
  padding: 7px;
  overflow: hidden;
  border: 3px solid #111;
  border-radius: 7px;
  --card-accent: #9a7343;
  --card-title-bg: #f4ebcf;
  --card-text-bg: rgba(237, 232, 219, 0.94);
  --card-text-border: rgba(34, 27, 17, 0.3);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 22%, rgba(0, 0, 0, 0.12)),
    #f7efcd;
  color: var(--ink);
  box-shadow: 0 5px 8px rgba(0, 0, 0, 0.45);
  text-align: left;
  cursor: pointer;
}

.supply-rail .card {
  height: auto;
  grid-template-rows: 48px auto 32px;
  gap: 0;
  padding: 8px;
}

.card.playable {
  border-color: #f3e870;
  box-shadow: 0 0 0 3px rgba(72, 230, 96, 0.64), 0 8px 14px rgba(0, 0, 0, 0.52);
}

.card.playable:hover {
  border-color: #fbff72;
  box-shadow: 0 0 0 4px rgba(83, 255, 95, 0.74), 0 9px 16px rgba(0, 0, 0, 0.56);
  transform: translateY(-3px);
}

.card.buyable-card:hover {
  border-color: #ffe36d;
  box-shadow: 0 0 0 4px rgba(255, 210, 77, 0.74), 0 9px 16px rgba(0, 0, 0, 0.56);
  transform: translateY(-3px);
}

.card.buyable-card:hover::after {
  content: attr(data-buy-label);
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  padding: 3px 7px;
  border-radius: 5px;
  background: rgba(20, 98, 38, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.card.empty,
.card:disabled {
  filter: grayscale(0.75);
  opacity: 0.58;
}

.card.treasure {
  --card-accent: #b78522;
  --card-title-bg: #f7e7a9;
  --card-text-bg: rgba(255, 244, 197, 0.94);
  background: #fff0b0;
}

.card.victory {
  --card-accent: #6f934c;
  --card-title-bg: #dceabe;
  --card-text-bg: rgba(230, 239, 209, 0.94);
  background: #d7e4bd;
}

.card.curse {
  --card-accent: #775193;
  --card-title-bg: #d9bee9;
  --card-text-bg: rgba(229, 215, 239, 0.94);
  background: #d3bde9;
}

.card.attack {
  --card-accent: #9d3930;
  --card-title-bg: #f0c8bd;
  --card-text-bg: rgba(242, 220, 216, 0.95);
  background: #efc0b8;
}

.card.reaction {
  --card-accent: #4a8aa2;
  --card-title-bg: #cce7ef;
  --card-text-bg: rgba(221, 238, 244, 0.95);
  background: #c9e3ef;
}

.cost,
.pile-count {
  position: absolute;
  z-index: 4;
  width: 40px;
  height: 40px;
  font-size: 26px;
  text-shadow: 0 1px rgba(255, 255, 255, 0.45);
}

.cost {
  left: 5px;
  bottom: 5px;
  border: 2px solid #7c5916;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffe889, var(--gold) 58%, #96661a);
  color: #111;
}

.pile-count {
  top: 2px;
  left: 2px;
  color: #fff;
  text-shadow: 0 2px 2px #000;
  background: var(--red);
}

.portrait {
  position: relative;
  z-index: 1;
  grid-row: 2;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(20, 16, 10, 0.72);
  border-radius: 3px;
  background: rgba(9, 11, 11, 0.92);
  box-shadow:
    inset 0 0 0 1px rgba(255, 245, 216, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

.portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08) 0%, transparent 26%, transparent 72%, rgba(0, 0, 0, 0.28) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.16), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.16));
  pointer-events: none;
}

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

.card-title {
  position: relative;
  z-index: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 0;
  padding: 2px 6px;
  border: 1px solid rgba(33, 26, 15, 0.38);
  border-bottom: 2px solid var(--card-accent);
  border-radius: 5px 5px 2px 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.06)),
    var(--card-title-bg);
  color: #111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  text-overflow: clip;
  text-transform: capitalize;
  white-space: normal;
}

.card[data-market-id] .card-title {
  padding-right: 8px;
  padding-left: 40px;
  font-size: 19px;
}

.supply-rail .card-title {
  padding: 2px 8px 2px 40px;
  font-size: 19px;
  line-height: 0.9;
}

.card-types {
  position: relative;
  z-index: 2;
  grid-row: 3;
  align-self: stretch;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 2px 10px 2px 50px;
  border: 1px solid rgba(24, 19, 12, 0.42);
  border-radius: 2px 2px 5px 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.04)),
    var(--card-accent);
  color: #16110a;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
  text-align: center;
  text-shadow: 0 1px rgba(255, 255, 255, 0.28);
  text-transform: uppercase;
  white-space: nowrap;
}

.card.attack .card-types {
  padding-right: 6px;
  font-size: 13px;
  line-height: 0.9;
  white-space: normal;
}

.card.reaction .card-types {
  padding-right: 6px;
  font-size: 13px;
  line-height: 0.9;
  white-space: normal;
}

.card-text {
  display: none;
}

.card-flight {
  position: fixed;
  z-index: 80;
  margin: 0;
  pointer-events: none;
  transform-origin: center center;
  will-change: transform, opacity, filter;
}

.supply-rail .card-text {
  display: none;
}

.supply-rail .card-types {
  padding: 2px 10px 2px 50px;
  font-size: 17px;
}

.action-bar {
  position: absolute;
  left: 592px;
  right: 8%;
  bottom: 316px;
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 78px;
  padding: 12px 16px 10px;
  background: linear-gradient(120deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.7) 72%, rgba(0, 0, 0, 0.88));
  border-left: 5px solid #1b2b75;
  box-shadow: var(--shadow);
}

.turn-readout {
  display: grid;
  align-content: center;
  min-width: 0;
  gap: 5px;
}

.turn-readout p {
  margin: 0;
  color: #b9c9ff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
}

.counter-grid {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
}

.counter-grid div {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-right: 12px;
  padding-right: 12px;
  color: #eee6cf;
}

.counter-grid div:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 0;
  bottom: 3px;
  width: 2px;
  background: rgba(238, 230, 207, 0.6);
}

.counter-grid strong {
  color: #ddffb6;
  font-size: 32px;
  line-height: 1;
  text-shadow: 0 2px 2px #000;
}

.counter-grid span {
  font-size: 22px;
  font-weight: 900;
}

.control-buttons {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  min-width: 214px;
}

.control-buttons button,
.utility-controls button,
.score-panel button,
.game-over-actions button,
.new-game-actions button,
.gallery-header button,
.name-actions button {
  min-height: 36px;
  border: 2px solid #6d4b1a;
  border-radius: 6px;
  background: linear-gradient(#f9e4a4, #bd7727);
  color: #111;
  cursor: pointer;
  font-weight: 900;
  text-shadow: 0 1px rgba(255, 255, 255, 0.55);
}

.control-buttons .primary-control {
  min-width: 198px;
  min-height: 58px;
  padding: 0 24px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 5px 12px rgba(0, 0, 0, 0.36);
  font-size: 28px;
}

.control-buttons button:disabled,
.utility-controls button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.65);
  opacity: 0.6;
}

.played-money-zone {
  position: absolute;
  left: 250px;
  bottom: 238px;
  z-index: 6;
  display: flex;
  align-items: end;
  width: 320px;
  min-height: 150px;
  pointer-events: none;
}

.played-money-zone.empty-money {
  display: none;
}

.played-money-empty {
  color: #eadfbf;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.played-money-cards {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  pointer-events: auto;
}

.spent-card.card {
  flex: 0 0 112px;
  width: 112px;
  height: auto;
  grid-template-rows: 24px auto 16px;
  gap: 0;
  padding: 4px;
  cursor: pointer;
}

.spent-card.card.stacked-card {
  box-shadow:
    5px 5px 0 rgba(255, 240, 176, 0.72),
    10px 10px 0 rgba(255, 240, 176, 0.42),
    0 5px 8px rgba(0, 0, 0, 0.45);
}

.spent-card.card:hover {
  border-color: #fbff72;
  box-shadow: 0 0 0 3px rgba(83, 255, 95, 0.62), 0 6px 12px rgba(0, 0, 0, 0.48);
}

.spent-card.card .card-title {
  padding: 1px 4px;
  font-size: 11px;
  line-height: 0.9;
}

.spent-card.card .card-types {
  padding: 1px 4px 1px 30px;
  font-size: 7px;
  line-height: 1;
  white-space: nowrap;
}

.spent-card.card.attack .card-types,
.spent-card.card.reaction .card-types {
  padding-left: 28px;
  font-size: 6px;
  line-height: 0.9;
  white-space: normal;
}

.spent-card.card .card-text {
  display: none;
}

.spent-card.card .cost {
  left: 4px;
  bottom: 4px;
  width: 26px;
  height: 26px;
  font-size: 16px;
}

.spent-card-count {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 4;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 5px;
  border: 2px solid #111;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-style: normal;
  font-weight: 900;
  text-shadow: 0 1px 1px #000;
}

.hand-zone {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  min-height: 252px;
}

.hand-scroll {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  overflow-x: auto;
  padding: 0 18px 8px 596px;
}

.hand-scroll .card {
  flex: 0 0 184px;
  height: auto;
  grid-template-rows: 48px auto 32px;
  gap: 0;
  padding: 7px;
}

.hand-scroll .card-title {
  padding: 2px 8px;
  font-size: 22px;
  line-height: 0.9;
}

.hand-scroll .card-text {
  display: none;
}

.hand-scroll .card-types {
  padding: 2px 10px 2px 50px;
  font-size: 17px;
}

.pile-previews {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding-left: 10px;
}

.zone-pile {
  position: relative;
  display: grid;
  gap: 3px;
  width: 68px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #f4ead0;
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.zone-pile-face {
  display: block;
  overflow: hidden;
  width: 68px;
  height: 90px;
  border: 3px solid #050708;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 34%),
    repeating-linear-gradient(90deg, #264c6d 0 8px, #d5c792 8px 12px, #264c6d 12px 20px);
  box-shadow: 0 8px 13px rgba(0, 0, 0, 0.48);
}

.zone-pile-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.zone-pile b {
  position: absolute;
  top: -3px;
  right: -4px;
  display: grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 5px;
  background: var(--red);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 1px #000;
}

.zone-pile em {
  overflow: hidden;
  color: #f4ead0;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px #000;
  text-transform: uppercase;
  white-space: nowrap;
}

.empty-zone-pile {
  cursor: default;
  opacity: 0.72;
}

.hidden-zone-pile {
  cursor: default;
}

.right-console {
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 100vh;
  padding: 8px 10px;
  background: var(--console);
  border-left: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: -12px 0 26px rgba(0, 0, 0, 0.42);
}

.trash-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 36px;
  border-bottom: 1px solid var(--console-line);
  background: rgba(255, 255, 255, 0.06);
  font-family: Georgia, "Times New Roman", serif;
  text-transform: uppercase;
}

.trash-strip strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 5px;
  background: var(--red);
  color: #fff;
  font-size: 24px;
}

.trash-strip span {
  font-size: 23px;
  font-weight: 900;
}

.right-console.has-score {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.log-panel {
  grid-row: 2;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border-top: 1px solid var(--console-line);
  padding-top: 8px;
}

.log-panel h2,
.score-panel h2,
.game-over-copy h2,
.gallery h2,
.gallery h3,
.name-form h2 {
  margin: 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.log-panel h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.log-panel ol {
  display: grid;
  align-content: start;
  gap: 6px;
  max-height: none;
  margin: 0;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.log-panel li {
  border-left: 3px solid #5aa7ff;
  padding-left: 8px;
  color: #dfdfdf;
  font-size: 13px;
  line-height: 1.22;
}

.log-panel li span {
  display: inline;
  margin-right: 5px;
  color: #7cb5ff;
  font-weight: 900;
  text-transform: none;
}

.card-preview p,
.gallery-card p {
  margin: 0;
  color: #f3ead8;
  font-size: 13px;
  line-height: 1.28;
}

.inspect-types {
  color: #e8d0a0;
  font-size: 12px;
  font-weight: 900;
}

.rules {
  color: #ffe49e;
  font-weight: 900;
}

.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.4);
}

.card-preview {
  display: grid;
  grid-template-columns: 230px minmax(260px, 380px);
  gap: 18px;
  width: min(680px, 94vw);
  padding: 14px;
  border: 2px solid rgba(244, 234, 208, 0.42);
  border-radius: 8px;
  background: rgba(15, 18, 14, 0.95);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.62);
}

.preview-card-face {
  overflow: hidden;
  border: 3px solid #111;
  border-radius: 7px;
  background: #f7efcd;
}

.preview-card-face img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #0d0f0f;
  object-fit: contain;
}

.preview-copy {
  display: grid;
  align-content: start;
  gap: 9px;
}

.preview-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.preview-title h2 {
  margin: 0;
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.03;
  letter-spacing: 0;
}

.preview-title span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid #7c5916;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffe889, var(--gold) 58%, #96661a);
  color: #111;
  font-size: 20px;
  font-weight: 900;
}

.name-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 42px);
  background:
    linear-gradient(90deg, rgba(3, 7, 14, 0.78), rgba(11, 11, 10, 0.4) 48%, rgba(3, 7, 14, 0.86)),
    url("../public/assets/generated/table-background.png") center / cover no-repeat,
    #0d1213;
}

.name-dialog {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(340px, 460px);
  gap: clamp(18px, 3vw, 34px);
  width: min(1180px, 96vw);
  min-height: min(760px, calc(100vh - 72px));
  overflow: hidden;
  border: 2px solid rgba(244, 234, 208, 0.42);
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 226, 142, 0.22), transparent 34%),
    linear-gradient(135deg, rgba(14, 22, 28, 0.97), rgba(9, 12, 13, 0.96) 62%, rgba(31, 20, 23, 0.98));
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.62);
}

.title-collage {
  position: relative;
  min-height: 560px;
  overflow: hidden;
}

.title-collage::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 229, 156, 0.3), transparent 62%);
  filter: blur(8px);
}

.title-collage-card {
  position: absolute;
  display: block;
  overflow: hidden;
  border: 3px solid rgba(8, 9, 9, 0.96);
  border-radius: 8px;
  background: #0d0f0f;
  box-shadow:
    0 20px 28px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 244, 204, 0.16);
}

.title-collage-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-collage-card-1 {
  left: 19%;
  top: 4%;
  z-index: 3;
  width: min(360px, 54%);
  aspect-ratio: 1 / 1;
}

.title-collage-card-2 {
  left: 4%;
  top: 16%;
  z-index: 2;
  width: min(230px, 34%);
  aspect-ratio: 1 / 1;
  transform: rotate(-7deg);
}

.title-collage-card-3 {
  right: 6%;
  top: 19%;
  z-index: 2;
  width: min(230px, 34%);
  aspect-ratio: 1 / 1;
  transform: rotate(6deg);
}

.title-collage-card-4 {
  left: 12%;
  bottom: 8%;
  z-index: 1;
  width: min(250px, 36%);
  aspect-ratio: 1 / 1;
  transform: rotate(5deg);
}

.title-collage-card-5 {
  right: 15%;
  bottom: 5%;
  z-index: 1;
  width: min(220px, 32%);
  aspect-ratio: 1 / 1;
  transform: rotate(-5deg);
}

.title-collage-card-6 {
  right: 1%;
  bottom: 24%;
  z-index: 1;
  width: min(170px, 25%);
  aspect-ratio: 1 / 1;
  transform: rotate(10deg);
}

.name-form {
  display: grid;
  align-self: center;
  gap: 14px;
  min-width: 0;
  margin-right: clamp(14px, 2vw, 28px);
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid rgba(255, 238, 184, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 246, 215, 0.12), rgba(255, 246, 215, 0.02)),
    rgba(13, 17, 15, 0.82);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.38);
}

.name-form h2 {
  font-size: clamp(42px, 5vw, 66px);
  line-height: 0.92;
  text-shadow: 0 3px 3px #000;
}

.title-kicker,
.title-welcome {
  margin: 0;
}

.title-kicker {
  color: #efd89a;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-welcome {
  max-width: 34ch;
  color: #f8ecd0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.24;
}

.name-form label {
  color: #eadfbf;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.name-form input {
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(244, 234, 208, 0.38);
  border-radius: 6px;
  background: #f9f0d6;
  color: #111;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  padding: 8px 10px;
}

.name-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.name-actions.single-action {
  grid-template-columns: 1fr;
}

.new-game-backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 7, 12, 0.66);
}

.new-game-confirm {
  display: grid;
  grid-template-columns: 190px minmax(280px, 420px);
  gap: 18px;
  width: min(680px, 94vw);
  padding: 14px;
  border: 2px solid rgba(244, 234, 208, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 24, 25, 0.98), rgba(10, 12, 13, 0.98)),
    rgba(15, 18, 14, 0.96);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.64);
}

.new-game-art {
  overflow: hidden;
  border: 3px solid #111;
  border-radius: 7px;
  background: #0d0f0f;
}

.new-game-art img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.new-game-copy {
  display: grid;
  align-content: center;
  gap: 12px;
}

.new-game-copy h2,
.new-game-copy p {
  margin: 0;
}

.new-game-copy h2 {
  color: var(--cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 31px;
  line-height: 1;
}

.new-game-copy p:not(.title-kicker) {
  color: #f4ead0;
  font-size: 15px;
  line-height: 1.35;
}

.new-game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.new-game-actions button {
  min-height: 44px;
  padding: 0 12px;
  font-size: 22px;
}

.score-panel {
  grid-row: 2;
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid rgba(255, 230, 168, 0.34);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(52, 75, 100, 0.48), rgba(120, 42, 50, 0.5)),
    rgba(14, 17, 15, 0.76);
}

.score-label {
  margin: 0;
  color: #efd89a;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.score-panel h2 {
  font-size: 18px;
  line-height: 1.05;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #fff8dc;
  font-size: 14px;
}

.score-row span {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-panel p {
  margin: 0;
  color: #ffe6a8;
  font-size: 13px;
}

.score-panel button {
  min-height: 34px;
  margin-top: 2px;
  font-size: 13px;
}

.game-over-backdrop {
  position: fixed;
  inset: 0;
  z-index: 42;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 42px);
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 216, 118, 0.28), transparent 32%),
    linear-gradient(90deg, rgba(4, 8, 12, 0.84), rgba(8, 13, 11, 0.58) 48%, rgba(4, 8, 12, 0.9));
  backdrop-filter: blur(3px);
}

.game-over-modal {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(340px, 500px);
  gap: clamp(18px, 3vw, 30px);
  width: min(940px, 96vw);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 2px solid rgba(244, 234, 208, 0.48);
  border-radius: 8px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 224, 145, 0.2), transparent 35%),
    linear-gradient(140deg, rgba(15, 25, 30, 0.98), rgba(10, 14, 13, 0.97) 58%, rgba(32, 20, 23, 0.98));
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.68);
}

.game-over-art {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  background:
    radial-gradient(circle at 54% 34%, rgba(255, 229, 150, 0.28), transparent 34%),
    linear-gradient(180deg, rgba(40, 69, 86, 0.28), rgba(119, 57, 42, 0.22));
}

.game-over-art::before {
  content: "";
  position: absolute;
  inset: 38px;
  border: 1px solid rgba(255, 229, 160, 0.2);
  border-radius: 50%;
}

.game-over-card {
  position: absolute;
  display: block;
  overflow: hidden;
  border: 3px solid rgba(8, 9, 9, 0.96);
  border-radius: 8px;
  background: #0d0f0f;
  box-shadow:
    0 20px 30px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 244, 204, 0.16);
}

.game-over-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-over-card-main {
  left: 12%;
  top: 10%;
  width: 74%;
  aspect-ratio: 1 / 1;
}

.game-over-card-accent {
  right: 8%;
  bottom: 9%;
  width: 42%;
  aspect-ratio: 1 / 1;
  transform: rotate(7deg);
}

.game-over-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  min-width: 0;
  padding: clamp(20px, 3vw, 34px) clamp(18px, 3vw, 36px) clamp(20px, 3vw, 34px) 0;
}

.result-kicker,
.result-reason {
  margin: 0;
}

.result-kicker {
  color: #efd89a;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.game-over-copy h2 {
  color: #fff4d6;
  font-size: clamp(36px, 4.8vw, 58px);
  line-height: 0.94;
  text-shadow: 0 3px 3px #000;
}

.result-reason {
  max-width: 42ch;
  color: #f7e8c4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.24;
}

.game-over-scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.final-score-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 238, 184, 0.28);
  border-radius: 8px;
  background: rgba(255, 246, 215, 0.08);
}

.final-score-card.winner,
.final-score-card.tied {
  border-color: rgba(255, 226, 142, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 226, 142, 0.16), rgba(255, 226, 142, 0.04)),
    rgba(255, 246, 215, 0.09);
}

.final-score-card span {
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.final-score-card strong {
  color: #ddffb6;
  font-size: 42px;
  line-height: 1;
  text-shadow: 0 2px 2px #000;
}

.final-score-card em {
  color: #e9d4a3;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.game-over-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.game-over-stats div {
  padding: 10px 12px;
  border-left: 4px solid #5aa7ff;
  background: rgba(255, 255, 255, 0.08);
}

.game-over-stats dt,
.game-over-stats dd {
  margin: 0;
}

.game-over-stats dt {
  color: #b9c9ff;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-over-stats dd {
  color: #fff8dc;
  font-size: 18px;
  font-weight: 900;
}

.game-over-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
}

.game-over-actions button {
  min-height: 44px;
  padding: 0 12px;
}

.game-over-actions .primary-result-action {
  border-color: rgba(255, 238, 184, 0.78);
  background: linear-gradient(#fff0b7, #d79a32 58%, #a15d21);
}

.utility-controls {
  grid-row: 3;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--console-line);
}

.utility-controls button {
  min-width: 0;
  padding: 0 8px;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.utility-controls .music-toggle {
  grid-column: 1 / -1;
  border-color: rgba(119, 198, 255, 0.74);
  background: linear-gradient(#dcefff, #4c8cc2 58%, #1d3d6d);
  color: #07101c;
}

.utility-controls .music-toggle.is-on {
  border-color: rgba(255, 238, 184, 0.84);
  background: linear-gradient(#fff4c7, #d9a23d 58%, #8f4f25);
  color: #161007;
  box-shadow: 0 0 0 2px rgba(255, 230, 137, 0.18), 0 0 22px rgba(100, 180, 255, 0.28);
}

.language-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.language-switch button {
  min-height: 42px;
  border: 2px solid rgba(244, 234, 208, 0.42);
  border-radius: 6px;
  background: rgba(8, 14, 18, 0.72);
  color: #f8ecd0;
  cursor: pointer;
  font-weight: 900;
}

.language-switch button.active-language {
  border-color: rgba(255, 238, 184, 0.9);
  background: linear-gradient(#fff0b7, #d79a32 58%, #a15d21);
  color: #15100a;
}

.app-shell[lang="ru"] .name-form {
  gap: 12px;
}

.app-shell[lang="ru"] .name-form h2 {
  font-size: clamp(38px, 4.2vw, 54px);
  line-height: 0.96;
}

.app-shell[lang="ru"] .title-kicker {
  font-size: clamp(12px, 0.95vw, 13px);
  letter-spacing: 0.1em;
}

.app-shell[lang="ru"] .title-welcome {
  max-width: 38ch;
  font-size: clamp(17px, 1.35vw, 20px);
  line-height: 1.18;
}

.app-shell[lang="ru"] .language-switch button,
.app-shell[lang="ru"] .name-actions.single-action button {
  font-size: clamp(18px, 1.4vw, 20px);
}

.app-shell[lang="ru"] .card-title,
.app-shell[lang="ru"] .hand-scroll .card-title {
  font-size: 18px;
  line-height: 0.92;
}

.app-shell[lang="ru"] .card[data-market-id] .card-title,
.app-shell[lang="ru"] .supply-rail .card-title {
  font-size: 16px;
}

.app-shell[lang="ru"] .card-types,
.app-shell[lang="ru"] .supply-rail .card-types,
.app-shell[lang="ru"] .hand-scroll .card-types {
  font-size: 13px;
}

.app-shell[lang="ru"] .control-buttons .primary-control {
  font-size: 21px;
}

.right-console.has-score .log-panel {
  grid-row: 3;
}

.right-console.has-score .utility-controls {
  grid-row: 4;
}

.gallery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.78);
}

.gallery {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: min(1120px, 100%);
  height: min(860px, 92vh);
  overflow: hidden;
  border: 1px solid rgba(245, 236, 208, 0.24);
  border-radius: 8px;
  background: rgba(17, 20, 16, 0.96);
  padding: 14px;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: scroll;
  padding-right: 8px;
  overscroll-behavior: contain;
  scrollbar-color: rgba(223, 200, 137, 0.74) rgba(255, 255, 255, 0.1);
  scrollbar-gutter: stable;
}

.gallery-card {
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(245, 236, 208, 0.2);
  border-radius: 8px;
  background: rgba(245, 236, 208, 0.08);
  padding: 10px;
}

.gallery-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: #0d0f0f;
  object-fit: contain;
  border-radius: 6px;
}

.gallery-card h3 {
  overflow: hidden;
  display: -webkit-box;
  line-height: 1.02;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.gallery-description,
.gallery-rules {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

.gallery-description {
  -webkit-line-clamp: 2;
}

.gallery-rules {
  -webkit-line-clamp: 3;
}

@media (max-width: 1120px) {
  .game-stage {
    grid-template-columns: 1fr;
  }

  .right-console {
    min-height: auto;
    grid-template-rows: auto;
  }

  .playmat {
    min-height: 930px;
  }

  .name-dialog {
    grid-template-columns: 1fr;
    align-content: start;
    min-height: 0;
    max-height: calc(100vh - 36px);
    overflow: auto;
  }

  .title-collage {
    min-height: 420px;
  }

  .name-form {
    align-self: stretch;
    margin: 0 clamp(14px, 4vw, 28px) clamp(14px, 4vw, 28px);
  }
}

@media (min-width: 1121px) and (max-width: 1800px) {
  .game-stage {
    grid-template-columns: minmax(0, 1fr) 256px;
  }

  .playmat {
    padding: 8px 8px 248px;
  }

  .game-title {
    top: 6px;
    right: 8px;
    gap: 8px;
    padding: 6px 8px;
  }

  .game-title h1 {
    font-size: 17px;
  }

  .game-title span {
    min-width: 66px;
    min-height: 26px;
  }

  .opponent-zone {
    top: 6px;
  }

  .human-banner {
    bottom: 8px;
    gap: 5px;
  }

  .nameplate {
    min-width: 170px;
    height: 46px;
  }

  .nameplate strong {
    font-size: 18px;
  }

  .deck-stack {
    width: 112px;
    height: 48px;
  }

  .deck-stack span {
    width: 68px;
    height: 44px;
  }

  .deck-stack span:nth-child(2) {
    left: 21px;
  }

  .deck-stack span:nth-child(3) {
    left: 42px;
  }

  .played-strip {
    max-width: 28vw;
  }

  .market-zone {
    width: calc(100% - 516px);
    margin-left: 516px;
    padding-top: 68px;
  }

  .supply-zone {
    top: 70px;
    bottom: 192px;
    left: 8px;
    width: 512px;
  }

  .supply-rail {
    grid-template-columns: repeat(3, 168px);
    gap: 4px;
  }

  .kingdom-board {
    grid-template-columns: repeat(5, 168px);
    gap: 12px 4px;
  }

  .card,
  .supply-rail .card,
  .hand-scroll .card {
    grid-template-rows: 40px auto 26px;
    padding: 6px;
    border-width: 3px;
  }

  .card-title,
  .hand-scroll .card-title {
    padding: 2px 6px;
    font-size: 18px;
    line-height: 0.9;
  }

  .card[data-market-id] .card-title,
  .supply-rail .card-title {
    padding: 2px 6px 2px 36px;
    font-size: 16px;
    line-height: 0.9;
  }

  .card-types,
  .supply-rail .card-types,
  .hand-scroll .card-types {
    padding: 2px 8px 2px 44px;
    font-size: 13px;
  }

  .card.attack .card-types,
  .card.reaction .card-types {
    padding-left: 40px;
    padding-right: 4px;
    font-size: 10px;
    line-height: 0.9;
    white-space: normal;
  }

  .cost,
  .pile-count {
    width: 36px;
    height: 36px;
    font-size: 23px;
  }

  .cost {
    left: 4px;
    bottom: 4px;
  }

  .pile-count {
    top: 1px;
    left: 1px;
  }

  .action-bar {
    left: 516px;
    right: 10px;
    bottom: 238px;
    min-height: 64px;
    gap: 12px;
    padding: 8px 12px;
  }

  .turn-readout p {
    font-size: 16px;
  }

  .counter-grid strong {
    font-size: 27px;
  }

  .counter-grid span {
    font-size: 19px;
  }

  .control-buttons {
    min-width: 172px;
  }

  .control-buttons .primary-control {
    min-width: 164px;
    min-height: 48px;
    padding: 0 18px;
    font-size: 23px;
  }

  .played-money-zone {
    left: 180px;
    bottom: 150px;
    width: 320px;
    min-height: 148px;
  }

  .played-money-cards {
    gap: 8px;
  }

  .spent-card.card {
    flex-basis: 112px;
    width: 112px;
    grid-template-rows: 24px auto 16px;
    padding: 4px;
  }

  .spent-card.card .card-title {
    padding: 1px 4px;
    font-size: 11px;
    line-height: 0.9;
  }

  .spent-card.card .card-types {
    padding: 1px 4px 1px 30px;
    font-size: 7px;
  }

  .spent-card.card.attack .card-types,
  .spent-card.card.reaction .card-types {
    padding-left: 28px;
    font-size: 6px;
  }

  .spent-card.card .cost {
    width: 26px;
    height: 26px;
    font-size: 16px;
  }

  .hand-zone {
    min-height: 198px;
  }

  .hand-scroll {
    gap: 4px;
    padding: 0 0 4px 520px;
  }

  .hand-scroll .card {
    flex-basis: 168px;
  }

  .pile-previews {
    gap: 8px;
    padding-left: 8px;
  }

  .zone-pile {
    width: 62px;
  }

  .zone-pile-face {
    width: 62px;
    height: 82px;
  }

  .right-console {
    gap: 10px;
    padding: 8px;
  }

  .trash-strip {
    min-height: 34px;
  }

  .trash-strip strong {
    width: 28px;
    height: 28px;
    font-size: 21px;
  }

  .trash-strip span {
    font-size: 20px;
  }

  .log-panel h2 {
    margin-bottom: 6px;
    font-size: 17px;
  }

  .log-panel li {
    font-size: 12px;
  }
}

@media (min-width: 1121px) and (max-width: 1600px) {
  .market-zone {
    width: calc(100% - 448px);
    margin-left: 448px;
  }

  .supply-zone {
    width: 440px;
  }

  .supply-rail {
    grid-template-columns: repeat(3, 144px);
  }

  .kingdom-board {
    grid-template-columns: repeat(5, 144px);
  }

  .action-bar {
    left: 448px;
  }

  .played-money-zone {
    left: 180px;
    width: 250px;
  }

  .hand-scroll {
    padding-left: 438px;
  }

  .hand-scroll .card {
    flex-basis: 144px;
  }

  .card,
  .supply-rail .card,
  .hand-scroll .card {
    grid-template-rows: 34px auto 22px;
    padding: 5px;
  }

  .card-title,
  .hand-scroll .card-title,
  .card[data-market-id] .card-title,
  .supply-rail .card-title {
    font-size: 15px;
    line-height: 0.9;
  }

  .card[data-market-id] .card-title,
  .supply-rail .card-title {
    padding-left: 32px;
    font-size: 14px;
  }

  .card-types,
  .supply-rail .card-types,
  .hand-scroll .card-types {
    padding-left: 38px;
    font-size: 11px;
  }

  .card.attack .card-types,
  .card.reaction .card-types {
    padding-left: 34px;
    font-size: 8px;
  }

  .cost,
  .pile-count {
    width: 32px;
    height: 32px;
    font-size: 20px;
  }
}

@media (min-width: 1121px) and (max-width: 1350px) {
  .game-stage {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .market-zone {
    width: calc(100% - 354px);
    margin-left: 354px;
  }

  .supply-zone {
    width: 330px;
  }

  .supply-rail {
    grid-template-columns: repeat(3, 104px);
    gap: 7px;
  }

  .kingdom-board {
    grid-template-columns: repeat(5, 104px);
    gap: 10px 7px;
  }

  .card,
  .supply-rail .card,
  .hand-scroll .card {
    grid-template-rows: 20px auto 13px;
    padding: 4px;
  }

  .card-title,
  .hand-scroll .card-title,
  .card[data-market-id] .card-title,
  .supply-rail .card-title {
    font-size: 10px;
  }

  .card-types,
  .supply-rail .card-types,
  .hand-scroll .card-types {
    padding-left: 28px;
    font-size: 7px;
  }

  .card.attack .card-types,
  .card.reaction .card-types {
    font-size: 6px;
  }

  .cost,
  .pile-count {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .action-bar {
    left: 354px;
    right: 12px;
  }

  .played-money-zone {
    left: 156px;
    width: 180px;
  }

  .spent-card.card {
    flex-basis: 94px;
    width: 94px;
    grid-template-rows: 21px auto 14px;
  }

  .spent-card.card .card-title {
    font-size: 9px;
  }

  .spent-card.card .card-types {
    padding-left: 26px;
    font-size: 6px;
  }

  .spent-card.card .cost {
    width: 23px;
    height: 23px;
    font-size: 14px;
  }

  .hand-scroll {
    padding-left: 356px;
  }

  .hand-scroll .card {
    flex-basis: 104px;
  }
}

@media (max-width: 760px) {
  .playmat {
    min-height: auto;
    padding: 82px 8px 12px;
    overflow: visible;
  }

  .game-title {
    left: 8px;
    right: 8px;
  }

  .opponent-zone,
  .human-banner,
  .hand-zone,
  .action-bar {
    position: static;
  }

  .opponent-zone {
    justify-content: flex-start;
    margin-bottom: 12px;
  }

  .market-zone {
    gap: 12px;
    width: 100%;
    margin-left: 0;
    padding-top: 0;
  }

  .supply-zone {
    position: static;
    width: 100%;
    margin-bottom: 12px;
    overflow: visible;
  }

  .supply-rail,
  .kingdom-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-bar {
    grid-template-columns: 1fr;
    margin: 12px 0;
  }

  .control-buttons {
    min-width: 0;
  }

  .control-buttons .primary-control {
    width: 100%;
  }

  .played-money-zone {
    position: static;
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 12px 0;
  }

  .hand-zone {
    min-height: 0;
  }

  .human-banner {
    margin-bottom: 10px;
  }

  .hand-scroll {
    justify-content: flex-start;
    padding: 0 0 12px;
  }

  .played-strip {
    display: none;
  }

  .right-console {
    padding: 10px;
  }

  .card-preview {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow: auto;
  }

  .new-game-confirm {
    grid-template-columns: 1fr;
    max-width: 420px;
  }

  .preview-card-face {
    max-width: 220px;
    justify-self: center;
  }

  .new-game-art {
    max-width: 220px;
    justify-self: center;
  }

  .game-over-backdrop {
    align-items: start;
    padding: 10px;
  }

  .game-over-modal {
    grid-template-columns: 1fr;
    width: 100%;
    max-height: calc(100vh - 20px);
    gap: 0;
  }

  .game-over-art {
    min-height: 250px;
  }

  .game-over-card-main {
    left: 18%;
    top: 7%;
    width: 52%;
  }

  .game-over-card-accent {
    right: 13%;
    bottom: 8%;
    width: 34%;
  }

  .game-over-copy {
    padding: 18px;
  }

  .game-over-copy h2 {
    font-size: 34px;
  }

  .game-over-scoreboard,
  .game-over-stats,
  .game-over-actions {
    grid-template-columns: 1fr;
  }

  .name-dialog-backdrop {
    padding: 10px;
  }

  .name-dialog {
    width: 100%;
    max-height: calc(100vh - 20px);
  }

  .title-collage {
    min-height: 300px;
  }

  .title-collage-card-1 {
    left: 21%;
    width: 58%;
  }

  .title-collage-card-2,
  .title-collage-card-3 {
    width: 36%;
  }

  .title-collage-card-4,
  .title-collage-card-5 {
    width: 34%;
  }

  .name-form {
    gap: 12px;
    padding: 18px;
  }

  .app-shell[lang="ru"] .name-form h2 {
    font-size: clamp(34px, 10vw, 46px);
  }

  .app-shell[lang="ru"] .title-kicker {
    font-size: 11px;
    letter-spacing: 0.08em;
  }

  .title-welcome {
    font-size: 18px;
  }

  .app-shell[lang="ru"] .title-welcome {
    font-size: 17px;
    line-height: 1.16;
  }
}

@media (max-width: 640px) {
  .supply-rail,
  .kingdom-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card,
  .supply-rail .card {
    height: auto;
    grid-template-rows: 22px auto 13px;
    gap: 0;
    padding: 5px;
  }

  .card-title,
  .supply-rail .card-title {
    padding: 2px 5px 1px;
    font-size: 11px;
  }

  .card[data-market-id] .card-title,
  .supply-rail .card-title {
    padding-left: 30px;
  }

  .card-text,
  .supply-rail .card-text {
    display: none;
  }

  .card-types,
  .supply-rail .card-types {
    padding: 1px 8px 1px 32px;
    font-size: 6px;
  }

  .counter-grid strong {
    font-size: 24px;
  }

  .counter-grid span,
  .turn-readout p {
    font-size: 16px;
  }

  .control-buttons .primary-control {
    font-size: 21px;
  }
}

@media (max-width: 520px) {
  .supply-rail,
  .kingdom-board {
    grid-template-columns: 1fr;
  }
}

.app-shell[lang="ru"] .card-title,
.app-shell[lang="ru"] .hand-scroll .card-title {
  font-size: clamp(11px, 1.15em, 18px);
}

.app-shell[lang="ru"] .card[data-market-id] .card-title,
.app-shell[lang="ru"] .supply-rail .card-title,
.app-shell[lang="ru"] .spent-card.card .card-title {
  font-size: clamp(9px, 0.95em, 16px);
}

.app-shell[lang="ru"] .control-buttons .primary-control {
  font-size: clamp(16px, 1.6vw, 21px);
  white-space: normal;
}
