@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Vazirmatn-Regular.e76a419f636b.ttf") format("truetype");
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/Vazirmatn-Medium.3182cfd5deb0.ttf") format("truetype");
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/Vazirmatn-Bold.f8bc8e05990e.ttf") format("truetype");
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/Vazirmatn-ExtraBold.1dd3b98e0d50.ttf") format("truetype");
}

@font-face {
  font-family: "Vazirmatn";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/Vazirmatn-Black.43956a8d3a53.ttf") format("truetype");
}

:root {
  --bg: #efe6d3;
  --ink: #20242a;
  --muted: #69707a;
  --line: #c9bda8;
  --panel: #fffaf0;
  --accent: #146c68;
  --accent-strong: #0d514e;
  --danger: #b63f3a;
  --ok: #2f8a5f;
  --shadow: 0 18px 50px rgba(43, 36, 24, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(20, 108, 104, .12), transparent 34%),
    linear-gradient(45deg, rgba(190, 60, 49, .1), transparent 38%),
    var(--bg);
  font-family: Vazirmatn, "Noto Naskh Arabic", Tahoma, sans-serif;
}

html.home-root {
  width: 100%;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  padding: .72rem .95rem;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.secondary-button {
  color: var(--ink);
  background: #efe3cc;
}

.secondary-button:hover:not(:disabled) {
  background: #dfcfb4;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .68rem .75rem;
  background: #fffdf7;
  color: var(--ink);
}

label {
  display: grid;
  gap: .45rem;
  font-weight: 700;
}

body.playrooms-shell {
  display: grid;
  place-items: start center;
  overflow: auto;
  padding:
    max(28px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  direction: rtl;
  background:
    radial-gradient(circle at 18% 24%, rgba(20, 108, 104, .12), transparent 28%),
    radial-gradient(circle at 80% 12%, rgba(182, 63, 58, .1), transparent 24%),
    linear-gradient(180deg, #f6efdf, #eadfca 56%, #e5d7bf);
}

.playrooms-page {
  width: min(1040px, 100%);
  min-height: calc(100dvh - 56px);
}

.playrooms-stage {
  display: grid;
  gap: 18px;
  align-items: start;
  width: 100%;
}

.playrooms-masthead {
  display: grid;
  gap: 8px;
  justify-items: start;
  text-align: right;
  width: 100%;
  padding-inline: 4px;
}

.playrooms-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: .84rem;
  font-weight: 800;
}

.playrooms-masthead h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(2rem, 4.2vw, 3.3rem);
  line-height: 1.02;
}

.playrooms-subtitle {
  margin: 0;
  max-width: 34rem;
  color: #5f645f;
  font-size: .96rem;
  line-height: 1.85;
}

.game-catalog {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 180px));
  justify-content: start;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.game-card {
  display: block;
  width: 100%;
  min-height: 72px;
  border: 1px solid rgba(89, 79, 63, .14);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 251, 243, .96), rgba(247, 239, 225, .98));
  box-shadow: 0 10px 22px rgba(73, 59, 37, .08);
  text-decoration: none;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.game-card:hover,
.game-card:focus-visible {
  border-color: rgba(20, 108, 104, .28);
  box-shadow: 0 14px 28px rgba(73, 59, 37, .11);
  transform: translateY(-2px);
}

.game-card:focus-visible {
  outline: 3px solid rgba(20, 108, 104, .18);
  outline-offset: 3px;
}

.game-slot {
  min-width: 0;
}

.game-card-content {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.game-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
}

.game-card p {
  margin: 0;
  color: #6c6f6a;
  font-size: .78rem;
  line-height: 1.55;
}

