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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
  color: #e0e0e0;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100vw;
  height: 100vh;
}

/* Screen Management */
.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Lobby Screen */
.lobby-container {
  background: rgba(30, 35, 60, 0.9);
  border: 2px solid #4a5578;
  border-radius: 12px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.lobby-container h1 {
  text-align: center;
  color: #64b5f6;
  margin-bottom: 30px;
  font-size: 3em;
  text-shadow: 0 0 20px rgba(100, 181, 246, 0.5);
}

.lobby-container h2 {
  color: #90caf9;
  margin: 20px 0 15px 0;
  font-size: 1.5em;
}

#join-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

input[type="text"] {
  padding: 12px;
  border: 2px solid #4a5578;
  border-radius: 6px;
  background: rgba(20, 25, 45, 0.8);
  color: #e0e0e0;
  font-size: 16px;
}

input[type="text"]:focus {
  outline: none;
  border-color: #64b5f6;
}

button {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%);
  color: white;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(100, 181, 246, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#player-list {
  background: rgba(20, 25, 45, 0.6);
  border-radius: 6px;
  padding: 15px;
  margin: 10px 0;
}

.player-item {
  display: flex;
  align-items: center;
  padding: 8px;
  margin: 5px 0;
}

.player-color {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-right: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.player-name {
  font-size: 1.1em;
}

/* Game Layout */
.game-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  grid-template-rows: 1fr;
  width: 100%;
  height: 100%;
  gap: 10px;
  padding: 10px;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
}

.panel {
  background: rgba(30, 35, 60, 0.9);
  border: 2px solid #4a5578;
  border-radius: 8px;
  padding: 15px;
}

.panel h3 {
  color: #64b5f6;
  margin-bottom: 10px;
  font-size: 1.2em;
  border-bottom: 1px solid #4a5578;
  padding-bottom: 8px;
}

/* Resources Display */
.resource-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 1.05em;
}

.resource-label {
  color: #b0b0b0;
}

/* Game Board */
.game-board {
  position: relative;
  background: rgba(10, 14, 39, 0.8);
  border: 2px solid #4a5578;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#turn-indicator {
  background: rgba(100, 181, 246, 0.2);
  padding: 12px;
  text-align: center;
  border-bottom: 2px solid #4a5578;
}

#current-player-name {
  font-size: 1.3em;
  font-weight: bold;
  color: #64b5f6;
  margin-right: 15px;
}

#turn-phase {
  color: #90caf9;
  font-size: 1.1em;
}

#hex-canvas {
  flex: 1;
  width: 100%;
  cursor: pointer;
  min-height: 0;
}

/* Tile HUD */
#tile-hud {
  position: absolute;
  bottom: 80px;
  left: 20px;
  background: rgba(20, 25, 45, 0.95);
  border: 2px solid #64b5f6;
  border-radius: 8px;
  padding: 15px;
  min-width: 250px;
  max-width: 350px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 100;
  pointer-events: none;
}

#tile-hud-content {
  color: #e0e0e0;
}

.hud-title {
  font-size: 1.2em;
  font-weight: bold;
  color: #64b5f6;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #4a5578;
}

.hud-section {
  margin: 8px 0;
}

.hud-label {
  color: #90caf9;
  font-weight: bold;
  font-size: 0.9em;
  margin-bottom: 4px;
}

.hud-value {
  color: #e0e0e0;
  margin-left: 8px;
}

.hud-resource-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.hud-resource-badge {
  background: rgba(100, 181, 246, 0.2);
  border: 1px solid #64b5f6;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85em;
  color: #64b5f6;
}

.hud-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
  margin-left: 8px;
}

.hud-status-uncolonized {
  background: rgba(76, 175, 80, 0.2);
  color: #66bb6a;
  border: 1px solid #66bb6a;
}

.hud-status-colonized {
  background: rgba(255, 152, 0, 0.2);
  color: #ffa726;
  border: 1px solid #ffa726;
}

.hud-status-enemy {
  background: rgba(244, 67, 54, 0.2);
  color: #ef5350;
  border: 1px solid #ef5350;
}

.hud-cost {
  color: #ffd54f;
  font-weight: bold;
}

/* Debug Menu */
#debug-menu {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 200;
}

#debug-toggle {
  width: 40px;
  height: 40px;
  background: rgba(244, 67, 54, 0.9);
  border: 2px solid #f44336;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5em;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

#debug-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
}

