:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-border: #2d3a4f;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #6cb6ff;
  --danger: #ff6b6b;
  --shadow: rgba(0, 0, 0, 0.45);
  --header-h: 44px;
  --top-bar-h: 48px;
  /* jeden řádek spodního panelu + rezerva pro Leaflet attribution */
  --news-bar-h: 44px;
  font-family: system-ui, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#map-root {
  position: fixed;
  inset: 0;
  z-index: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(15, 20, 25, 0.92), rgba(15, 20, 25, 0.55));
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.brand {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.game-menu-wrap {
  position: relative;
}

.game-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 248px;
  padding: 6px 0;
  z-index: 5600;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 12px 36px var(--shadow);
}

.game-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.game-menu-item:hover,
.game-menu-item:focus-visible {
  background: rgba(108, 182, 255, 0.12);
  outline: none;
}

.game-menu-sep {
  margin: 6px 0;
  border: none;
  border-top: 1px solid var(--panel-border);
}

.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-ghost {
  background: transparent;
}

.hint {
  position: fixed;
  top: calc(var(--top-bar-h) + 8px);
  left: 12px;
  right: 12px;
  z-index: 4000;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  max-width: 52ch;
  pointer-events: none;
  text-shadow: 0 1px 2px var(--shadow);
}

#windows-layer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
}

#windows-layer > * {
  pointer-events: auto;
}

.te-window {
  position: absolute;
  min-width: 220px;
  min-height: 140px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - var(--top-bar-h) - var(--news-bar-h) - 24px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 12px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
}

.te-window.is-minimized .te-body {
  display: none;
}

.te-window.is-minimized {
  min-height: 0;
  height: auto !important;
  resize: none;
}

.te-window.is-maximized {
  resize: none;
  border-radius: 6px;
  left: 8px !important;
  top: calc(var(--top-bar-h) + 8px) !important;
  width: calc(100vw - 16px) !important;
  height: calc(100vh - var(--top-bar-h) - var(--news-bar-h) - 16px) !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

.te-header {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: linear-gradient(180deg, #222c3d, #1a2332);
  border-bottom: 1px solid var(--panel-border);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.te-header:active {
  cursor: grabbing;
}

.te-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.te-header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--panel-border);
}

.icon-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
}

.te-body {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-size: 13px;
  color: var(--text);
}

.te-body p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.mock-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.mock-table th,
.mock-table td {
  border: 1px solid var(--panel-border);
  padding: 6px 8px;
  text-align: left;
}

.mock-table th {
  background: rgba(108, 182, 255, 0.08);
  color: var(--accent);
  font-weight: 600;
}

.leaflet-control-attribution {
  font-size: 11px;
  background: rgba(15, 20, 25, 0.75) !important;
  color: var(--muted) !important;
  max-width: min(420px, 55vw);
  white-space: normal;
  line-height: 1.25;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

/* Zoom vlevo dole, nad informačním panelem */
.leaflet-bottom.leaflet-left .leaflet-control {
  margin-bottom: calc(var(--news-bar-h) + 8px + env(safe-area-inset-bottom, 0px));
  margin-left: max(8px, env(safe-area-inset-left, 0px));
}

.leaflet-bottom.leaflet-right .leaflet-control-attribution {
  margin-bottom: calc(var(--news-bar-h) + 6px + env(safe-area-inset-bottom, 0px));
  margin-right: max(8px, env(safe-area-inset-right, 0px));
}

.leaflet-top.leaflet-right {
  top: calc(var(--top-bar-h) + 8px);
}

.leaflet-top.leaflet-right .leaflet-control {
  margin-top: 0;
}

/* Spodní panel: datum | zpráva | peníze */
.world-news-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 450;
  height: var(--news-bar-h);
  min-height: var(--news-bar-h);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 0 max(12px, env(safe-area-inset-left, 0px)) max(0px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-right, 0px));
  background: linear-gradient(0deg, rgba(15, 20, 25, 0.98), rgba(26, 35, 50, 0.95));
  border-top: 1px solid var(--panel-border);
  box-shadow: 0 -4px 20px var(--shadow);
  pointer-events: auto;
}