@media (max-width: 620px) {
  body.playrooms-shell {
    padding:
      max(18px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .playrooms-page {
    min-height: calc(100dvh - 36px);
  }

  .playrooms-stage {
    gap: 14px;
  }

  .game-catalog {
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 10px;
  }

  .game-card {
    min-height: 68px;
    padding: 11px 12px;
  }

  .playrooms-masthead h1 {
    font-size: clamp(1.8rem, 9vw, 2.6rem);
  }

  .game-card h2 {
    font-size: .95rem;
  }

  .game-card p {
    font-size: .74rem;
  }
}

body.home-shell {
  display: grid;
  place-items: center;
  direction: ltr;
  padding:
    max(32px, env(safe-area-inset-top))
    max(32px, env(safe-area-inset-right))
    max(32px, env(safe-area-inset-bottom))
    max(32px, env(safe-area-inset-left));
}

.home-page {
  width: min(980px, 100%);
  direction: rtl;
  min-width: 0;
}

.home-hero {
  position: relative;
  margin-bottom: 28px;
  text-align: center;
}

.home-help-link {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-start: auto;
  inset-inline-end: 0;
}

.history-entry-link,
.history-back {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.history-entry-link:hover,
.history-back:hover {
  text-decoration: underline;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: .95;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.home-actions > form.panel {
  display: grid;
  gap: 14px;
  grid-template-rows: auto auto auto auto;
  min-width: 0;
}

.home-actions > form.panel label {
  align-self: start;
}

.home-actions > form.panel button {
  width: 100%;
  margin-top: 6px;
  align-self: end;
}

body.history-shell {
  display: grid;
  place-items: start center;
  direction: rtl;
  overflow: auto;
  padding:
    max(26px, env(safe-area-inset-top))
    max(22px, env(safe-area-inset-right))
    max(30px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
}

.history-page {
  display: grid;
  gap: 18px;
  width: min(1040px, 100%);
}

.history-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.history-header h1 {
  margin: 4px 0 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, .7fr) minmax(160px, .85fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(89, 79, 63, .18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 240, .92);
  box-shadow: 0 10px 28px rgba(43, 36, 24, .08);
}

.history-card-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.history-card-main > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-card-main p,
.history-card-main small {
  margin: 0;
  color: var(--muted);
}

.history-code {
  direction: ltr;
  font-size: 1.15rem;
}

.history-badge-finished {
  background: var(--ok);
}

.history-result {
  display: grid;
  gap: 3px;
}

.history-result span,
.history-standings {
  color: var(--muted);
  font-size: .86rem;
}

.history-result strong {
  line-height: 1.5;
}

.history-standings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.history-actions {
  display: flex;
  gap: 8px;
  justify-content: end;
}

.history-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 7px;
  padding: .5rem .75rem;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.history-link:hover {
  background: var(--accent-strong);
}

.history-link.secondary-button {
  color: var(--ink);
  background: #efe3cc;
}

.history-empty {
  display: grid;
  justify-items: start;
  gap: 12px;
}

@media (max-width: 860px) {
  .history-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .history-actions {
    justify-content: stretch;
  }

  .history-actions .history-link {
    flex: 1;
  }
}

.map-picker {
  display: grid;
  gap: 10px;
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  overflow: hidden;
}

.map-picker legend {
  padding: 0;
  font-weight: 800;
}

.map-slider {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.map-options {
  display: flex;
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 2px;
  scroll-snap-type: x mandatory;
  padding: 0 2px 8px;
  scrollbar-width: none;
}

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

.map-option {
  position: relative;
  display: block;
  flex: 0 0 178px;
  scroll-snap-align: start;
  cursor: pointer;
}

.map-slider-button {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: 54px;
  min-height: 54px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: rgba(54, 47, 36, .72);
  background: rgba(255, 255, 255, .36);
  box-shadow: 0 10px 28px rgba(54, 47, 36, .14);
  backdrop-filter: blur(8px);
  cursor: pointer;
  user-select: none;
  transform: translateY(-50%);
}

.map-slider-button:hover:not(:disabled) {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, .58);
}

.map-slider-button-left {
  left: -12px;
}

.map-slider-button-right {
  right: -12px;
}

.home-actions > form.panel .map-slider-button {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: 54px;
  min-height: 54px;
  margin: 0;
  padding: 0;
  align-self: auto;
}

.map-option input {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.map-option-card {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(42px, auto) 1fr;
  gap: 7px;
  height: 100%;
  min-height: 244px;
  min-width: 0;
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, .45);
  opacity: 1;
  visibility: visible;
}

.appearance-picker {
  display: grid;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.appearance-picker legend {
  margin-bottom: 2px;
  padding: 0;
  font-weight: 800;
}

.appearance-row {
  display: grid;
  gap: 5px;
}

.appearance-row > strong {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
}

.appearance-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.appearance-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid rgba(89, 79, 63, .16);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  background: rgba(255, 250, 240, .55);
  cursor: pointer;
}

.appearance-choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.appearance-choice small {
  font-size: .74rem;
  font-weight: 800;
}

.appearance-choice:has(input:checked) {
  border-color: rgba(20, 108, 104, .46);
  box-shadow: 0 0 0 2px rgba(20, 108, 104, .12);
  background: rgba(239, 249, 243, .8);
}

.appearance-choice.disabled {
  opacity: .42;
  cursor: not-allowed;
}

.appearance-token {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--player-color);
  box-shadow: 0 0 0 2px rgba(255, 250, 240, .9), 0 0 0 3px rgba(89, 79, 63, .18);
}

.icon-choice {
  color: #26364f;
}

.appearance-panel {
  display: grid;
  gap: 10px;
}

.appearance-panel summary,
.mobile-appearance-details summary {
  cursor: pointer;
  font-weight: 900;
}

.appearance-panel summary {
  color: var(--accent-strong);
}

.appearance-panel form,
.mobile-appearance-form {
  display: grid;
  gap: 10px;
}

.mobile-appearance-details {
  display: grid;
  gap: 8px;
  width: 100%;
}

.map-option-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.map-option-name {
  display: block;
  font-size: 1rem;
  line-height: 1.4;
}

.map-option-description {
  display: block;
  min-height: 42px;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.6;
}

.map-preview-description {
  margin: -4px 0 8px;
  color: var(--muted);
  font-size: .9rem;
}

.map-info-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.map-info-button:hover:not(:disabled) {
  color: var(--accent-strong);
  background: transparent;
}

.map-info-button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-option input:checked + .map-option-card {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(20, 108, 104, .18);
}

.map-preview,
.map-preview-large {
  display: block;
  width: 100%;
  background: #f4ead7;
  border-radius: 6px;
}

.map-preview {
  aspect-ratio: 1.2;
}

.map-preview rect,
.map-preview-large rect {
  fill: #f4ead7;
}

.map-preview line,
.map-preview path,
.map-preview-large line,
.map-preview-large path {
  fill: none;
  stroke: var(--route-color);
  stroke-width: 1.2;
  stroke-linecap: round;
  opacity: .74;
}

.map-preview circle,
.map-preview-large circle {
  fill: #fffaf0;
  stroke: #20242a;
  stroke-width: .45;
}

.map-preview-modal {
  width: min(1480px, 98vw);
  max-width: none;
  max-height: 92vh;
  height: 92vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.map-preview-full h3 {
  margin: 0 0 10px;
}

.map-preview-full {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.preview-map-frame {
  height: calc(100% - 38px);
  min-height: 0;
  overflow: auto;
}

.map-preview-large {
  width: 100%;
  height: min(80vh, 820px);
  border: 1px solid rgba(89, 79, 63, .2);
}

.map-preview-large text {
  fill: #20242a;
  font-size: 2.25px;
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fffaf0;
  stroke-width: .55;
}

.preview-route-cell {
  fill: color-mix(in srgb, var(--route-color) 72%, #fffaf0);
  stroke: rgba(32, 36, 42, .46);
  stroke-width: .18;
}

.preview-route-length {
  fill: #20242a;
  font-size: 2px;
  font-weight: 900;
  paint-order: stroke;
  stroke: #fffaf0;
  stroke-width: .65;
  text-anchor: middle;
}

.compact-button {
  width: auto;
  min-height: 34px;
  padding: .4rem .7rem;
}

.panel {
  border: 1px solid rgba(89, 79, 63, .18);
  border-radius: 8px;
  background: rgba(255, 250, 240, .92);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel form,
.inline-form {
  display: grid;
  gap: 12px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  margin: 0;
  border-radius: 7px;
  padding: .75rem .9rem;
  background: #fff3d5;
  border: 1px solid #e4c886;
}

.message.error {
  color: #fff;
  background: var(--danger);
  border-color: transparent;
}

.action-toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
  direction: rtl;
}

.action-toast {
  position: relative;
  width: 100%;
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 14px;
  padding: 12px 42px 12px 14px;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(20, 108, 104, .14), transparent 30%),
    rgba(255, 250, 240, .72);
  box-shadow: 0 18px 46px rgba(28, 25, 20, .2);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  animation: action-toast-in .24s ease-out both;
}

.action-toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: .86rem;
}

.action-toast p {
  margin: 0;
  color: #312b22;
  font-size: .9rem;
  font-weight: 800;
  line-height: 1.7;
}

.action-toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid rgba(89, 79, 63, .16);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 250, 240, .62);
  font-size: 1rem;
  line-height: 1;
}

.action-toast-close:hover {
  color: var(--danger);
  background: rgba(255, 250, 240, .9);
}

@keyframes action-toast-in {
  from {
    opacity: 0;
    transform: translate(18px, 8px);
  }
  to {
    opacity: 1;
    transform: translate(0, 0);
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(89, 79, 63, .18);
  background: rgba(255, 250, 240, .9);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.help-link {
  display: inline-grid;
  place-items: center;
  min-width: 58px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(89, 79, 63, .24);
  border-radius: 999px;
  color: var(--accent-strong);
  background: #fff4dd;
  font-size: .82rem;
  font-weight: 900;
  text-decoration: none;
}

.help-link:hover {
  background: #ead8b8;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: .92rem;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  grid-template-areas: "board side";
  gap: 18px;
  padding: 18px;
  height: calc(100vh - 57px);
  height: calc(100dvh - 57px);
  overflow: hidden;
  direction: ltr;
}

.text-link {
  color: var(--accent-strong);
  font-weight: 900;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.monitor-body {
  overflow: hidden;
}

.monitor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 26vw);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "head head"
    "board side";
  gap: 14px;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 14px;
  direction: ltr;
}

.monitor-header {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 0;
  border: 1px solid rgba(89, 79, 63, .18);
  border-radius: 12px;
  padding: 12px 16px;
  direction: rtl;
  background: rgba(255, 250, 240, .9);
  box-shadow: var(--shadow);
}

.monitor-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 3.2rem);
  line-height: 1;
}

.monitor-header .eyebrow {
  margin-bottom: 5px;
}

.monitor-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  color: var(--muted);
  font-size: clamp(.9rem, 1.1vw, 1.1rem);
}

.monitor-board {
  position: relative;
  grid-area: board;
  min-width: 0;
  min-height: 0;
  direction: rtl;
}

.monitor-map-frame {
  border-radius: 14px;
}

.monitor-side {
  grid-area: side;
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  direction: rtl;
}

.monitor-panel {
  padding: 14px;
}

.monitor-players {
  display: grid;
  gap: 9px;
}

.monitor-player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  border: 1px solid rgba(89, 79, 63, .16);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, .48);
}

