* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #1c2844;
  color: #eef1f7;
  min-width: 1200px;
}

.desktop-only-banner {
  display: none;
  background: #ffc107;
  color: #111;
  text-align: center;
  padding: 8px;
  font-size: 14px;
}

@media (max-width: 1199px) {
  .desktop-only-banner {
    display: block;
  }
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #2a3d5c;
  border-bottom: 1px solid #3d5278;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #ffd54f;
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #b0bdd4;
}

.stats {
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat .label {
  font-size: 0.75rem;
  color: #b0bdd4;
  text-transform: uppercase;
}

.stat .value {
  font-size: 1.25rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 0;
  height: calc(100vh - 88px);
  min-height: 640px;
}

.map-container {
  position: relative;
  background: #3d5278;
  min-height: 640px;
  overflow: hidden;
}

.city-hover-card {
  position: absolute;
  z-index: 20;
  width: min(340px, calc(100% - 24px));
  background: rgba(20, 26, 42, 0.96);
  border: 1px solid #4a6288;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: #eef1f7;
  pointer-events: auto;
  backdrop-filter: blur(6px);
}

.city-hover-card[hidden] {
  display: none;
}

.city-hover-card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #2d3a52;
}

.city-hover-card header h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #ffd54f;
}

.hover-country {
  font-size: 0.72rem;
  color: #9aa8c7;
}

.hover-body {
  padding: 10px 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  max-height: min(260px, 42vh);
  overflow-y: auto;
}

.hover-tech-section {
  margin: 8px 0 10px;
  padding: 8px 10px;
  background: rgba(100, 181, 246, 0.08);
  border: 1px solid rgba(100, 181, 246, 0.2);
  border-radius: 6px;
}

.hover-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64b5f6;
  font-weight: 700;
  margin-bottom: 6px;
}

.hover-tech-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.8rem;
}

.hover-tech-row span {
  color: #9aa8c7;
}

.hover-tech-row strong {
  text-align: right;
  color: #eef1f7;
  font-size: 0.78rem;
}

.hover-tech-label {
  margin: 8px 0 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9aa8c7;
}

.hover-tech-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.76rem;
  color: #b0bdd4;
  line-height: 1.45;
}

.hover-tech-list.sellers li {
  margin-bottom: 2px;
}

.hover-patent-yours {
  color: #a5d6a7;
}

.hover-patent-yours em {
  color: #9aa8c7;
  font-style: normal;
  font-size: 0.72rem;
}

.hover-patent-risk {
  color: #ffb74d;
}

.hover-tech-block {
  margin: 0 0 6px;
  font-size: 0.76rem;
  color: #ef9a9a;
}

.hover-tech-muted {
  margin: 0;
  font-size: 0.76rem;
  color: #9aa8c7;
}

.hover-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin: 8px 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
}

.hover-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hover-stat span {
  font-size: 0.68rem;
  color: #9aa8c7;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hover-stat strong {
  font-size: 0.82rem;
}

.hover-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 4px;
}

.hover-badge.empty {
  background: rgba(128, 203, 196, 0.18);
  color: #80cbc4;
}

.hover-badge.contested {
  background: rgba(255, 204, 188, 0.15);
  color: #ffccbc;
}

.hover-badge.owned {
  background: rgba(165, 214, 167, 0.15);
  color: #a5d6a7;
}

