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

body {
  background: #0a0a0a;
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#game-canvas canvas {
  display: block;
}

/* ── Shared Button Styles ─────────────────── */

.btn-primary, .btn-accent, .btn-secondary {
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  font-weight: bold;
  padding: 14px 36px;
  border: none;
  cursor: pointer;
  letter-spacing: 2px;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary {
  background: transparent;
  color: #00ff88;
  border: 1px solid #00ff8866;
}
.btn-primary:hover {
  background: rgba(0, 255, 136, 0.1);
  border-color: #00ff88;
}

.btn-accent {
  background: #00ff88;
  color: #0a0a0a;
}
.btn-accent:hover {
  background: #44ffaa;
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: #666;
  border: 1px solid #333;
  font-size: 13px;
  padding: 10px 24px;
}
.btn-secondary:hover {
  color: #aaa;
  border-color: #666;
}

/* ── Title Screen ─────────────────────────── */

#title-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#title-logo {
  max-width: 320px;
  margin-bottom: 16px;
}

.title-tagline {
  color: #00ff8888;
  font-size: 14px;
  letter-spacing: 3px;
  margin-bottom: 48px;
}

.title-buttons {
  display: flex;
  gap: 20px;
}

/* ── Rules Screen ─────────────────────────── */

#rules-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0a0a0a;
  z-index: 150;
  overflow-y: auto;
}

.rules-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.rules-container h1 {
  font-size: 28px;
  color: #ffcc00;
  letter-spacing: 6px;
  margin-bottom: 36px;
  text-align: center;
}

.rules-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid #1a1a1a;
}

.rules-section:last-of-type {
  border-bottom: none;
}

.rules-section h2 {
  font-size: 14px;
  color: #00ff88;
  letter-spacing: 3px;
  margin-bottom: 12px;
}

.rules-section p {
  color: #b0b0b0;
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 8px;
}

.rules-section strong {
  color: #e0e0e0;
}

.rules-section ul {
  list-style: none;
  padding: 0;
}

.rules-section ul li {
  color: #b0b0b0;
  font-size: 14px;
  line-height: 1.8;
  padding-left: 20px;
  position: relative;
}

.rules-section ul li::before {
  content: '>';
  position: absolute;
  left: 0;
  color: #00ff8866;
}

.rules-tip {
  color: #ffcc00 !important;
  font-size: 13px !important;
  padding: 8px 12px;
  background: rgba(255, 204, 0, 0.06);
  border-left: 2px solid #ffcc0066;
  margin-top: 8px;
}

.text-yellow { color: #ffcc00; }
.text-blue { color: #4488ff; }
.text-red { color: #ff6644; }

#btn-back-to-title {
  display: block;
  margin: 36px auto 0;
}

/* ── Matchmaking Screen ───────────────────── */

#matchmaking-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#matchmaking-logo {
  max-width: 200px;
  margin-bottom: 24px;
  opacity: 0.6;
}

#matchmaking-status {
  font-size: 18px;
  color: #00ff88;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

#matchmaking-timer {
  font-size: 48px;
  font-weight: bold;
  color: #00ff8844;
  margin-bottom: 24px;
}

#matchmaking-players {
  font-size: 14px;
  color: #aaaaaa;
  text-align: center;
  line-height: 2;
  margin-bottom: 32px;
  min-height: 80px;
}

.lobby-player {
  color: #4488ff;
}

.lobby-player.bot {
  color: #ff6644;
}

#btn-launch-bots {
  margin-bottom: 16px;
}

/* ── HUD Overlay ──────────────────────────── */

#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}

#hud.hidden {
  display: none;
}

.hud-panel {
  pointer-events: auto;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid #00ff8844;
  padding: 12px 16px;
  font-size: 13px;
}

.hud-label {
  font-size: 10px;
  color: #00ff8866;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

/* Net Worth - Top Left */
.top-left {
  position: absolute;
  top: 16px;
  left: 16px;
  min-width: 200px;
}

.hud-value {
  font-size: 24px;
  font-weight: bold;
  color: #00ff88;
  margin-bottom: 8px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  margin: 2px 0;
}

.cash-label, .cash-value { color: #44ff88; }
.asset-label, .asset-value { color: #4488ff; }

/* Timer - Top Right */
.top-right {
  position: absolute;
  top: 16px;
  right: 16px;
  text-align: center;
}

.timer-value {
  font-size: 36px;
  font-weight: bold;
  color: #00ff88;
  letter-spacing: 4px;
}

.timer-value.urgent {
  color: #ff4444;
  animation: pulse-red 1s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Hint Banner - Top Center */
.top-center {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  max-width: 400px;
  font-size: 13px;
  color: #ffcc00;
  border-color: #ffcc0044;
  transition: opacity 0.5s;
}

.top-center.fade-out {
  opacity: 0;
}

/* Bid Terminal - Bottom Center */
.bottom-center {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 560px;
  padding: 20px 24px;
  border: 2px solid #ffcc0088;
  background: rgba(10, 10, 10, 0.95);
  box-shadow: 0 0 30px rgba(255, 204, 0, 0.15);
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 16px;
}

.terminal-title {
  color: #ffcc00;
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 16px;
}

#bid-parcel-info { color: #aaaaaa; font-size: 14px; }
#bid-timer { color: #ffcc00; font-weight: bold; font-size: 18px; }

.terminal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bid-quick-pct {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#bid-terminal .pct-btn {
  background: transparent !important;
  border: 1px solid #00ff8844;
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: bold;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s, border-color 0.15s;
}

#bid-terminal .pct-btn:hover {
  background: rgba(0, 255, 136, 0.15) !important;
  border-color: #00ff88;
}

#bid-terminal .pct-btn:active {
  background: rgba(0, 255, 136, 0.3) !important;
}

.terminal-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt { color: #00ff88; font-size: 20px; }

#bid-input {
  flex: 1;
  background: #1a1a1a;
  border: 2px solid #00ff8844;
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  font-size: 22px;
  padding: 12px 16px;
  outline: none;
  min-height: 48px;
}

#bid-input:focus { border-color: #00ff88; }
#bid-input::placeholder { color: #00ff8844; }

#bid-submit {
  background: #00ff88;
  color: #0a0a0a;
  border: none;
  padding: 12px 24px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  min-height: 48px;
}

#bid-submit:hover { background: #44ffaa; }
#bid-submit:active { background: #00cc66; }

/* Event Log - Bottom Right */
.bottom-right {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 350px;
  max-height: 250px;
}

#log-entries {
  max-height: 200px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
  color: #aaaaaa;
}