.monitor-player.active {
  border-color: rgba(20, 108, 104, .42);
  background: rgba(20, 108, 104, .1);
  box-shadow: inset 0 0 0 1px rgba(20, 108, 104, .18);
}

.monitor-player small,
.monitor-player b {
  grid-column: 2 / 4;
}

.monitor-player small {
  color: var(--muted);
}

.monitor-face-up {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.board-area {
  position: relative;
  grid-area: board;
  min-width: 0;
  min-height: 0;
  direction: rtl;
}

.map-frame {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  border: 1px solid rgba(89, 79, 63, .22);
  border-radius: 8px;
  background: #f4ead7;
  box-shadow: var(--shadow);
}

.map-frame.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.map-frame.is-panning {
  cursor: grabbing;
  user-select: none;
}

.map-frame.is-panning .route-node {
  pointer-events: none;
}

.desktop-map-overlays {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: block;
  pointer-events: none;
}

.desktop-map-summary {
  position: absolute;
  z-index: 1;
  display: grid;
  gap: 8px;
  width: min(230px, 28%);
  max-height: min(320px, calc(100% - 32px));
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 12px;
  background: rgba(255, 250, 240, .58);
  box-shadow: 0 14px 30px rgba(39, 30, 18, .13);
  backdrop-filter: blur(10px);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.desktop-map-summary.is-dragging {
  cursor: grabbing;
  box-shadow: 0 18px 36px rgba(39, 30, 18, .2);
}

.desktop-map-summary-cards {
  top: 66px;
  right: 16px;
  width: min(150px, 19%);
}

.desktop-map-summary-tickets {
  top: 66px;
  left: 16px;
}

.desktop-map-summary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #302a22;
}

.desktop-summary-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .86rem;
  line-height: 1.65;
}

.desktop-summary-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.desktop-summary-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-card-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-color-mark {
  position: relative;
  display: inline-block;
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: var(--card-color);
  box-shadow:
    0 0 0 1px rgba(255, 250, 240, .86),
    0 0 0 2px rgba(89, 79, 63, .16);
}

