.heros-page {
  --heros-ink: #2a1813;
  --heros-parchment: #f1d79a;
  --heros-parchment-dark: #b98342;
  --heros-gold: #f6ca58;
  --heros-red: #a83442;
  --heros-forest: #4b8b63;
  --heros-sky: #6ab8c9;
  --heros-night: #120b16;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 26px),
    linear-gradient(180deg, #11150f 0%, #090b08 52%, #050604 100%);
}

.heros-main {
  width: min(1880px, calc(100% - 18px));
  min-width: 0;
}

.heros-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(210px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(246, 202, 88, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background:
    linear-gradient(135deg, rgba(241, 215, 154, 0.14), rgba(53, 33, 24, 0.22) 38%, rgba(18, 11, 22, 0.86)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 22px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  min-width: 0;
  max-width: 100%;
}

.heros-hero::after {
  content: none;
}

.heros-hero h1 {
  margin: 5px 0 0;
  color: #fff4c8;
  font-size: clamp(24px, 2.5vw, 42px);
  line-height: 0.96;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 0 5px 26px rgba(0, 0, 0, 0.5);
  overflow-wrap: normal;
}

.heros-hero p {
  display: none;
  max-width: 58ch;
  margin: 6px 0 0;
  color: rgba(255, 242, 203, 0.84);
  font-size: 14px;
  line-height: 1.55;
}

.heros-controls {
  position: relative;
  z-index: 1;
  justify-content: flex-end;
  max-width: 1320px;
  min-width: 0;
  gap: 8px;
}

.heros-controls .btn {
  min-width: 0;
  white-space: normal;
  padding: 9px 12px;
  font-size: 11px;
}

.heros-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 250px;
  gap: 10px;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}

.heros-panel,
.heros-stage-wrap {
  border: 1px solid rgba(246, 202, 88, 0.25);
  background:
    linear-gradient(180deg, rgba(68, 41, 27, 0.86), rgba(30, 19, 20, 0.92)),
    repeating-linear-gradient(0deg, rgba(241, 215, 154, 0.06) 0 1px, transparent 1px 8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 52px rgba(0, 0, 0, 0.34);
  min-width: 0;
}

.heros-panel {
  border-radius: 8px;
  padding: 10px;
}

.panel-heading {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
}

.panel-kicker,
.overlay-kicker {
  color: rgba(246, 202, 88, 0.76);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.panel-heading h2 {
  margin: 0;
  color: #fff4c8;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.shop-hand,
.town-upgrades {
  display: grid;
  gap: 7px;
}

.shop-card,
.upgrade-row,
.selected-readout,
.tile-info {
  border: 1px solid rgba(246, 202, 88, 0.24);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(241, 215, 154, 0.92), rgba(207, 158, 86, 0.9)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 10px);
  color: var(--heros-ink);
}

.shop-card {
  --card-type-color: #b98342;
  position: relative;
  width: 100%;
  min-height: 82px;
  padding: 9px 9px 9px 44px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.shop-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 9px;
  border-radius: 11px 0 0 11px;
  background: var(--card-type-color);
}

.shop-card-glyph {
  position: absolute;
  left: 13px;
  top: 13px;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(42, 24, 19, 0.24);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 245, 196, 0.7), rgba(255, 245, 196, 0.18)),
    var(--card-type-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.shop-card-glyph::after {
  content: attr(data-mark);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #22130f;
  font-size: 13px;
  font-weight: 700;
}

.shop-card:hover,
.shop-card:focus-visible,
.shop-card.selected {
  transform: translateY(-2px);
  border-color: rgba(255, 245, 187, 0.86);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.24), inset 0 0 0 3px rgba(255, 240, 168, 0.62);
}

.shop-card.selected {
  scale: 1.025;
}

.shop-card-path {
  --card-type-color: #b97843;
}

.shop-card-bridge {
  --card-type-color: #8f623e;
}

.shop-card-tower {
  --card-type-color: #477fa5;
}

.shop-card-town {
  --card-type-color: #d8a44f;
}

.shop-card-resource {
  --card-type-color: #45c8d7;
}

.shop-card-upgrade {
  --card-type-color: #7d4cc2;
}

.shop-card[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.shop-card-top,
.upgrade-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.shop-card-name,
.upgrade-row strong,
.tile-info strong {
  display: block;
  color: #27130e;
  font-size: 12px;
  line-height: 1.12;
  text-transform: uppercase;
}

.shop-card-cost,
.upgrade-row-cost {
  flex: 0 0 auto;
  border: 1px solid rgba(42, 24, 19, 0.24);
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(255, 244, 200, 0.55);
  color: #4a2714;
  font-size: 11px;
  font-weight: 700;
}

.shop-card-tag {
  display: inline-block;
  margin-top: 5px;
  color: #6d281f;
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.shop-card p,
.upgrade-row p,
.tile-info p,
.heros-note,
.selected-readout {
  margin: 5px 0 0;
  color: rgba(42, 24, 19, 0.78);
  font-size: 11px;
  line-height: 1.32;
}

.heros-note {
  color: rgba(255, 242, 203, 0.7);
}

.selected-readout {
  margin-top: 10px;
  padding: 10px;
}

.placement-chip {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  align-items: center;
  border: 1px solid rgba(246, 202, 88, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(241, 215, 154, 0.94), rgba(175, 115, 58, 0.92)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 10px);
  color: var(--heros-ink);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.placement-chip span {
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  min-height: 38px;
  border: 1px solid rgba(42, 24, 19, 0.2);
  border-radius: 10px;
  background: rgba(255, 245, 196, 0.42);
  color: #6d281f;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.placement-chip strong {
  color: #22130f;
  font-size: 15px;
  line-height: 1.1;
  text-transform: uppercase;
}

.placement-chip em {
  color: rgba(42, 24, 19, 0.76);
  font-size: 12px;
  font-style: normal;
}

.placement-chip.is-valid span {
  background: rgba(78, 213, 126, 0.28);
  color: #174424;
}

.placement-chip.is-invalid span {
  background: rgba(183, 52, 66, 0.22);
  color: #6d1f2a;
}

.path-palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.path-palette button {
  position: relative;
  overflow: hidden;
  min-height: 38px;
  border: 1px solid rgba(246, 202, 88, 0.28);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(73, 39, 23, 0.92), rgba(31, 18, 18, 0.9));
  color: #fff0a8;
  font: 700 11px/1 'Manrope', sans-serif;
  cursor: pointer;
}

.path-palette button::before {
  content: "";
  position: absolute;
  inset: 10px 14px;
  border-top: 4px solid rgba(216, 163, 94, 0.92);
  border-radius: 999px;
  transform-origin: center;
}

.path-palette button[data-road-rotation="1"]::before,
.path-palette button[data-road-rotation="3"]::before,
.path-palette button[data-road-rotation="4"]::before,
.path-palette button[data-road-rotation="5"]::before {
  inset: 9px 15px 15px 11px;
  border-top: 0;
  border-right: 4px solid rgba(216, 163, 94, 0.92);
  border-bottom: 4px solid rgba(216, 163, 94, 0.92);
  border-radius: 0 0 12px 0;
}

.path-palette button[data-road-rotation="2"]::before {
  transform: rotate(90deg);
}

.path-palette button[data-road-rotation="3"]::before {
  transform: scaleX(-1);
}

.path-palette button[data-road-rotation="4"]::before {
  transform: rotate(180deg);
}

.path-palette button[data-road-rotation="5"]::before {
  transform: scale(-1, -1);
}

.path-palette button span {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 16px 0 0;
  font-size: 10px;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.8);
}

.path-palette button.is-active {
  border-color: rgba(102, 255, 161, 0.85);
  box-shadow: inset 0 0 0 2px rgba(102, 255, 161, 0.28), 0 8px 18px rgba(0, 0, 0, 0.24);
  color: #ecffe8;
}

.path-palette button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.heros-stage-wrap {
  padding: 8px;
  border-radius: 8px;
}

.heros-stage {
  border-color: rgba(246, 202, 88, 0.28);
  background:
    linear-gradient(180deg, #213019 0%, #151a12 56%, #080a07 100%);
  min-width: 0;
}

.heros-stage canvas {
  height: min(82vh, 900px);
  min-height: 680px;
  background: transparent;
  cursor: crosshair;
  touch-action: none;
}

.heros-overlay-card {
  max-width: 520px;
  border-color: rgba(246, 202, 88, 0.45);
  background:
    linear-gradient(180deg, rgba(241, 215, 154, 0.96), rgba(178, 121, 61, 0.96));
  color: var(--heros-ink);
}

.heros-overlay-card h2 {
  color: #24120e;
}

.heros-overlay-card p {
  color: rgba(42, 24, 19, 0.82);
}

.heros-status {
  min-height: 28px;
  color: rgba(255, 242, 203, 0.78);
}

.heros-touch-controls {
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
}

.heros-touch-controls button {
  border-color: rgba(246, 202, 88, 0.28);
  background: rgba(43, 24, 18, 0.82);
  padding: 8px 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

.heros-controls .btn.is-active,
.heros-touch-controls button.is-active {
  border-color: rgba(102, 255, 161, 0.82);
  background: rgba(52, 132, 86, 0.82);
  color: #ecffe8;
}

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

.heros-hud li {
  border-color: rgba(246, 202, 88, 0.2);
  background: rgba(20, 13, 18, 0.7);
}

.heros-hud strong {
  color: var(--heros-gold);
  font-size: 15px;
}

.town-heading {
  margin-top: 10px;
}

.upgrade-row {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.upgrade-row button {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 11px;
}

.upgrade-row button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.tile-info {
  margin-top: 10px;
  padding: 9px;
}

.tile-info span {
  display: block;
  color: #6d281f;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-stage-wrap:fullscreen .heros-stage canvas,
.game-stage-wrap:-webkit-full-screen .heros-stage canvas {
  min-height: 0;
}

html:fullscreen body.heros-page,
html:-webkit-full-screen body.heros-page {
  overflow: auto;
}

html:fullscreen .site-header,
html:fullscreen .site-footer,
html:-webkit-full-screen .site-header,
html:-webkit-full-screen .site-footer {
  display: none;
}

html:fullscreen .heros-main,
html:-webkit-full-screen .heros-main {
  width: min(1900px, calc(100% - 14px));
  padding-top: 8px;
  padding-bottom: 10px;
}

html:fullscreen .heros-hero,
html:-webkit-full-screen .heros-hero {
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-radius: 10px;
  padding: 8px 10px;
}

html:fullscreen .heros-hero h1,
html:-webkit-full-screen .heros-hero h1 {
  margin: 2px 0;
  font-size: clamp(22px, 2.4vw, 38px);
  line-height: 1;
}

html:fullscreen .heros-hero p,
html:-webkit-full-screen .heros-hero p {
  display: none;
}

html:fullscreen .heros-layout,
html:-webkit-full-screen .heros-layout {
  grid-template-columns: 230px minmax(0, 1fr) 260px;
  gap: 10px;
}

html:fullscreen .heros-panel,
html:fullscreen .heros-stage-wrap,
html:-webkit-full-screen .heros-panel,
html:-webkit-full-screen .heros-stage-wrap {
  border-radius: 10px;
  padding: 10px;
}

html:fullscreen .shop-card,
html:-webkit-full-screen .shop-card {
  min-height: 92px;
  padding-top: 10px;
  padding-bottom: 10px;
}

html:fullscreen .path-palette,
html:-webkit-full-screen .path-palette {
  gap: 4px;
}

html:fullscreen .path-palette button,
html:-webkit-full-screen .path-palette button {
  min-height: 32px;
}

html:fullscreen .heros-stage canvas,
html:-webkit-full-screen .heros-stage canvas {
  height: min(68vh, calc(100vh - 240px));
  min-height: 360px;
}

html:fullscreen .heros-touch-controls,
html:-webkit-full-screen .heros-touch-controls {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
}

html:fullscreen .heros-touch-controls button,
html:-webkit-full-screen .heros-touch-controls button {
  min-height: 36px;
  padding: 6px 3px;
  font-size: 9px;
  letter-spacing: 0.02em;
}

html:fullscreen .heros-status,
html:-webkit-full-screen .heros-status {
  min-height: 22px;
  font-size: 12px;
}

@media (max-width: 1240px) {
  .heros-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .heros-command-panel {
    grid-column: 1 / -1;
  }

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

  html:fullscreen .heros-layout,
  html:-webkit-full-screen .heros-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .heros-hero {
    grid-template-columns: 1fr;
  }

  .heros-controls {
    justify-content: flex-start;
  }

  .heros-layout {
    grid-template-columns: 1fr;
  }

  .heros-shop-panel {
    order: 2;
  }

  .heros-stage-wrap {
    order: 1;
  }

  .heros-command-panel {
    order: 3;
  }

  .shop-hand,
  .town-upgrades {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .shop-hand {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 3px;
  }

  .shop-card {
    flex: 0 0 min(300px, 84vw);
    scroll-snap-align: start;
  }

  .heros-stage canvas {
    min-height: 480px;
    height: min(62vh, 600px);
  }

  html:fullscreen .heros-hero,
  html:-webkit-full-screen .heros-hero {
    grid-template-columns: 1fr;
  }

  html:fullscreen .heros-stage canvas,
  html:-webkit-full-screen .heros-stage canvas {
    height: min(60vh, 620px);
  }
}

@media (max-width: 680px) {
  .heros-main {
    width: min(1880px, calc(100% - 12px));
  }

  .heros-hero,
  .heros-panel,
  .heros-stage-wrap {
    border-radius: 12px;
    padding: 10px;
  }

  .heros-hero h1 {
    font-size: clamp(32px, 12vw, 48px);
  }

  .heros-controls .btn {
    flex: 1 1 132px;
  }

  .shop-hand,
  .town-upgrades {
    grid-template-columns: 1fr;
  }

  .shop-hand {
    display: flex;
  }

  .placement-chip {
    grid-template-columns: 1fr;
  }

  .placement-chip span {
    grid-row: auto;
    justify-content: flex-start;
    padding-inline: 10px;
  }

  .heros-stage canvas {
    min-height: 390px;
    height: min(58vh, 470px);
  }

  .heros-touch-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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