.competition-low { color: #a5d6a7; }
.competition-medium { color: #ffe082; }
.competition-high { color: #ffab91; }
.competition-intense { color: #ef5350; }

.hover-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
  border-top: 1px solid #2d3a52;
}

.hover-actions .btn {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.hover-hint {
  font-size: 0.72rem;
  color: #9aa8c7;
  margin: 0;
}

.attack-options {
  display: flex;
  flex-direction: row;
  gap: 4px;
}

.attack-option {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #1a2438;
  border: 1px solid #2d3a52;
  border-radius: 6px;
  padding: 6px 4px;
  cursor: pointer;
  text-align: center;
  color: #eef1f7;
  transition: border-color 0.15s, background 0.15s;
}

.attack-option:hover:not(:disabled) {
  border-color: #5a7298;
  background: #22304a;
}

.attack-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.attack-option-recommended {
  border-color: #ffd54f;
  box-shadow: 0 0 0 1px rgba(255, 213, 79, 0.25);
}

.attack-tier {
  font-weight: 700;
  font-size: 0.72rem;
  color: #ffd54f;
  line-height: 1.2;
}

.attack-meta {
  font-size: 0.66rem;
  color: #b0bdd4;
  line-height: 1.2;
  white-space: nowrap;
}

.attack-pay {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attack-pay.pay-cash {
  background: rgba(165, 214, 167, 0.15);
  color: #a5d6a7;
}

.attack-pay.pay-loan {
  background: rgba(255, 183, 77, 0.15);
  color: #ffcc80;
}

.attack-pay.pay-blocked {
  background: rgba(239, 83, 80, 0.12);
  color: #ef9a9a;
}

.attack-cost {
  font-size: 0.82rem;
  color: #eef1f7;
}

.attack-sales {
  font-size: 0.75rem;
  color: #a5d6a7;
}

.attack-outcome {
  font-size: 0.75rem;
  color: #80cbc4;
}

.pay-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 2px 0;
}

.pay-badge.pay-cash {
  background: rgba(165, 214, 167, 0.15);
  color: #a5d6a7;
  border: 1px solid rgba(165, 214, 167, 0.35);
}

.pay-badge.pay-loan {
  background: rgba(255, 183, 77, 0.15);
  color: #ffcc80;
  border: 1px solid rgba(255, 183, 77, 0.4);
}

.pay-badge.pay-blocked {
  background: rgba(239, 83, 80, 0.12);
  color: #ef9a9a;
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.facility-btn {
  text-align: left;
  line-height: 1.5;
}

.attack-finance {
  font-size: 0.72rem;
  color: #9aa8c7;
  margin-top: 2px;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.sidebar {
  padding: 16px;
  background: linear-gradient(180deg, #141a2e 0%, #101524 100%);
  border-left: 1px solid #2a3548;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.player-card {
  background: #1e2a42;
  border: 1px solid #334766;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.player-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.player-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.player-card-cash {
  font-weight: 700;
  font-size: 1rem;
  color: #a5d6a7;
}

.player-card-stats {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.75rem;
  color: #b0bdd4;
}

.player-card-stats strong {
  color: #eef1f7;
  font-size: 0.85rem;
}

.sidebar-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: #0c1019;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #252f42;
}

.sidebar-tabs .tab {
  flex: 1 1 calc(33% - 4px);
  min-width: 0;
  border: none;
  background: transparent;
  color: #8b9bb8;
  padding: 7px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.72rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-tabs .tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
  color: #c5cfe0;
}

.sidebar-tabs .tab.active {
  background: #2a3d5c;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px;
}

.panel[hidden] {
  display: none;
}

.panel-title {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9aa8c7;
  font-weight: 600;
}

.action-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #1a2438;
  border: 1px solid #2d3a52;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.84rem;
  cursor: pointer;
  text-align: left;
  color: #eef1f7;
  transition: border-color 0.15s, background 0.15s;
}

.menu-item:hover:not(:disabled) {
  border-color: #4a6288;
  background: #22304a;
}

.menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.menu-item-label {
  font-weight: 600;
}

.menu-item-meta {
  font-size: 0.72rem;
  color: #9aa8c7;
  white-space: nowrap;
}

.menu-item-meta.affordable {
  color: #a5d6a7;
}

.menu-item-meta.expensive {
  color: #ffccbc;
}

.menu-item-meta.tag-empty {
  color: #80cbc4;
}

.finance-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #2d3a52;
}

.finance-actions .btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.alert {
  background: rgba(229, 57, 53, 0.12);
  border: 1px solid rgba(229, 57, 53, 0.4);
  color: #ffcbc4;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
}

.finance-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  color: #b0bdd4;
  padding-bottom: 8px;
  border-bottom: 1px solid #3d5278;
}

.finance-row strong {
  color: #eef1f7;
  font-size: 0.92rem;
}

.finance-row strong.positive {
  color: #a5d6a7;
}

.finance-row.total strong {
  color: #ffccbc;
}

.finance-note {
  margin-top: auto;
}

.empire-summary {
  background: #1a2438;
  border: 1px solid #2d3a52;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #c5cfe0;
  line-height: 1.5;
}

.empire-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empire-list h4 {
  margin: 8px 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa8c7;
  font-weight: 600;
}

.empire-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a2438;
  border: 1px solid #2d3a52;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.84rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.empire-item:hover {
  border-color: #4a6288;
  background: #22304a;
}

.empire-item .tag {
  font-size: 0.72rem;
  color: #b0bdd4;
}

.turn-status {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1a2438;
  border: 1px solid #2d3a52;
  color: #b0bdd4;
}

.turn-status.human {
  border-color: #ffd54f;
  color: #ffd54f;
  background: rgba(255, 213, 79, 0.08);
}

.turn-status.ai {
  border-color: #ab47bc;
  color: #ce93d8;
  background: rgba(171, 71, 188, 0.1);
}

.message {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #d5deed;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.84rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.help {
  font-size: 0.78rem;
  color: #9aa8c7;
  line-height: 1.5;
  margin-top: auto;
}

.patent-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #3d5278;
}

.patent-form h4 {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa8c7;
  font-weight: 600;
}

.patent-form .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: #b0bdd4;
}