.card-color-mark.wild {
  background:
    radial-gradient(circle at 35% 32%, #fff7d0 0 22%, transparent 23%),
    linear-gradient(135deg, #f6d77a, #c79538 54%, #76501f);
  box-shadow:
    inset 0 0 0 1px rgba(255, 250, 230, .52),
    0 0 0 1px rgba(255, 250, 240, .86),
    0 0 0 2px rgba(121, 82, 28, .22);
}

.desktop-summary-list b {
  flex: 0 0 auto;
}

.desktop-summary-list .done span {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(185, 56, 48, .78);
}

.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  display: flex;
  gap: 7px;
  direction: ltr;
}

.map-control {
  min-width: 38px;
  min-height: 38px;
  padding: .45rem .6rem;
  color: var(--ink);
  background: rgba(255, 250, 240, .94);
  border: 1px solid rgba(89, 79, 63, .22);
  box-shadow: 0 8px 22px rgba(43, 36, 24, .14);
}

.map-control:hover:not(:disabled) {
  background: #fff4dd;
}

.map-control.wide {
  min-width: 74px;
}

.map-turn-badge {
  display: none;
}

.turn-step-badge {
  background: #146c68;
  box-shadow: 0 10px 18px rgba(20, 108, 104, .22);
}

.map {
  --map-symbol-scale: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  background: #f4ead7;
  transform-origin: top left;
}

.route-node {
  cursor: help;
  pointer-events: auto;
}

.route-node.claimable {
  cursor: pointer;
}

.city-node {
  cursor: help;
  pointer-events: auto;
}

.city-hitbox {
  fill: transparent;
  stroke: transparent;
  stroke-width: 0;
}

.route-hitbox {
  fill: none;
  pointer-events: stroke;
  stroke: transparent;
  stroke-width: 12px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.route-line {
  fill: none;
  pointer-events: none;
  stroke: var(--route-color);
  stroke-width: .55;
  stroke-linecap: round;
  stroke-dasharray: none;
  opacity: .24;
  vector-effect: non-scaling-stroke;
}

.route-tooltip {
  position: fixed;
  z-index: 80;
  max-width: min(360px, calc(100vw - 24px));
  transform: translate(-50%, calc(-100% - 14px));
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 12px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 250, 240, .96);
  box-shadow: 0 18px 46px rgba(28, 25, 20, .22);
  backdrop-filter: blur(8px);
  font-size: .82rem;
  font-weight: 900;
  line-height: 1.6;
  pointer-events: none;
  text-align: center;
  white-space: pre-line;
}

.route-tooltip[hidden] {
  display: none;
}

.route-tooltip .claimed-route-line {
  text-decoration-line: line-through;
  text-decoration-color: #c4302b;
  text-decoration-thickness: 1.5px;
}

.route-tooltip .open-route-line {
  text-decoration: none;
}

.route-node.claimed .route-line {
  stroke-width: 1.28;
  stroke-dasharray: none;
  opacity: .94;
  filter:
    drop-shadow(0 0 .75px rgba(255, 250, 240, .95))
    drop-shadow(0 0 1.25px color-mix(in srgb, var(--route-color) 70%, #20242a));
}

.route-node.claimable .route-line {
  stroke-width: .85;
  filter: drop-shadow(0 0 .9px rgba(20, 108, 104, .75));
  opacity: .72;
}

.route-node.claimable:hover .route-line {
  stroke-width: 1.2;
}

.route-cell {
  pointer-events: none;
  x: calc(-1.45px * var(--map-symbol-scale));
  y: calc(-0.82px * var(--map-symbol-scale));
  width: calc(2.9px * var(--map-symbol-scale));
  height: calc(1.64px * var(--map-symbol-scale));
  rx: calc(.35px * var(--map-symbol-scale));
  fill: color-mix(in srgb, var(--route-color) 72%, #fffaf0);
  stroke: rgba(32, 36, 42, .48);
  stroke-width: .18;
  vector-effect: non-scaling-stroke;
}

.route-node.claimed .route-cell {
  fill: var(--route-color);
  stroke: rgba(255, 250, 240, .72);
}

.route-token {
  pointer-events: none;
  fill: var(--route-color);
  stroke: #fffaf0;
  stroke-width: .34;
  paint-order: stroke;
  filter:
    drop-shadow(0 .25px .35px rgba(32, 36, 42, .46))
    drop-shadow(0 0 .75px color-mix(in srgb, var(--route-color) 72%, #20242a));
}

.route-token > * {
  transform: scale(var(--map-symbol-scale));
  transform-box: fill-box;
  transform-origin: center;
  vector-effect: non-scaling-stroke;
}

.route-token-star {
  stroke-width: .28;
}

.route-node.claimable .route-cell {
  stroke: #123f3e;
  stroke-width: .26;
}

.route-node.claimable:hover .route-cell {
  filter: drop-shadow(0 0 .65px rgba(20, 108, 104, .9));
}

.route-length {
  fill: #584f42;
  font-size: calc(2px * var(--map-symbol-scale));
  font-weight: 800;
  pointer-events: none;
}

.city circle:not(.city-hitbox) {
  r: calc(1.7px * var(--map-symbol-scale));
  fill: #fffaf0;
  stroke: #2f302f;
  stroke-width: .45;
  transition: fill .16s ease, stroke .16s ease, r .16s ease, filter .16s ease;
  vector-effect: non-scaling-stroke;
}

.city text {
  fill: #20242a;
  font-size: calc(2.25px * var(--map-symbol-scale));
  font-weight: 900;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #fffaf0;
  stroke-width: .55;
  transition: fill .16s ease, font-size .16s ease;
  vector-effect: non-scaling-stroke;
}

.city-node.mission-highlight-origin circle:not(.city-hitbox),
.city-node.mission-highlight-destination circle:not(.city-hitbox) {
  r: calc(2.45px * var(--map-symbol-scale));
  filter: drop-shadow(0 0 1px rgba(32, 36, 42, .38));
}

.city-node.mission-highlight-origin circle:not(.city-hitbox) {
  fill: #e46f2b;
  stroke: #fff5ea;
  stroke-width: .62;
}

.city-node.mission-highlight-destination circle:not(.city-hitbox) {
  fill: #146c68;
  stroke: #eefaf9;
  stroke-width: .62;
}

.city-node.mission-highlight-origin text,
.city-node.mission-highlight-destination text {
  font-size: calc(2.48px * var(--map-symbol-scale));
}

.city-node.mission-highlight-origin text {
  fill: #b44f16;
}

.city-node.mission-highlight-destination text {
  fill: #0f5753;
}

.route-node.result-path-highlight .route-line {
  stroke-width: calc(1.38px * var(--map-symbol-scale));
  filter: drop-shadow(0 0 1.6px rgba(20, 108, 104, .55));
}

.route-node.result-path-highlight .route-cell,
.route-node.result-path-highlight .route-token {
  filter: drop-shadow(0 0 1.3px rgba(20, 108, 104, .7));
}

.city-node.result-path-highlight circle:not(.city-hitbox) {
  r: calc(2.18px * var(--map-symbol-scale));
  stroke: #fffaf0;
  stroke-width: .58;
}

.map.result-filter-active .route-node,
.map.result-filter-active .city-node {
  opacity: .2;
}

.map.result-filter-active .route-node.result-path-highlight,
.map.result-filter-active .city-node.result-path-highlight,
.map.result-filter-active .city-node.mission-highlight-origin,
.map.result-filter-active .city-node.mission-highlight-destination {
  opacity: 1;
}

.side-panel {
  grid-area: side;
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-left: 3px;
  direction: rtl;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ticket-action-form {
  margin-top: 12px;
}

.ticket-action-form button {
  width: 100%;
  min-height: 46px;
}

.badge {
  border-radius: 999px;
  padding: .28rem .55rem;
  color: #fff;
  background: var(--accent);
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}

.players,
.tickets,
.route-list,
.standings {
  display: grid;
  gap: 9px;
}

.player-row,
.ticket,
.standing-row {
  border: 1px solid rgba(89, 79, 63, .16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, .48);
}

.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 8px;
  align-items: center;
}

.player-row small {
  grid-column: 2 / 4;
  color: var(--muted);
}

.player-row.active {
  outline: 2px solid rgba(20, 108, 104, .28);
}

.swatch,
.player-marker {
  display: inline-block;
  width: 14px;
  height: 14px;
}

.swatch {
  border-radius: 50%;
}

.player-marker {
  background: var(--player-color);
  box-shadow:
    0 0 0 2px rgba(255, 250, 240, .85),
    0 0 0 3px rgba(89, 79, 63, .18);
}

.player-marker-circle {
  border-radius: 50%;
}

.player-marker-diamond {
  transform: rotate(45deg) scale(.86);
}

.player-marker-triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.player-marker-square {
  border-radius: 3px;
}

.player-marker-star {
  clip-path: polygon(50% 0, 62% 34%, 98% 35%, 69% 56%, 80% 92%, 50% 70%, 20% 92%, 31% 56%, 2% 35%, 38% 34%);
}

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

.card-chip,
.train-card {
  color: #171a1f;
  background: color-mix(in srgb, var(--chip-color) 32%, #fffaf0);
  border: 1px solid color-mix(in srgb, var(--chip-color) 58%, #6b6254);
}

.card-chip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-radius: 7px;
  padding: .55rem .62rem;
  font-weight: 800;
}

.card-chip.wild {
  color: #3a2710;
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 250, 218, .84), transparent 24%),
    linear-gradient(135deg, #fff0b9, #c79538 56%, #785121);
  border-color: rgba(137, 91, 28, .56);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 230, .38);
}

.ticket {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ticket.done {
  border-color: rgba(47, 138, 95, .45);
  background: rgba(47, 138, 95, .1);
}

.selectable .ticket {
  cursor: pointer;
}

.selectable input {
  width: auto;
}

.face-up {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  column-gap: 12px;
  row-gap: 12px;
  margin-bottom: 16px;
}

.face-up form,
.train-actions form {
  display: block;
  min-width: 0;
}

.train-card {
  display: block;
  width: 100%;
  min-height: 54px;
  color: #171a1f;
  padding: .45rem .35rem;
  white-space: normal;
}

.train-card.wild {
  color: #3a2710;
  background:
    radial-gradient(circle at 17% 18%, rgba(255, 250, 218, .88), transparent 24%),
    linear-gradient(135deg, #fff0b9, #c79538 56%, #785121);
  border-color: rgba(137, 91, 28, .58);
  box-shadow: inset 0 0 0 1px rgba(255, 250, 230, .4);
  font-size: .82rem;
  line-height: 1.25;
}

.train-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 6px;
}

.train-actions button {
  width: 100%;
  min-height: 46px;
}

.muted {
  color: var(--muted);
}

.join-panel {
  width: min(520px, calc(100% - 32px));
  max-width: 520px;
}

.join-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.join-overlay .join-panel {
  pointer-events: auto;
  background:
    radial-gradient(circle at 18% 12%, rgba(20, 108, 104, .12), transparent 28%),
    rgba(255, 250, 240, .94);
  box-shadow: 0 28px 80px rgba(28, 25, 20, .24);
  backdrop-filter: blur(10px);
}

.join-panel-head {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.join-panel-kicker {
  color: var(--accent-strong);
  font-size: .86rem;
  font-weight: 900;
}

.join-panel h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 2.7rem);
  line-height: 1.1;
}

.join-game-code {
  justify-self: start;
  border: 1px solid rgba(20, 108, 104, .22);
  border-radius: 999px;
  padding: .24rem .72rem;
  color: var(--accent-strong);
  background: rgba(20, 108, 104, .08);
  font-weight: 900;
  letter-spacing: .08em;
}

.join-panel-copy {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.8;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 25, 20, .44);
  backdrop-filter: blur(6px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(430px, 100%);
  border: 1px solid rgba(89, 79, 63, .22);
  border-radius: 8px;
  padding: 20px;
  background: #fffaf0;
  box-shadow: 0 24px 80px rgba(28, 25, 20, .28);
}

.modal.map-preview-modal {
  width: min(1480px, 96vw);
  max-width: none;
}

@media (min-width: 900px) {
  .modal.map-preview-modal {
    min-width: 66vw;
  }
}

.modal p {
  color: var(--muted);
  line-height: 1.8;
}

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

.route-choice-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.route-choice-list[hidden] {
  display: none;
}

.route-choice-list button {
  min-height: 38px;
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 10px;
  padding: .45rem .7rem;
  color: var(--ink);
  background: rgba(239, 227, 204, .76);
  text-align: right;
}

.route-choice-list button.active {
  border-color: rgba(20, 108, 104, .45);
  color: #fff;
  background: var(--accent);
}

.claim-color-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.claim-color-list[hidden] {
  display: none;
}

.claim-color-list strong {
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: .9rem;
}

.claim-color-list button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid rgba(89, 79, 63, .2);
  border-radius: 10px;
  padding: .42rem .62rem;
  color: var(--ink);
  background: rgba(255, 250, 240, .88);
  font-weight: 800;
}

.claim-color-list button.active {
  border-color: rgba(20, 108, 104, .5);
  background: rgba(20, 108, 104, .12);
  box-shadow: inset 0 0 0 1px rgba(20, 108, 104, .2);
}

.color-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid rgba(89, 79, 63, .28);
  border-radius: 50%;
  background: var(--choice-color);
}

.final-results-modal {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, 94vw);
  max-height: min(88vh, 720px);
  max-height: min(88dvh, 720px);
  overflow: hidden;
}

.final-results-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-left: 4px;
}

.final-results-list {
  gap: 12px;
}

.final-result-card {
  display: grid;
  gap: 14px;
}

.final-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.final-result-head strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.final-player-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: .84rem;
}