#debug-panel {
  position: absolute;
  top: 50px;
  right: 0;
  background: rgba(20, 25, 45, 0.98);
  border: 2px solid #f44336;
  border-radius: 8px;
  padding: 15px;
  min-width: 200px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

#debug-panel h3 {
  color: #f44336;
  margin: 0 0 12px 0;
  font-size: 1.1em;
  border-bottom: 1px solid #f44336;
  padding-bottom: 8px;
}

#debug-panel button {
  width: 100%;
  margin: 6px 0;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#debug-panel button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

#debug-panel button:active {
  transform: translateY(0);
}

#action-buttons {
  display: flex;
  gap: 10px;
  padding: 15px;
  background: rgba(30, 35, 60, 0.8);
  border-top: 2px solid #4a5578;
  justify-content: center;
  flex-shrink: 0;
  min-height: 60px;
}

#action-buttons button {
  flex: 1;
  max-width: 200px;
}

/* Contracts Display */
.contract-item {
  background: rgba(20, 25, 45, 0.6);
  border: 1px solid #4a5578;
  border-radius: 6px;
  padding: 10px;
  margin: 8px 0;
  cursor: pointer;
  transition: background 0.2s;
}

.contract-item:hover {
  background: rgba(30, 35, 60, 0.8);
}

.mission-contract {
  border-left: 3px solid #66bb6a;
  background: rgba(102, 187, 106, 0.1);
}

.mission-partner-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mission-partner-section label {
  display: block;
  font-size: 0.9em;
  margin-bottom: 5px;
  color: #b0b0b0;
}

.mission-partner-select {
  width: 100%;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #ffffff;
  font-size: 0.9em;
  cursor: pointer;
}

.mission-partner-select:hover {
  border-color: rgba(102, 187, 106, 0.5);
}

.mission-partner-select:focus {
  outline: none;
  border-color: #66bb6a;
}

.complete-mission-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: #66bb6a;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
}

.complete-mission-btn:hover {
  background: #57a65a;
}

.complete-mission-btn:active {
  background: #4a8f4d;
}

.contract-type {
  font-weight: bold;
  color: #64b5f6;
  margin-bottom: 5px;
  text-transform: uppercase;
  font-size: 0.9em;
}

.contract-description {
  font-size: 0.95em;
  line-height: 1.4;
}

/* Game Log */
#game-log {
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.9em;
}

.log-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(74, 85, 120, 0.3);
  color: #b0b0b0;
}

.log-entry:last-child {
  border-bottom: none;
}

/* Players Display */
#players-display .player-item {
  background: rgba(20, 25, 45, 0.4);
  border-radius: 6px;
  margin: 8px 0;
}

.player-vp {
  margin-left: auto;
  font-weight: bold;
  color: #ffd54f;
}

/* Winner Screen */
.winner-container {
  background: rgba(30, 35, 60, 0.95);
  border: 3px solid #64b5f6;
  border-radius: 12px;
  padding: 50px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(100, 181, 246, 0.4);
}

.winner-container h1 {
  color: #ffd54f;
  font-size: 3em;
  margin-bottom: 20px;
  text-shadow: 0 0 30px rgba(255, 213, 79, 0.6);
}

.winner-container h2 {
  color: #64b5f6;
  font-size: 2em;
  margin-bottom: 30px;
}

#final-scores {
  margin: 30px 0;
  text-align: left;
}

.score-item {
  padding: 12px;
  margin: 8px 0;
  background: rgba(20, 25, 45, 0.6);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: rgba(30, 35, 60, 0.98);
  border: 2px solid #64b5f6;
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal h2 {
  color: #64b5f6;
  margin-bottom: 20px;
  text-align: center;
}

.modal-content {
  background: rgba(30, 35, 60, 0.98);
  border: 2px solid #64b5f6;
  border-radius: 12px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
  color: #64b5f6;
  margin-bottom: 20px;
}

#modal-body {
  margin: 20px 0;
  line-height: 1.6;
}

/* Station Modal */
.station-section {
  background: rgba(20, 25, 45, 0.6);
  border: 1px solid #4a5578;
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
}

.station-section h3 {
  color: #90caf9;
  margin-bottom: 10px;
  font-size: 1.1em;
}

.station-section p {
  color: #b0b0b0;
  margin-bottom: 12px;
  font-size: 0.95em;
}

.trade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.trade-row label {
  min-width: 80px;
  color: #b0b0b0;
}

.trade-row select {
  flex: 1;
  padding: 8px;
  border: 2px solid #4a5578;
  border-radius: 6px;
  background: rgba(20, 25, 45, 0.8);
  color: #e0e0e0;
  font-size: 14px;
}