.status-date {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.status-money {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #8ce99a;
  white-space: nowrap;
}

.status-news-trigger {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(108, 182, 255, 0.08);
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-news-trigger:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(108, 182, 255, 0.14);
}

.status-news-trigger:disabled,
.status-news-trigger.is-empty {
  cursor: default;
  color: var(--muted);
  background: rgba(15, 20, 25, 0.4);
}

/* Detail zprávy – výsuv zdola */
.news-detail {
  position: fixed;
  inset: 0;
  z-index: 3500;
  pointer-events: none;
  visibility: hidden;
}

.news-detail.is-open {
  pointer-events: auto;
  visibility: visible;
}

.news-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.news-detail.is-open .news-detail-backdrop {
  opacity: 1;
}

.news-detail-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(72vh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -12px 40px var(--shadow);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.news-detail.is-open .news-detail-sheet {
  transform: translateY(0);
}

.news-detail-header {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 10px;
  padding: 14px 12px 10px 16px;
  border-bottom: 1px solid var(--panel-border);
}

.news-detail-tag {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 2px 10px;
}

.news-detail-close {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  width: 32px;
  height: 32px;
  font-size: 20px;
}

.news-detail-headline {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.news-detail-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  -webkit-overflow-scrolling: touch;
}

.news-detail-footer {
  flex: 0 0 auto;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--panel-border);
}

.news-detail-footer .btn {
  width: 100%;
}

/* Leaflet vlastní markery provozoven */
.leaflet-marker-icon.te-marker {
  border: none !important;
  background: transparent !important;
}

/* Kontextové menu mapy (pravý klik / long-press): backdrop + panel */
.map-ctx-backdrop {
  position: fixed;
  inset: 0;
  z-index: 7000;
  background: rgba(10, 14, 20, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.map-ctx-backdrop.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.map-ctx-menu {
  position: fixed;
  z-index: 7010;
  min-width: 220px;
  padding: 6px 0;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 8px 28px var(--shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease, visibility 0.1s ease;
}

.map-ctx-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.map-ctx-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.map-ctx-menu__item:hover,
.map-ctx-menu__item:focus {
  background: rgba(108, 182, 255, 0.12);
  outline: none;
}

.map-ctx-menu__hint {
  padding: 6px 14px 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  border-top: 1px solid var(--panel-border);
  margin-top: 4px;
}

/* --- Přihlášení / obrazovka hry --- */
.is-hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 48px;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #1e2d42 0%, var(--bg) 62%);
  z-index: 12000;
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 28px 24px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: 0 16px 48px var(--shadow);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 650;
}

.auth-lead {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-msg {
  min-height: 1.25em;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--danger);
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.auth-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.auth-tab.is-active {
  background: rgba(108, 182, 255, 0.18);
  color: var(--text);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.auth-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: #0f1419;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.auth-submit {
  margin-top: 4px;
  width: 100%;
}

.auth-divider {
  text-align: center;
  margin: 20px 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.auth-spectator {
  width: 100%;
}

.screen-app {
  position: relative;
  width: 100%;
  height: 100%;
}

.session-badge {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

body.is-spectator #btn-logout {
  display: none !important;
}

body.is-spectator .is-player-only {
  display: none !important;
}

body:not(.is-spectator) #btn-auth-back {
  display: none !important;
}

/* Úzká obrazovka / telefon: větší tlačítka, bez ručního roztahování oken, kratší nápověda přes třídu z JS */
body.is-narrow .hint {
  display: none;
}

body.is-narrow .te-body {
  -webkit-overflow-scrolling: touch;
}

body.is-narrow .te-window {
  min-width: min(220px, 100vw - 24px);
  resize: none;
}

body.is-narrow .icon-btn {
  min-width: 36px;
  min-height: 36px;
}

body.is-narrow .top-bar {
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  padding-top: max(0px, env(safe-area-inset-top, 0px));
}

body.is-narrow .top-actions {
  gap: 6px;
}

body.is-narrow .top-actions .btn {
  padding: 8px 10px;
  font-size: 12px;
}

body.is-narrow .session-badge {
  font-size: 11px;
  max-width: min(38vw, 140px);
}