.final-player-meta span {
  border-radius: 999px;
  padding: .16rem .48rem;
  background: rgba(239, 227, 204, .52);
}

.longest-detail {
  display: grid;
  gap: 7px;
  border-radius: 10px;
  padding: 10px;
  background: rgba(239, 227, 204, .45);
}

.longest-detail ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0 1.25rem 0 0;
}

.longest-detail li {
  padding-right: 2px;
}

.longest-detail li small {
  color: var(--muted);
}

.result-section {
  display: grid;
  gap: 10px;
}

.result-section h3 {
  margin: 0;
  font-size: .95rem;
}

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

.result-path-card {
  position: relative;
  display: block;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(89, 79, 63, .16);
  border-radius: 8px;
  padding: 0;
  background: rgba(255, 253, 247, .9);
  outline: 0;
}

.result-path-card:hover,
.result-path-card:focus-visible {
  border-color: rgba(20, 108, 104, .38);
  box-shadow: inset 0 0 0 1px rgba(20, 108, 104, .14);
}

.result-path-card.completed {
  background: rgba(240, 250, 244, .88);
}

.result-path-card.failed {
  background: rgba(255, 245, 242, .88);
}

.result-path-card-body {
  position: absolute;
  inset-inline: 6px;
  inset-block-end: 6px;
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 1px solid rgba(255, 250, 240, .7);
  border-radius: 7px;
  padding: 5px 6px;
  background: rgba(255, 250, 240, .88);
  box-shadow: 0 6px 18px rgba(32, 36, 42, .12);
}