.trade-row select:focus {
  outline: none;
  border-color: #64b5f6;
}

.action-btn {
  width: 100%;
  padding: 10px;
  margin-top: 10px;
  background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(100, 181, 246, 0.4);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.close-btn {
  width: 100%;
  padding: 10px;
  margin-top: 20px;
  background: rgba(100, 100, 100, 0.3);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.close-btn:hover {
  background: rgba(120, 120, 120, 0.4);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(20, 25, 45, 0.4);
}

::-webkit-scrollbar-thumb {
  background: #4a5578;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64b5f6;
}

/* Score Tracker Screen */
.score-tracker-container {
  width: 100%;
  max-width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.score-tracker-container h1 {
  text-align: center;
  color: #64b5f6;
  margin-bottom: 10px;
  font-size: 1.5em;
  text-shadow: 0 0 20px rgba(100, 181, 246, 0.5);
}

#score-tracker-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 10px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.score-tracker-card {
  background: rgba(30, 35, 60, 0.9);
  border: 2px solid #4a5578;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-tracker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid #4a5578;
  gap: 8px;
}

.score-tracker-name {
  color: #64b5f6;
  font-size: 1.1em;
  margin: 0;
  font-weight: bold;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-tracker-vp {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 213, 79, 0.1);
  border: 1px solid #ffd54f;
  border-radius: 6px;
  padding: 4px 8px;
  flex-shrink: 0;
}

.vp-label {
  font-weight: bold;
  color: #ffd54f;
  font-size: 0.9em;
}

.vp-value {
  font-weight: bold;
  font-size: 1.1em;
  color: #ffd54f;
  min-width: 24px;
  text-align: center;
}

.vp-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.vp-btn.plus {
  background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
  color: white;
}

.vp-btn.minus {
  background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
  color: white;
}

.vp-btn:active {
  transform: scale(0.9);
}

.score-tracker-resources {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.resource-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: rgba(20, 25, 45, 0.6);
  border-radius: 5px;
  border: 1px solid rgba(74, 85, 120, 0.3);
}

.resource-name {
  color: #90caf9;
  font-weight: 600;
  font-size: 0.9em;
  min-width: 50px;
}

.resource-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.resource-value {
  font-weight: bold;
  font-size: 1em;
  color: #e0e0e0;
  min-width: 24px;
  text-align: center;
}

.resource-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.resource-btn.plus {
  background: linear-gradient(135deg, #64b5f6 0%, #42a5f5 100%);
  color: white;
}

.resource-btn.minus {
  background: linear-gradient(135deg, #78909c 0%, #607d8b 100%);
  color: white;
}

.resource-btn:active {
  transform: scale(0.9);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
  .score-tracker-container {
    padding: 8px;
  }

  .score-tracker-container h1 {
    font-size: 1.3em;
    margin-bottom: 8px;
  }

  #score-tracker-players {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 8px;
  }

  .score-tracker-card {
    padding: 8px;
    gap: 6px;
  }

  .score-tracker-header {
    padding-bottom: 6px;
  }

  .score-tracker-name {
    font-size: 1em;
  }

  .vp-label {
    font-size: 0.85em;
  }

  .vp-value {
    font-size: 1em;
    min-width: 20px;
  }

  .vp-btn {
    width: 26px;
    height: 26px;
    font-size: 1em;
  }

  .resource-row {
    padding: 4px 6px;
    gap: 4px;
  }

  .resource-name {
    min-width: 45px;
    font-size: 0.85em;
  }

  .resource-value {
    font-size: 0.95em;
    min-width: 20px;
  }

  .resource-controls {
    gap: 6px;
  }

  .resource-btn {
    width: 26px;
    height: 26px;
    font-size: 0.95em;
  }
}

@media (max-width: 480px) {
  .score-tracker-container {
    padding: 6px;
  }

  .score-tracker-container h1 {
    font-size: 1.2em;
    margin-bottom: 6px;
  }

  #score-tracker-players {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .score-tracker-card {
    padding: 8px;
  }

  .score-tracker-vp {
    padding: 3px 6px;
    gap: 5px;
  }

  .resource-row {
    padding: 3px 6px;
  }
}

/* Very compact for small screens showing 2 columns */
@media (min-width: 481px) and (max-width: 768px) {
  #score-tracker-players {
    grid-template-columns: repeat(2, 1fr);
  }
}
