* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Arial, sans-serif;
  background: #111827;
  color: #f9fafb;
}

body {
  display: flex;
  flex-direction: column;
  touch-action: none;
}

.topbar {
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: #1f2937;
  border-bottom: 1px solid #374151;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
}

.topbar h1 span {
  color: #9ca3af;
  font-size: 14px;
}

.subtitle {
  color: #9ca3af;
  font-size: 11px;
  margin-top: 3px;
}

.stats {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 12px;
  white-space: nowrap;
}

.sidebar {
  width: 310px;
  flex-shrink: 0;
  padding: 14px;
  overflow-y: auto;
  background: #17202d;
  border-right: 1px solid #374151;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.toolbar {
  display: grid;
  gap: 7px;
}

.tool {
  width: 100%;
  padding: 9px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #202b3a;
  color: #fff;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}

.tool:hover,
.tool.active {
  background: #374151;
  border-color: #6b7280;
}

.tool small {
  float: right;
  color: #d1d5db;
}

.rotate-road {
  color: #bfdbfe;
}

.panel {
  margin-top: 12px;
  padding: 12px;
  background: #202b3a;
  border: 1px solid #374151;
  border-radius: 10px;
}

.panel h2 {
  margin: 0 0 9px;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
}

.panel-button,
.danger-button {
  width: 100%;
  margin-top: 9px;
  padding: 9px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  color: white;
  background: #2563eb;
}

.danger-button {
  background: #991b1b;
}

.danger-button:hover {
  background: #b91c1c;
}

.demand-row {
  margin: 8px 0;
  font-size: 11px;
}

.bar {
  height: 7px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #111827;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: #60a5fa;
  transition: width 0.2s ease;
}

.warning {
  margin-top: 12px;
  padding: 9px;
  border-radius: 8px;
  background: #5b3a08;
  color: #fde68a;
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.message {
  min-height: 17px;
  margin-top: 10px;
  color: #93c5fd;
  font-size: 11px;
}

.game-area {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #78a85a;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.save-slot {
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid #374151;
  border-radius: 7px;
  background: #17202d;
  font-size: 10px;
}

.save-slot-title {
  font-weight: bold;
  margin-bottom: 4px;
}

.save-slot-info {
  color: #9ca3af;
  margin-bottom: 6px;
}

.slot-buttons {
  display: flex;
  gap: 5px;
}

.slot-buttons button {
  flex: 1;
  padding: 5px;
  border: 0;
  border-radius: 5px;
  background: #374151;
  color: white;
  cursor: pointer;
  font-size: 10px;
}

.slot-buttons button:hover {
  background: #4b5563;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  background: rgba(0, 0, 0, 0.65);
}

.modal-box {
  width: min(500px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid #4b5563;
  border-radius: 12px;
  background: #1f2937;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
}

.modal-header button {
  border: 0;
  background: transparent;
  color: white;
  font-size: 25px;
  cursor: pointer;
}

.bank-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 15px 0;
}

.bank-info div {
  padding: 10px;
  border-radius: 8px;
  background: #111827;
}

.bank-info span {
  display: block;
  color: #9ca3af;
  font-size: 10px;
}

.bank-info strong {
  display: block;
  margin-top: 5px;
}

.modal-box h3 {
  font-size: 13px;
  margin-top: 18px;
}

.loan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.loan-button {
  padding: 11px;
  border: 1px solid #374151;
  border-radius: 8px;
  background: #263448;
  color: white;
  cursor: pointer;
}

.loan-button:hover {
  background: #374151;
}

.loan-button small {
  display: block;
  margin-top: 3px;
  color: #9ca3af;
}

.loan-info {
  margin-top: 12px;
  padding: 9px;
  border-radius: 7px;
  background: #111827;
  color: #d1d5db;
  font-size: 11px;
}

.loan-card {
  margin-top: 8px;
  padding: 9px;
  border-radius: 8px;
  background: #111827;
  font-size: 11px;
}

.loan-card strong {
  display: block;
  margin-bottom: 5px;
}

@media (max-width: 700px) {

  .topbar {
    height: 56px;
    padding: 0 8px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .topbar h1 span {
    font-size: 11px;
  }

  .subtitle {
    font-size: 8px;
  }

  .stats {
    gap: 6px;
    font-size: 9px;
  }

  .stats div:nth-child(2),
  .stats div:nth-child(3),
  .stats div:nth-child(4) {
    display: none;
  }

  main {
    display: block;
  }

  .sidebar {
    position: absolute;
    z-index: 10;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 43%;
    padding: 7px;
    border-right: 0;
    border-top: 1px solid #374151;
    background: rgba(23, 32, 45, 0.97);
  }

  .sidebar > h2,
  .panel {
    display: none;
  }

  .toolbar {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .tool {
    min-height: 41px;
    padding: 5px 2px;
    text-align: center;
    font-size: 9px;
  }

  .tool small {
    display: block;
    float: none;
    margin-top: 2px;
    font-size: 7px;
  }

  .rotate-road {
    grid-column: span 2;
  }

  .message {
    margin: 4px 0 0;
    text-align: center;
  }
}