.result-path-card-body strong {
  overflow: hidden;
  line-height: 1.35;
  font-size: .76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-path-card-body small {
  overflow: hidden;
  color: var(--muted);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-score {
  width: fit-content;
  border-radius: 999px;
  padding: .08rem .38rem;
  color: var(--muted);
  background: rgba(105, 112, 122, .1);
  font-size: .68rem;
  font-weight: 900;
}

.result-score.positive {
  color: #16633f;
  background: rgba(47, 138, 95, .14);
}

.result-score.negative {
  color: #9d332e;
  background: rgba(182, 63, 58, .13);
}

.result-mini-map {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: rgba(239, 227, 204, .55);
}

.result-mini-map rect {
  fill: rgba(255, 250, 240, .7);
}

.result-mini-route {
  fill: none;
  stroke: rgba(89, 79, 63, .18);
  stroke-width: .32;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-mini-route.highlighted {
  stroke: var(--route-color);
  stroke-width: 1.18;
  filter: drop-shadow(0 0 1px rgba(32, 36, 42, .35));
}

.result-mini-city {
  fill: rgba(89, 79, 63, .35);
}

.result-mini-city.highlighted {
  fill: #146c68;
}

.result-mini-city.endpoint {
  fill: #e46f2b;
  stroke: #fffaf0;
  stroke-width: .45;
}

.result-route-list {
  display: grid;
  gap: 4px;
  max-height: 150px;
  margin: 2px 0 0;
  padding: 0 1.1rem 0 0;
  overflow: auto;
  color: var(--ink);
  font-size: .86rem;
}

.result-route-list small {
  display: block;
}

.monitor-results-panel {
  display: grid;
  gap: 12px;
}

.monitor-results-panel .final-results-list {
  gap: 10px;
}

.monitor-results-panel .result-card-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rules-body {
  overflow: auto;
}

.rules-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 36px 20px;
}

.rules-header {
  max-width: 760px;
  margin-bottom: 24px;
}

.rules-header h1 {
  font-size: clamp(2.2rem, 6vw, 4.7rem);
}

.rules-grid {
  counter-reset: rule-step;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.rules-grid .panel {
  counter-increment: rule-step;
}

.rules-grid h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-grid h2::before {
  content: counter(rule-step);
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  background: var(--accent-strong);
  font-size: .82rem;
  font-weight: 900;
}

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

@media (max-width: 980px) {
  body.home-shell {
    align-items: start;
    overflow: auto;
  }

  .home-actions {
    grid-template-columns: 1fr;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "side"
      "board";
    grid-template-rows: minmax(220px, 42vh) minmax(320px, 1fr);
    height: calc(100vh - 57px);
    height: calc(100dvh - 57px);
  }

  .action-toasts {
    display: none;
  }

  .map {
    height: 100%;
  }

  .side-panel {
    order: initial;
  }

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

  .home-page {
    width: min(680px, 100%);
  }

  .map-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    padding: 0;
    scroll-snap-type: none;
    scrollbar-width: auto;
  }

  .map-option {
    flex: initial;
  }

  .map-slider-button {
    display: none;
  }

  .map-option-card {
    min-height: 0;
  }

  .modal.map-preview-modal {
    width: 96vw;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  body.home-shell,
  .game-shell {
    padding: 12px;
  }

  body.home-shell {
    place-items: start center;
    overflow: auto;
  }

  .home-hero {
    margin-bottom: 18px;
  }

  h1 {
    font-size: clamp(2rem, 16vw, 3.1rem);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .game-meta {
    gap: 6px 10px;
    font-size: .82rem;
  }

  .game-shell {
    height: calc(100vh - 92px);
    height: calc(100dvh - 92px);
    grid-template-rows: minmax(210px, 44vh) minmax(300px, 1fr);
  }

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

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

  .map-options {
    display: grid;
    grid-template-columns: 1fr;
  }

  .map-option-card {
    grid-template-columns: minmax(0, 1fr) 104px;
    grid-template-rows: none;
    align-items: center;
  }

  .map-option-title {
    order: 1;
  }

  .map-preview {
    order: 2;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .map-preview-modal {
    height: 94vh;
    max-height: 94vh;
    padding: 12px;
  }

  .preview-map-frame {
    height: calc(100% - 34px);
  }

  .home-actions > form.panel,
  .home-actions > form.panel:nth-child(2) {
    grid-template-rows: none;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) and (orientation: landscape) {
  .topbar {
    flex-direction: row;
    align-items: center;
    padding: 8px 12px;
  }

  .brand {
    font-size: 1rem;
    white-space: nowrap;
  }

  .game-meta {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    gap: 8px;
    max-width: calc(100vw - 180px);
    overflow-x: auto;
    white-space: nowrap;
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 32vw);
    grid-template-areas: "board side";
    grid-template-rows: 1fr;
    gap: 12px;
    height: calc(100vh - 49px);
    height: calc(100dvh - 49px);
    padding: 12px;
  }

  .side-panel {
    order: initial;
  }

  .map-toolbar {
    top: 8px;
    left: 8px;
  }

  .map-control {
    min-width: 34px;
    min-height: 34px;
    padding: .34rem .52rem;
  }

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

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

  .panel {
    padding: 12px;
  }

  .map-preview-modal {
    width: 96vw;
    height: 92vh;
    height: 92dvh;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  .topbar {
    gap: 10px;
    padding: 7px 10px;
  }

  .game-meta {
    font-size: .76rem;
    max-width: calc(100vw - 150px);
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 36vw);
    gap: 10px;
    height: calc(100vh - 44px);
    height: calc(100dvh - 44px);
    padding: 10px;
  }

  .side-panel {
    gap: 10px;
  }

  .panel {
    padding: 10px;
  }

  h2 {
    margin-bottom: 8px;
    font-size: 1rem;
  }

  .player-row,
  .ticket,
  .standing-row {
    padding: 8px;
  }

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

  .face-up {
    gap: 8px;
    margin-bottom: 10px;
  }

  .train-card {
    min-height: 44px;
    font-size: .86rem;
  }

  .ticket-action-form button,
  .train-actions button {
    min-height: 42px;
  }
}

.mobile-game-ui,
.orientation-guard,
.map-preview-rotate-guard,
.mobile-map-overlays {
  display: none;
}

@media (max-width: 700px) {
  body.home-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 14px 14px;
    background: #ede4d2;
  }

  .home-page {
    width: 100%;
    max-width: 420px;
    margin: 14px auto 0;
    overflow: hidden;
  }

  .home-page > *,
  .home-actions > form.panel,
  .home-actions input,
  .map-option-card {
    width: 100%;
    max-width: 100%;
  }

  .home-hero {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 0 9px;
    padding: 12px 14px 9px;
    background: transparent;
    backdrop-filter: blur(10px);
  }

  .home-help-link {
    inset-block-start: 12px;
    inset-inline-end: 14px;
    height: 26px;
    min-width: 54px;
    font-size: .78rem;
  }

  .home-hero h1 {
    margin-bottom: 4px;
    font-size: clamp(1.65rem, 8vw, 2.15rem);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
  }

  .home-hero p {
    margin: 0 auto;
    max-width: 330px;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.55;
    text-align: center;
  }

  .home-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    width: 100%;
    min-width: 0;
    direction: ltr;
  }

  .home-actions > form.panel,
  .home-actions > form.panel:nth-child(2) {
    width: 100%;
    min-width: 0;
    direction: ltr;
    gap: 8px;
    grid-template-rows: none;
    border-radius: 13px;
    padding: 10px;
    background: #fff8ed;
    box-shadow: 0 1px 2px rgba(43, 36, 24, .08);
  }

  .home-actions > form.panel h2 {
    margin-bottom: 0;
    font-size: .98rem;
    text-align: right;
  }

  .home-actions > form.panel > * {
    direction: rtl;
  }

  .home-actions > form.panel label,
  .map-picker legend {
    text-align: right;
  }

  .home-actions > form.panel button {
    min-height: 42px;
    margin-top: 0;
    border-radius: 10px;
    padding: .5rem .8rem;
  }

  .home-actions input {
    min-height: 40px;
    border-radius: 10px;
    padding: .48rem .65rem;
    font-size: .92rem;
    text-align: right;
  }

  .map-picker {
    gap: 6px;
  }

  .map-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    overflow: visible;
    padding: 0;
    scroll-snap-type: none;
    scrollbar-width: auto;
  }

  .map-option {
    flex: initial;
  }

  .map-option-card {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    grid-template-rows: none;
    align-items: center;
    justify-items: center;
    direction: ltr;
    gap: 8px;
    min-height: 58px;
    border-radius: 11px;
    padding: 7px;
    background:
      linear-gradient(135deg, rgba(255, 255, 255, .68), rgba(255, 250, 240, .46)),
      rgba(255, 255, 255, .45);
  }

  .map-option-title {
    order: 2;
    direction: rtl;
    justify-content: space-between;
    align-self: center;
    min-width: 0;
  }

  .map-option-description {
    order: 3;
    grid-column: 2;
    min-height: 0;
    font-size: .7rem;
    text-align: right;
  }

  .map-option-name {
    font-size: .92rem;
    text-align: right;
  }

  .map-info-button {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .map-info-button svg {
    width: 18px;
    height: 18px;
  }

  .map-preview {
    order: 1;
    width: 78px;
    height: 50px;
    aspect-ratio: auto;
    border: 1px solid rgba(89, 79, 63, .14);
  }

  .map-option input:checked + .map-option-card {
    border-color: var(--accent);
    background: rgba(235, 248, 240, .78);
    box-shadow: 0 0 0 2px rgba(20, 108, 104, .18);
  }

  .messages {
    margin-bottom: 8px;
  }
}

@media (max-width: 700px) and (max-height: 760px) {
  .home-hero {
    padding-top: 8px;
    padding-bottom: 6px;
  }

  .home-hero h1 {
    font-size: clamp(1.55rem, 7.5vw, 2rem);
  }

  .map-option-card {
    min-height: 44px;
    padding: 5px 7px;
  }

  .map-preview {
    width: 64px;
    height: 34px;
  }

  .home-actions > form.panel,
  .home-actions > form.panel:nth-child(2) {
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .home-actions input {
    min-height: 36px;
    padding: .38rem .6rem;
  }

  .home-actions > form.panel button {
    min-height: 38px;
  }

  .home-actions > form.panel:nth-child(2) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-actions > form.panel:nth-child(2) h2,
  .home-actions > form.panel:nth-child(2) button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 980px) and (orientation: portrait) {
  #map-preview-modal {
    padding: 16px;
  }

  #map-preview-modal .map-preview-modal {
    display: none;
  }

  .map-preview-rotate-guard {
    display: grid;
    gap: 12px;
    width: min(380px, 100%);
    border: 1px solid rgba(255, 250, 240, .22);
    border-radius: 18px;
    padding: 22px;
    color: #fffaf0;
    background:
      radial-gradient(circle at 20% 12%, rgba(255, 250, 240, .14), transparent 24%),
      linear-gradient(135deg, #123f3e, #20242a 68%);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
    text-align: center;
  }

  .map-preview-rotate-guard strong {
    font-size: 1.2rem;
    line-height: 1.6;
  }

  .map-preview-rotate-guard span {
    color: rgba(255, 250, 240, .74);
    line-height: 1.9;
  }

  .map-preview-rotate-guard button {
    justify-self: center;
    min-width: 120px;
  }
}

@media (max-width: 980px) and (orientation: landscape) {
  body.home-shell .modal-backdrop {
    padding: 8px;
  }

  body.home-shell .map-preview-modal {
    width: 98vw;
    height: 94vh;
    height: 94dvh;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 14px;
    padding: 12px;
  }

  body.home-shell .preview-map-frame {
    height: calc(100% - 34px);
  }
}

@media (max-width: 980px) and (orientation: portrait) {
  .orientation-guard {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #fffaf0;
    background:
      radial-gradient(circle at 24% 18%, rgba(255, 250, 240, .16), transparent 24%),
      linear-gradient(135deg, #123f3e, #20242a 66%);
    text-align: center;
  }

  .orientation-guard div {
    display: grid;
    gap: 10px;
    max-width: 340px;
    border: 1px solid rgba(255, 250, 240, .22);
    border-radius: 16px;
    padding: 24px;
    background: rgba(255, 250, 240, .08);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .28);
  }

  .orientation-guard strong {
    font-size: 1.35rem;
  }

  .orientation-guard span {
    color: rgba(255, 250, 240, .76);
    line-height: 1.9;
  }
}

@media (max-width: 980px) and (orientation: landscape) {
  .topbar {
    display: none;
  }

  .game-shell {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "board"
      "mobile";
    grid-template-rows: minmax(0, 1fr) 70px;
    gap: 8px;
    height: 100vh;
    height: 100dvh;
    padding: 8px;
    background:
      linear-gradient(180deg, rgba(20, 108, 104, .08), transparent 42%),
      var(--bg);
  }

  .desktop-side-panel {
    display: none;
  }

  .action-toasts {
    display: none;
  }

  .desktop-map-overlays {
    display: none;
  }

  .board-area {
    position: relative;
    grid-area: board;
    min-height: 0;
  }

  .mobile-map-overlays {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: grid;
    gap: 8px;
    width: min(220px, 28vw);
    direction: rtl;
    pointer-events: none;
  }

  .mobile-map-overlays.secondary {
    top: 58px;
    right: auto;
    left: 12px;
  }

  .mobile-map-summary {
    position: relative;
    display: grid;
    gap: 5px;
    min-width: 0;
    max-height: 118px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(89, 79, 63, .2);
    border-radius: 12px;
    padding: 9px 10px 8px 32px;
    color: rgba(32, 36, 42, .9);
    background: rgba(255, 250, 240, .58);
    box-shadow: 0 14px 36px rgba(43, 36, 24, .12);
    backdrop-filter: blur(10px);
    pointer-events: auto;
  }

  .mobile-map-summary[hidden] {
    display: none;
  }

  .mobile-map-summary strong {
    font-size: .78rem;
    line-height: 1.2;
  }

  .mobile-map-summary ul {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-map-summary li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    font-size: .7rem;
    line-height: 1.25;
  }

  .mobile-map-summary li.done {
    color: var(--ok);
  }

  .mobile-map-summary li.current {
    border-radius: 8px;
    margin-inline: -3px;
    padding: 2px 3px;
    color: var(--accent-strong);
    background: rgba(20, 108, 104, .11);
  }

  .mobile-map-summary li span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-map-summary li b {
    flex: 0 0 auto;
  }

  .score-summary-row {
    align-items: flex-start;
  }

  .score-summary-name {
    display: inline-flex;
    gap: 5px;
    align-items: center;
  }

  .score-summary-name .player-marker {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
  }

  .score-summary-row.current .score-summary-name::after {
    content: "نوبت";
    display: inline-block;
    margin-right: 5px;
    border-radius: 999px;
    padding: 1px 5px;
    color: #fff;
    background: var(--accent);
    font-size: .58rem;
    font-weight: 800;
    vertical-align: middle;
  }

  .score-summary-stats {
    display: flex;
    flex: 0 0 auto;
    gap: 5px;
    align-items: center;
    color: var(--muted);
  }

  .score-summary-stats b {
    color: var(--ink);
  }

  .score-summary-stats small {
    font-size: .58rem;
    white-space: nowrap;
  }


  .mobile-map-summary-close {
    position: absolute;
    top: 6px;
    left: 6px;
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    min-height: 20px;
    border-radius: 7px;
    padding: 0;
    color: var(--ink);
    background: rgba(239, 227, 204, .72);
    font-size: .78rem;
  }

  .mobile-summary-toggle {
    justify-self: stretch;
    min-height: 30px;
    border-radius: 999px;
    padding: .3rem .65rem;
    color: var(--accent-strong);
    background: rgba(239, 227, 204, .64);
    font-size: .76rem;
  }

  .mobile-summary-toggle:hover:not(:disabled) {
    background: rgba(223, 207, 180, .82);
  }

  .mobile-settings-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  .map-frame {
    border-radius: 12px;
  }

  .route-hitbox {
    stroke-width: 9;
  }

  .map-toolbar {
    top: 9px;
    left: 9px;
  }

  .map-control {
    min-width: 34px;
    min-height: 34px;
    padding: .32rem .52rem;
    font-size: .88rem;
  }

  .map-control.wide {
    min-width: 66px;
  }

  .map-turn-badge {
    display: inline-grid;
    place-items: center;
    min-height: 34px;
    border: 1px solid rgba(20, 108, 104, .34);
    border-radius: 999px;
    padding: .32rem .68rem;
    color: #fff;
    background: var(--accent);
    box-shadow: 0 8px 22px rgba(20, 108, 104, .2);
    font-size: .82rem;
    font-weight: 900;
    white-space: nowrap;
  }

  .mobile-game-ui {
    position: relative;
    z-index: 8;
    grid-area: mobile;
    display: grid;
    min-height: 0;
    direction: rtl;
  }

  .mobile-dock {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) 52px;
    gap: 8px;
    align-items: stretch;
    border: 1px solid rgba(89, 79, 63, .2);
    border-radius: 14px;
    padding: 8px;
    background: rgba(255, 250, 240, .96);
    box-shadow: 0 14px 42px rgba(43, 36, 24, .16);
  }

  .mobile-dock button {
    min-width: 0;
    min-height: 48px;
    padding: .45rem .35rem;
    color: var(--ink);
    background: #efe3cc;
    font-size: .86rem;
    line-height: 1.25;
  }

  .mobile-dock button.active {
    color: #fff;
    background: var(--accent);
  }

  .mobile-dock button:hover:not(:disabled) {
    background: #dfcfb4;
  }

  .mobile-dock button.active:hover:not(:disabled) {
    background: var(--accent-strong);
  }

  .mobile-help-button {
    border-radius: 12px;
    color: #fff;
    background: var(--accent);
    font-size: .78rem;
    font-weight: 900;
  }

  .mobile-help-button:hover:not(:disabled) {
    background: var(--accent-strong);
  }

  .mobile-rules-backdrop {
    z-index: 30;
    padding: 10px;
  }

  .mobile-rules-modal {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
    width: min(900px, 96vw);
    height: min(86vh, 430px);
    height: min(86dvh, 430px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    overflow: hidden;
    border-radius: 16px;
    padding: 12px;
  }

  .mobile-rules-scroll {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding-left: 4px;
    direction: rtl;
  }

  .mobile-rules-scroll .rules-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .mobile-rules-scroll .panel {
    padding: 10px;
    box-shadow: none;
  }

  .mobile-rules-scroll h2 {
    margin-bottom: 6px;
    font-size: .95rem;
  }

  .mobile-rules-scroll p {
    font-size: .78rem;
    line-height: 1.75;
  }

  .mobile-tray {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    left: 0;
    display: grid;
    gap: 10px;
    max-height: min(42vh, 265px);
    max-height: min(42dvh, 265px);
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(89, 79, 63, .22);
    border-radius: 14px;
    padding: 12px;
    background: rgba(255, 250, 240, .98);
    box-shadow: 0 20px 60px rgba(28, 25, 20, .24);
  }

  .mobile-tray[hidden],
  .mobile-panel[hidden] {
    display: none;
  }

  .mobile-tray-close {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    color: var(--ink);
    background: #efe3cc;
  }

  .mobile-panel {
    display: grid;
    gap: 10px;
  }

  .mobile-panel[data-mobile-panel="tickets"] {
    gap: 7px;
  }

  .mobile-panel[data-mobile-panel="tickets"] form {
    display: grid;
    gap: 7px;
  }

  .mobile-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding-left: 42px;
  }

  .mobile-panel-head strong {
    font-size: 1rem;
  }

  .mobile-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    color: var(--muted);
    font-size: .82rem;
  }

  .mobile-status-grid span,
  .mobile-cards-grid .card-chip,
  .mobile-compact-list .ticket,
  .mobile-players .player-row {
    min-width: 0;
  }

  .mobile-cards-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .mobile-cards-grid .card-chip {
    padding: .42rem .48rem;
    font-size: .78rem;
  }

  .mobile-face-up {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 0;
  }

  .mobile-face-up .train-card {
    min-height: 44px;
    font-size: .78rem;
  }

  .mobile-compact-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-compact-list .ticket,
  .mobile-compact-list .standing-row {
    padding: 8px;
    font-size: .82rem;
  }

  .mobile-panel[data-mobile-panel="tickets"] .mobile-compact-list {
    justify-content: start;
    gap: 6px;
  }

  .mobile-panel[data-mobile-panel="tickets"] .ticket {
    width: min(100%, 205px);
    min-height: 32px;
    border-radius: 7px;
    padding: 5px 7px;
    font-size: .74rem;
    line-height: 1.2;
  }

  .mobile-panel[data-mobile-panel="tickets"] .selectable .ticket {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 5px;
  }

  .mobile-panel[data-mobile-panel="tickets"] .selectable.mobile-compact-list {
    grid-template-columns: repeat(3, minmax(0, 205px));
  }

  .mobile-panel[data-mobile-panel="tickets"] .ticket span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-panel[data-mobile-panel="tickets"] .ticket input {
    width: 14px;
    height: 14px;
    margin: 0;
  }

  .mobile-panel[data-mobile-panel="tickets"] button[type="submit"] {
    justify-self: end;
    min-height: 36px;
    padding: .42rem .8rem;
  }

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

  .mobile-players .player-row {
    padding: 8px;
    font-size: .82rem;
  }

  .mobile-players .player-row small {
    font-size: .72rem;
  }

  .game-shell > .messages,
  .game-shell > #live-error {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 12;
    width: min(360px, calc(100vw - 20px));
    margin: 0;
    direction: rtl;
  }

  .game-shell > .messages:empty {
    display: none;
  }

  .join-panel {
    position: absolute;
    top: auto;
    right: 50%;
    bottom: 86px;
    z-index: 18;
    width: min(420px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
    transform: translateX(50%);
    border-radius: 18px;
    padding: 12px 16px;
    background:
      radial-gradient(circle at 18% 12%, rgba(20, 108, 104, .12), transparent 28%),
      rgba(255, 250, 240, .97);
    box-shadow: 0 28px 80px rgba(28, 25, 20, .28);
  }

  .join-panel-head {
    gap: 4px;
    margin-bottom: 6px;
    text-align: center;
  }

  .join-panel-kicker {
    display: none;
  }

  .join-panel h1 {
    font-size: 1.34rem;
  }

  .join-game-code {
    justify-self: center;
    padding: .18rem .68rem;
    font-size: .86rem;
  }

  .join-panel-copy {
    display: none;
  }

  .join-panel form {
    gap: 7px;
  }

  .join-panel label {
    gap: .35rem;
    font-size: .88rem;
    text-align: right;
  }

  .join-panel input {
    min-height: 36px;
    border-radius: 11px;
    padding: .52rem .7rem;
    text-align: right;
  }

  .join-panel button {
    min-height: 36px;
    border-radius: 11px;
    padding: .38rem .85rem;
  }

  .modal {
    width: min(430px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow: auto;
  }
}

@media (max-width: 700px) and (orientation: landscape) {
  .game-shell {
    grid-template-rows: minmax(0, 1fr) 62px;
    gap: 6px;
    padding: 6px;
  }

  .join-panel {
    bottom: 74px;
    width: min(400px, calc(100vw - 28px));
    padding: 12px;
  }

  .join-panel-head {
    gap: 3px;
    margin-bottom: 6px;
  }

  .join-panel h1 {
    font-size: 1.34rem;
  }

  .join-game-code {
    padding: .12rem .58rem;
    font-size: .78rem;
  }

  .join-panel form {
    gap: 7px;
  }

  .join-panel label {
    font-size: .8rem;
  }

  .join-panel input,
  .join-panel button {
    min-height: 36px;
    border-radius: 9px;
    padding-block: .38rem;
  }

  .mobile-dock {
    grid-template-columns: repeat(4, minmax(0, 1fr)) 44px;
    gap: 6px;
    padding: 6px;
    border-radius: 12px;
  }

  .mobile-dock button {
    min-height: 44px;
    font-size: .78rem;
  }

  .mobile-help-button {
    font-size: 1rem;
  }

  .mobile-rules-modal {
    width: min(620px, 96vw);
    height: min(84vh, 315px);
    height: min(84dvh, 315px);
    padding: 10px;
  }

  .mobile-rules-scroll .rules-grid {
    gap: 8px;
  }

  .mobile-rules-scroll .panel {
    padding: 8px;
  }

  .mobile-rules-scroll h2 {
    font-size: .86rem;
  }

  .mobile-rules-scroll p {
    font-size: .72rem;
    line-height: 1.6;
  }

  .mobile-tray {
    bottom: calc(100% + 6px);
    max-height: min(46vh, 230px);
    max-height: min(46dvh, 230px);
    padding: 10px;
  }

  .mobile-map-overlays {
    top: 10px;
    right: 10px;
    width: min(190px, 30vw);
    gap: 6px;
  }

  .mobile-map-overlays.secondary {
    top: 52px;
    left: 10px;
  }

  .mobile-map-summary {
    max-height: 102px;
    padding: 7px 8px 7px 28px;
  }

  .mobile-map-summary strong {
    font-size: .72rem;
  }

  .mobile-map-summary li {
    font-size: .66rem;
  }

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

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

  .mobile-compact-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