#log-entries::-webkit-scrollbar { width: 4px; }
#log-entries::-webkit-scrollbar-track { background: transparent; }
#log-entries::-webkit-scrollbar-thumb { background: #00ff8844; }

.log-entry { border-bottom: 1px solid #ffffff08; padding: 2px 0; }
.log-entry .log-time { color: #00ff8866; }
.log-entry.penalty { color: #ff6644; }
.log-entry.purchase { color: #4488ff; }
.log-entry.auction { color: #ffcc00; }

/* ── Leaderboard Screen ───────────────────── */

#leaderboard-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10, 10, 10, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#leaderboard-screen h1 {
  font-size: 36px;
  color: #ffcc00;
  letter-spacing: 6px;
  margin-bottom: 32px;
}

#leaderboard-list { width: 500px; max-width: 90vw; }

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #ffffff11;
  font-size: 16px;
  color: #aaaaaa;
}

.leaderboard-entry:first-child {
  color: #ffcc00;
  font-size: 20px;
  font-weight: bold;
  border: 1px solid #ffcc0044;
  background: rgba(255, 204, 0, 0.05);
}

.leaderboard-entry .rank { width: 30px; color: #00ff8866; }
.leaderboard-entry .name { flex: 1; }
.leaderboard-entry .worth { text-align: right; min-width: 120px; }

/* ── Utility ──────────────────────────────── */

.hidden { display: none !important; }

#bid-input::-webkit-outer-spin-button,
#bid-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#bid-input[type=number] { -moz-appearance: textfield; }

/* ── Animations ───────────────────────────── */

@keyframes bid-flash {
  0% { background: rgba(0, 255, 136, 0.15); }
  100% { background: transparent; }
}

@keyframes penalty-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.flash-bid { animation: bid-flash 0.5s ease-out; }
.shake-penalty { animation: penalty-shake 0.5s ease-out; }

/* Scanline overlay */
#hud::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0, 255, 136, 0.008) 2px,
    rgba(0, 255, 136, 0.008) 4px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  .title-buttons { flex-direction: column; gap: 12px; }
  .bottom-center { min-width: 90vw; }
  .bottom-right { width: 280px; }
}

.next-up {
  position: absolute;
  top: 120px;
  right: 16px;
  text-align: center;
  font-size: 13px;
}
#next-parcel-info { color: #aaaaaa; }

.upgrade-panel {
  position: absolute;
  bottom: 16px;
  left: 16px;
  min-width: 220px;
}
#upgrade-btn, #sell-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: transparent;
  border: 1px solid #00ff8844;
  color: #00ff88;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: 6px;
  cursor: pointer;
  letter-spacing: 1px;
}
#upgrade-btn:hover { background: rgba(0,255,136,0.1); border-color: #00ff88; }
#sell-btn { border-color: #ffcc0044; color: #ffcc00; }
#sell-btn:hover { background: rgba(255,204,0,0.1); border-color: #ffcc00; }

.sell-terminal {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 320px;
}

.player-sidebar {
  position: absolute;
  top: 120px;
  left: 16px;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
}
.player-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid #ffffff08;
  font-size: 12px;
  gap: 8px;
}
.player-row.is-me { color: #4488ff; }
.player-row .p-cash { color: #44ff88; font-size: 11px; }
.player-row .p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.buyout-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 320px;
  text-align: center;
  border-color: #ffcc0088;
  z-index: 50;
}

.view-toggle-btn {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 110px;
  background: rgba(10,10,10,0.85);
  border: 1px solid #00ff8844;
  color: #00ff8888;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: 6px 16px;
  cursor: pointer;
  letter-spacing: 2px;
  pointer-events: auto;
  z-index: 30;
}
.view-toggle-btn:hover { border-color: #00ff88; color: #00ff88; }
.view-toggle-btn.active { background: rgba(0,255,136,0.15); color: #00ff88; border-color: #00ff88; }
#grid-2d {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 5;
  background: #0a0a0a;
}
.buyout-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
#buyout-details { color: #e0e0e0; margin: 8px 0; font-size: 14px; }
#buyout-timer-display { color: #ffcc00; font-size: 12px; }
