* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden;
  height: 100vh;
}

.screen {
  display: none;
  height: 100vh;
}
.screen.active {
  display: flex;
}

/* Lobby / Login */
.lobby-container {
  margin: auto;
  text-align: center;
  padding: 40px;
}
.lobby-container h1 {
  font-size: 2.5rem;
  margin-bottom: 30px;
  color: #e6a817;
}
.join-card {
  background: #16213e;
  border-radius: 12px;
  padding: 30px;
  min-width: 300px;
  border: 1px solid #333;
  display: inline-block;
  margin-bottom: 20px;
}
.join-card h2 {
  margin-bottom: 15px;
  color: #ccc;
}
.join-card input {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #0f3460;
  color: #fff;
  font-size: 1rem;
}
.error-msg {
  color: #e6194b;
  background: rgba(230, 25, 75, 0.1);
  border: 1px solid #e6194b;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 10px 0;
  font-size: 0.9rem;
}
#lobby-players h3 {
  margin-bottom: 10px;
  color: #aaa;
}
#player-list {
  list-style: none;
}
#player-list li {
  display: inline-block;
  background: #16213e;
  padding: 5px 15px;
  margin: 5px;
  border-radius: 20px;
  border: 1px solid #444;
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #e6a817; color: #1a1a2e; }
.btn-admin { background: #4363d8; color: #fff; }
.btn-danger { background: #e6194b; color: #fff; }
.btn-large { padding: 14px 36px; font-size: 1.1rem; }

/* Game Layout */
.game-layout {
  display: flex;
  width: 100%;
  height: 100vh;
}
.graph-panel {
  flex: 1;
  background: #0f0f23;
  position: relative;
  min-width: 0;
}
.graph-panel svg {
  width: 100%;
  height: 100%;
}
.side-panel {
  width: 380px;
  background: #16213e;
  overflow-y: auto;
  padding: 15px;
  border-left: 2px solid #333;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Player Info */
.player-info {
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}
.money-display {
  font-size: 1.4rem;
  color: #e6a817;
  margin: 5px 0;
}
.round-display, .phase-display {
  color: #888;
  font-size: 0.9rem;
}

/* Panels */
.panel {
  background: #1a1a3e;
  border-radius: 8px;
  padding: 12px;
}
.panel h3 {
  margin-bottom: 8px;
  color: #e6a817;
  font-size: 1rem;
}
.panel h4 {
  margin-bottom: 6px;
  color: #ccc;
  font-size: 0.9rem;
}
.hidden { display: none !important; }

/* Bundles */
.bundle-card {
  background: #0f3460;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #444;
}
.bundle-card h4 {
  color: #e6a817;
  margin-bottom: 6px;
}
.bundle-item {
  font-size: 0.85rem;
  padding: 2px 0;
  color: #ccc;
}
.bundle-item.track-item::before {
  content: '\1F6E4\FE0F ';
}
.bundle-item.contract-item::before {
  content: '\1F4DC ';
}
.bid-input {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bid-input label {
  color: #aaa;
  font-size: 0.85rem;
}
.bid-input input {
  width: 100px;
  padding: 5px 8px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.9rem;
}

/* Contracts */
.contract-card {
  background: #0f3460;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.85rem;
}
.contract-card:hover {
  background: #1a4a8a;
}
.contract-payout {
  color: #4caf50;
  font-weight: 600;
}

/* Results */
.result-item {
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 0.9rem;
}
.result-item.won {
  background: #1b5e20;
  border: 1px solid #4caf50;
}
.result-item.lost {
  background: #333;
  border: 1px solid #555;
}

/* Admin */
.admin-header {
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}
.admin-header h2 {
  color: #4363d8;
}
.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  background: #0f3460;
  font-size: 0.85rem;
}
.player-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.bid-count {
  font-size: 0.8rem;
  color: #888;
}

/* Toll Inputs */
.toll-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #222;
  font-size: 0.85rem;
}
.toll-row input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #fff;
}
.toll-row input:focus {
  border-color: #ffeb3b;
  outline: none;
  box-shadow: 0 0 4px rgba(255, 235, 59, 0.4);
}

/* Route assignment */
.route-contract {
  background: #0f3460;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #444;
}
.route-contract h4 {
  color: #e6a817;
  margin-bottom: 6px;
}
.route-info {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 6px;
}
.route-cost {
  font-weight: 600;
}
.route-cost.profitable { color: #4caf50; }
.route-cost.unprofitable { color: #e6194b; }
.route-path {
  font-size: 0.8rem;
  color: #ccc;
  margin-top: 4px;
}
.route-btn-group {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.route-btn-group .btn {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* SVG Graph */
.city-node {
  cursor: pointer;
}
.city-label {
  font-size: 9px;
  fill: #ccc;
  pointer-events: none;
  text-anchor: middle;
}
.track-line {
  stroke-width: 3;
  cursor: pointer;
}
.track-line.unowned { stroke: #aaa; }
.track-line.other { stroke: #555; }
.track-line.highlight { stroke-width: 5; }
.track-line.editable { cursor: crosshair; }
.track-line.editable:hover { stroke-width: 5; opacity: 0.8; }

/* Admin bundle editor */
.admin-bundle-card {
  background: #0f3460;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid #444;
}
.admin-bundle-card h4 {
  color: #e6a817;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

/* Scrollbar */
.side-panel::-webkit-scrollbar {
  width: 6px;
}
.side-panel::-webkit-scrollbar-track {
  background: #16213e;
}
.side-panel::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

.bid-status {
  background: #1b5e20;
  border: 1px solid #4caf50;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
  margin-bottom: 10px;
}

.hint {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 8px;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #16213e;
  border: 2px solid #e6a817;
  border-radius: 12px;
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-content h2 {
  color: #e6a817;
  margin-bottom: 10px;
  text-align: center;
}
.modal-money {
  text-align: center;
  margin-bottom: 15px;
  font-size: 1.1rem;
}
.modal-content .bundle-card {
  margin-bottom: 12px;
}
.modal-content .btn-large {
  display: block;
  width: 100%;
  margin-top: 15px;
}

/* Notification Toast */
.notification-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #e6a817;
  color: #1a1a2e;
  padding: 12px 30px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.1rem;
  z-index: 2000;
  animation: toastFade 3s ease forwards;
  pointer-events: none;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Trading UI */
.trade-form {
  margin-top: 8px;
}
.trade-form-section {
  margin-bottom: 10px;
}
.trade-form-section label {
  display: block;
  color: #aaa;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.trade-contract-select {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.trade-contract-chip {
  background: #0f3460;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.trade-contract-chip.selected {
  background: #e6a817;
  color: #1a1a2e;
  border-color: #e6a817;
}
.trade-money-input {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.trade-money-input label {
  display: inline;
  white-space: nowrap;
}
.trade-money-input input {
  width: 80px;
  padding: 4px 6px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.85rem;
}
.trade-select {
  width: 100%;
  padding: 6px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #0f3460;
  color: #fff;
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.trade-offer-card {
  background: #0f3460;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
}
.trade-offer-card .trade-from {
  color: #e6a817;
  font-weight: 600;
  margin-bottom: 4px;
}
.trade-offer-card .trade-details {
  font-size: 0.85rem;
  color: #ccc;
  margin-bottom: 6px;
}
.trade-offer-card .trade-actions {
  display: flex;
  gap: 6px;
}
.trade-offer-card .trade-actions .btn {
  padding: 4px 12px;
  font-size: 0.8rem;
}

/* Trade Modal */
.trade-modal-content {
  max-width: 700px;
  width: 95%;
}

/* Leaderboard Table */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 8px;
}
.leaderboard-table th {
  background: #0f3460;
  color: #e6a817;
  padding: 6px 4px;
  text-align: center;
  font-size: 0.75rem;
  white-space: nowrap;
}
.leaderboard-table td {
  padding: 5px 4px;
  text-align: center;
  border-bottom: 1px solid #333;
  font-size: 0.8rem;
}
.leaderboard-table tr:hover {
  background: rgba(255,255,255,0.05);
}

/* Action Log */
.action-log-container {
  max-height: 300px;
  overflow-y: auto;
}
.log-entry {
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid #222;
  color: #ccc;
}
.log-time {
  color: #888;
  font-size: 0.75rem;
  margin-right: 6px;
}

/* Track Halo */
.track-halo {
  pointer-events: none;
}

/* Toll Labels */
.toll-label {
  font-size: 7px;
  fill: #e6a817;
  pointer-events: none;
  font-weight: 600;
}
.toll-label-bg {
  pointer-events: none;
}

/* Leaderboard Modal */
.leaderboard-modal-content {
  max-width: 750px;
  max-height: 80vh;
  overflow-y: auto;
}
.leaderboard-modal-content h2 {
  color: #e6a817;
  margin-bottom: 12px;
}

/* Panel Resizer */
.panel-resizer {
  width: 6px;
  background: #2a2a4a;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.2s;
  position: relative;
  z-index: 10;
}
.panel-resizer:hover, .panel-resizer.dragging {
  background: #e6a817;
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}
.zoom-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #444;
  border-radius: 6px;
  background: rgba(22, 33, 62, 0.9);
  color: #eee;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.zoom-btn:hover {
  background: rgba(230, 168, 23, 0.85);
  border-color: #e6a817;
  color: #1a1a2e;
}
.btn-willing-toggle {
  background: #333;
  color: #aaa;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-willing-toggle:hover {
  background: #444;
}
.btn-willing-toggle.willing-active {
  background: #2e7d32;
  color: #fff;
  border-color: #4caf50;
}
