.matches-page .layout {
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
}

.matches-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.matches-screen[hidden] {
  display: none !important;
}

.matches-modes-layout,
.matches-map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 16px;
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto 40px;
  align-items: start;
  flex: 1;
  min-height: 0;
}

.matches-modes {
  min-width: 0;
  padding-bottom: 8px;
}

.matches-modes__lead {
  margin: 8px 0 22px;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

.matches-modes__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: 18px;
}

.matches-modes__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.matches-modes__hint[hidden] {
  display: none !important;
}

.matches-leaderboard-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.matches-leaderboard-panel .leaderboard-list {
  max-height: min(520px, 70vh);
}

.matches-mode-groups {
  display: grid;
  gap: 18px;
}

.matches-mode-group {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(20, 26, 36, 0.96), rgba(10, 14, 20, 0.96));
  box-shadow: var(--shadow);
}

.matches-mode-group__title {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.matches-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.matches-mode-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-height: 92px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.matches-mode-card:hover {
  border-color: rgba(184, 255, 46, 0.45);
  transform: translateY(-1px);
  background: rgba(184, 255, 46, 0.06);
}

.matches-mode-card--active {
  border-color: rgba(184, 255, 46, 0.7);
  background: rgba(184, 255, 46, 0.1);
  box-shadow: inset 0 0 0 1px rgba(184, 255, 46, 0.25);
}

.matches-mode-card__head {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.matches-mode-card__count {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  color: var(--green);
}

.matches-mode-card__pts {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}

.matches-mode-card__label {
  font-size: 0.92rem;
  font-weight: 700;
}

.matches-mode-card__meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.matches-mode-card--empty .matches-mode-card__count {
  color: var(--orange);
}

.matches-screen--map {
  height: 100vh;
  height: 100dvh;
}

.matches-screen--map .matches-map-layout {
  margin-bottom: 16px;
  width: min(1200px, calc(100% - 32px));
}

.matches-map-header {
  flex-shrink: 0;
  max-width: none;
  width: 100%;
}

.matches-map-header .matches-map-title {
  margin-left: auto;
  margin-right: auto;
}

.matches-screen--play > .header,
.matches-screen > .header {
  max-width: none;
  width: 100%;
}

.matches-map-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.matches-map-title strong {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  font-weight: 800;
}

.matches-map-title span {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.matches-map-viewport {
  position: relative;
  z-index: 1;
  min-height: 0;
  height: min(72vh, calc(100dvh - 140px));
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(209, 138, 69, 0.12), transparent 42%),
    linear-gradient(180deg, #10161f, #080b10);
  box-shadow: var(--shadow);
  scroll-behavior: smooth;
  scrollbar-color: var(--green) #121820;
}

.matches-level-map {
  position: relative;
  width: 100%;
  min-height: 100%;
}

.matches-map-svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.matches-map-road-shadow {
  fill: none;
  stroke: rgba(0, 0, 0, 0.5);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matches-map-road {
  fill: none;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matches-map-node {
  cursor: pointer;
  outline: none;
}

.matches-map-node:focus-visible .matches-map-node__ring {
  stroke: var(--green);
  stroke-width: 3;
}

.matches-map-node__halo {
  fill: rgba(184, 255, 46, 0.08);
}

.matches-map-node__ring {
  fill: #17202c;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 2;
}

.matches-map-node__label {
  fill: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.matches-map-node--current .matches-map-node__ring {
  stroke: var(--green);
  stroke-width: 2.5;
  fill: rgba(184, 255, 46, 0.14);
}

.matches-map-node--done .matches-map-node__ring {
  stroke: rgba(184, 255, 46, 0.55);
  fill: rgba(184, 255, 46, 0.1);
}

.matches-map-node--locked {
  cursor: default;
  opacity: 0.55;
}

.matches-map-node--locked .matches-map-node__ring {
  fill: #0f141c;
  stroke: rgba(255, 255, 255, 0.1);
}

.matches-map-node--locked .matches-map-node__label {
  fill: var(--text-muted);
}

.matches-map-node--soon .matches-map-node__ring {
  stroke: rgba(255, 159, 26, 0.45);
}

.matches-map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}

.matches-play {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 16px;
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto 28px;
}

.panel--side {
  align-self: start;
}

.matches-mode-chip {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--matches-ui-accent, var(--green)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--matches-ui-accent, var(--green)) 28%, transparent);
  font-size: 0.9rem;
  font-weight: 700;
}

.panel--side .tool-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.panel--side .tool-btn:hover {
  border-color: color-mix(in srgb, var(--matches-ui-accent, var(--green)) 35%, transparent);
}

.panel--side .tool-btn__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.matches-board-wrap {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 16px 28px;
  background: var(
    --matches-board-bg,
    radial-gradient(ellipse at 50% 18%, rgba(209, 138, 69, 0.1), transparent 52%),
      linear-gradient(180deg, rgba(20, 26, 36, 0.96), rgba(10, 14, 20, 0.96))
  );
  border: 1px solid var(--matches-board-border, var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s;
}

body.matches-page[data-matches-bg] .bg-glow--green {
  background: radial-gradient(circle, var(--matches-page-glow-a, rgba(112, 255, 26, 0.15)), transparent 68%);
}

body.matches-page[data-matches-bg] .bg-glow--orange {
  background: radial-gradient(circle, var(--matches-page-glow-b, rgba(255, 114, 24, 0.1)), transparent 70%);
}

body.matches-page[data-matches-bg] .bg-grid {
  background-image:
    linear-gradient(var(--matches-page-grid, rgba(168, 255, 31, 0.035)) 1px, transparent 1px),
    linear-gradient(90deg, var(--matches-page-grid, rgba(168, 255, 31, 0.035)) 1px, transparent 1px);
}

.matches-board-wrap[data-matches-model="orbita"] {
  box-shadow:
    var(--shadow),
    inset 0 0 40px rgba(92, 141, 255, 0.08),
    0 0 28px rgba(92, 225, 255, 0.08);
}

.matches-board-wrap[data-matches-model="bezdna"] {
  box-shadow:
    var(--shadow),
    inset 0 0 40px rgba(123, 220, 181, 0.1),
    0 0 28px rgba(32, 242, 242, 0.08);
}

.matches-prompt {
  margin: 0 0 18px;
  max-width: 38rem;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.45;
}

.matches-svg {
  width: min(100%, 760px);
  height: auto;
  overflow: visible;
  touch-action: manipulation;
  user-select: none;
}

.stick__hit {
  fill: transparent;
  cursor: pointer;
}

.stick__body {
  fill: url(#wood);
  stroke: var(--matches-wood-stroke, rgba(60, 28, 8, 0.55));
  stroke-width: 0.6;
  pointer-events: none;
}

.stick__head {
  fill: url(#head);
  stroke: var(--matches-head-stroke, rgba(70, 10, 8, 0.45));
  stroke-width: 0.5;
  pointer-events: none;
}

.stick--ghost .stick__body,
.stick--ghost .stick__head {
  opacity: 0.22;
  filter: none;
}

.stick--ghost .stick__body {
  fill: var(--matches-ghost-body, rgba(246, 215, 162, 0.35));
  stroke: color-mix(in srgb, var(--matches-ui-accent, var(--green)) 45%, transparent);
  stroke-dasharray: 3 3;
}

.stick--ghost .stick__head {
  fill: var(--matches-ghost-head, rgba(255, 107, 74, 0.28));
}

.stick--selected .stick__body {
  stroke: var(--matches-ui-accent, var(--green));
  stroke-width: 1.4;
}

body[data-matches-style="flat"] .stick__body,
body[data-matches-style="flat"] .stick__head {
  filter: none;
}

body[data-matches-style="flat"] .stick:not(.stick--ghost) {
  filter: none !important;
}

body[data-matches-style="outline"] .stick__body {
  fill: transparent;
  stroke: var(--matches-wood-1, #d18a45);
  stroke-width: 1.8;
}

body[data-matches-style="outline"] .stick__head {
  fill: transparent;
  stroke: var(--matches-head-0, #ff7a55);
  stroke-width: 1.6;
}

body[data-matches-style="outline"] .stick--ghost .stick__body {
  fill: transparent;
  stroke-dasharray: 3 3;
}

body[data-matches-bg="light"] .matches-prompt,
body[data-matches-bg="light"] .matches-status {
  color: #1a2230;
}

body[data-matches-bg="light"] .matches-status--ok {
  color: #3d7a0a;
}

body[data-matches-bg="light"] .matches-board-wrap .matches-prompt {
  color: #1a2230;
}

.stick--disabled {
  pointer-events: none;
  opacity: 0.55;
}

.matches-coin {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.matches-status {
  min-height: 1.45em;
  margin: 16px 0 0;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
}

.matches-status--ok {
  color: var(--green);
}

.matches-status--bad {
  color: #ff8aa0;
}

.matches-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.matches-how {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.stick--selected .stick__hit {
  stroke: rgba(184, 255, 46, 0.35);
  stroke-width: 2;
}

.stick--ghost.stick--selected .stick__body {
  opacity: 0.5;
  stroke: var(--green);
  stroke-dasharray: none;
}

#board-root {
  width: 100%;
  display: flex;
  justify-content: center;
}

@media (max-width: 900px) {
  .matches-modes-layout,
  .matches-map-layout {
    grid-template-columns: 1fr;
    width: calc(100% - 24px);
  }

  .matches-leaderboard-panel {
    position: static;
  }

  .matches-map-viewport {
    height: min(58vh, 520px);
  }

  .matches-play {
    grid-template-columns: 1fr;
  }

  .matches-board-wrap {
    min-height: 360px;
    order: 0;
  }

  .panel--side {
    order: 1;
  }

  .matches-mode-grid {
    grid-template-columns: 1fr;
  }

  .matches-map-header .btn--ghost:last-child {
    display: none;
  }
}

@media (max-width: 560px) {
  .matches-modes-layout,
  .matches-map-layout {
    width: calc(100% - 20px);
  }

  .matches-modes {
    width: auto;
  }

  .matches-map-viewport {
    margin: 0;
    height: min(52vh, 460px);
  }

  .matches-mode-card {
    min-height: 78px;
  }

  .matches-page .header .btn--ghost,
  .matches-page .header .btn--ghost:not(:last-child),
  .matches-page .header .btn--ghost:last-child {
    font-size: 0.85rem;
    padding-inline: 12px;
    min-width: 0;
  }

  .matches-page .header .btn--ghost::before,
  .matches-page .header .btn--ghost:not(:last-child)::before,
  .matches-page .header .btn--ghost:last-child::before {
    content: none;
  }

  .matches-map-title {
    order: 3;
    width: 100%;
    margin-top: 4px;
  }
}