.patent-form select {
  background: #1c2844;
  border: 1px solid #3d5278;
  border-radius: 6px;
  color: #eef1f7;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.patent-preview {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: #b0bdd4;
  background: #2f4668;
  border-radius: 6px;
  padding: 8px 10px;
}

.patent-preview strong {
  color: #eef1f7;
}

.patent-item {
  cursor: default;
}

.patent-item:hover {
  border-color: transparent;
  background: #2f4668;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.tech-tag {
  font-size: 0.72rem;
  background: #243656;
  border: 1px solid #3d5278;
  border-radius: 999px;
  padding: 3px 10px;
  color: #c5d0e6;
}

.legal-block {
  margin: 12px 0;
  padding-top: 10px;
  border-top: 1px solid #3d5278;
}

.legal-block h4 {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9aa8c7;
  font-weight: 600;
}

.legal-hint {
  margin: 0 0 8px;
  font-size: 0.75rem;
}

.badge {
  color: #ffb74d;
  font-weight: 700;
}

.legal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legal-card {
  background: #243656;
  border: 1px solid #3d5278;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.8rem;
}

.alert-card {
  border-left: 3px solid #ffb74d;
}

.lawsuit-card {
  border-left: 3px solid #ef5350;
}

.legal-meta {
  font-weight: 700;
  color: #eef1f7;
  margin-bottom: 6px;
}

.legal-claim,
.legal-app,
.legal-harm {
  margin: 4px 0;
  color: #b0bdd4;
  line-height: 1.4;
}

.claim-preview {
  font-size: 0.78rem;
  color: #9aa8c7;
  font-style: italic;
  margin: 0;
  line-height: 1.4;
}

.claim-line {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: #9aa8c7;
  line-height: 1.35;
}

.verdict {
  margin: 6px 0 0;
  color: #81c784;
  font-weight: 600;
}

.research-offer {
  text-align: left;
  width: 100%;
}

.research-offer small {
  color: #9aa8c7;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.legal-actions {
  margin-top: 8px;
}

.pending-item {
  border-left: 3px solid #64b5f6;
}

.tech-map {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tech-country {
  background: #243656;
  border: 1px solid #3d5278;
  border-radius: 8px;
  padding: 8px 10px;
}

.tech-country.blocked {
  border-color: #ef5350;
  opacity: 0.85;
}

.tech-country-name {
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 6px;
  color: #eef1f7;
}

.tech-city-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: #b0bdd4;
  line-height: 1.5;
}

.tech-block-note {
  font-size: 0.75rem;
  color: #ef9a9a;
  margin: 0 0 6px;
}

.defense-card {
  border-left: 3px solid #ef5350;
}

.patent-item.granted {
  opacity: 0.85;
}

.patent-item.rejected {
  opacity: 0.6;
}

.sidebar .panel {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: #ffd54f;
  color: #1a1a1a;
}

.btn.primary:hover:not(:disabled) {
  background: #ffca28;
}

.btn.secondary {
  background: #3d5278;
  color: #eef1f7;
}

.btn.secondary:hover:not(:disabled) {
  background: #4a6288;
}

.btn.accent {
  background: #9c27b0;
  color: #fff;
}

.btn.accent:hover:not(:disabled) {
  background: #ab47bc;
}

.btn.accent.mandatory {
  background: #e65100;
}

.btn.full {
  width: 100%;
}

.city-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #2f4668;
  border: 1px solid #4a6288;
  border-radius: 12px;
  padding: 0;
  min-width: 320px;
  max-width: 420px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  color: #eef1f7;
}

.city-popup[hidden] {
  display: none;
}

.city-popup header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #3d5278;
}

.city-popup header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #b0bdd4;
  font-size: 1.2rem;
  cursor: pointer;
}

.popup-body {
  padding: 16px 20px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.popup-body .hint {
  color: #b0bdd4;
  font-size: 0.85rem;
}

.city-popup footer,
.popup-actions {
  padding: 16px 20px;
  border-top: 1px solid #3d5278;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.city-popup footer .btn,
.popup-actions .btn {
  width: 100%;
}
