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

body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: #0a0e17;
  color: #e0e6ed;
  min-height: 100vh;
  overflow-x: hidden;
}

#hex-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

/* ========== LANDING / SETUP ========== */
.landing {
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 24px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.game-title {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -3px;
  background: linear-gradient(135deg, #74b9ff, #a29bfe, #fd79a8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.landing h1:not(.game-title) {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -2px;
  color: #fff;
  margin-bottom: 4px;
}

.subtitle {
  color: #636e85;
  margin-bottom: 48px;
  font-size: 1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.subtitle strong {
  color: #74b9ff;
  font-family: monospace;
  letter-spacing: 3px;
}

.form-group {
  margin-bottom: 28px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  color: #636e85;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #1e2538;
  border-radius: 10px;
  background: rgba(15, 20, 35, 0.8);
  color: #e0e6ed;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
  backdrop-filter: blur(8px);
}

.form-group input[type="text"]:focus {
  border-color: #74b9ff;
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.color-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(255,255,255,0.15);
}

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 16px rgba(255,255,255,0.3);
}

.color-swatch.taken {
  cursor: not-allowed;
  pointer-events: none;
  border-color: transparent !important;
  position: relative;
  opacity: 0.4;
}

.color-swatch.taken::after {
  content: 'X';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.9);
}

/* Buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 36px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #74b9ff, #5f9df7);
  color: #0a0e17;
}

.btn-accent {
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  color: #fff;
}

.btn-secondary {
  background: rgba(30, 37, 56, 0.8);
  color: #b2bec3;
  border: 1px solid #1e2538;
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}

.btn-large {
  padding: 18px 32px;
  font-size: 1.15rem;
  width: 100%;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  margin-top: 16px;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.add-bot-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.bot-difficulty {
  padding: 8px 10px;
  font-size: 0.85rem;
  background: #1a1f2e;
  color: #e0e6ed;
  border: 1px solid #2d3548;
  border-radius: 6px;
  cursor: pointer;
}

.add-bot-group .btn-small {
  margin-top: 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #3d4560;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #1e2538;
}

.join-group {
  display: flex;
  gap: 8px;
}

.join-group input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid #1e2538;
  border-radius: 10px;
  background: rgba(15, 20, 35, 0.8);
  color: #e0e6ed;
  font-size: 1rem;
  letter-spacing: 3px;
  text-align: center;
  outline: none;
  backdrop-filter: blur(8px);
}

.join-group input:focus {
  border-color: #a29bfe;
}

.error {
  color: #ff6b6b;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Map Size Picker */
.map-size-picker {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-size-picker input[type="range"] {
  flex: 1;
  accent-color: #74b9ff;
}

#setup-map-size-label {
  font-size: 0.85rem;
  color: #636e85;
  min-width: 120px;
}

/* ========== LOBBY ========== */
.lobby-container {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.lobby-sidebar {
  width: 280px;
  background: rgba(12, 16, 28, 0.92);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e2538;
  backdrop-filter: blur(12px);
}

.lobby-sidebar h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
  color: #fff;
}

.lobby-sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3d4560;
  margin-bottom: 12px;
  font-weight: 600;
}

.lobby-sidebar .room-info {
  font-size: 0.85rem;
  color: #636e85;
  margin-bottom: 16px;
  font-family: monospace;
  letter-spacing: 2px;
}

.invite-link-group {
  margin-bottom: 20px;
}

.invite-link-group label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3d4560;
  margin-bottom: 6px;
  font-weight: 600;
}

.invite-copy {
  display: flex;
  gap: 6px;
}

.invite-copy input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #1e2538;
  border-radius: 8px;
  background: rgba(15, 20, 35, 0.6);
  color: #636e85;
  font-size: 0.72rem;
  outline: none;
}

.lobby-sidebar ul {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.lobby-sidebar li {
  padding: 6px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.waiting-text {
  font-size: 0.85rem;
  color: #3d4560;
  margin-top: 12px;
  margin-bottom: 8px;
}

#start-game-btn { margin-top: 12px; margin-bottom: 8px; }
#add-bot-btn { margin-top: 8px; margin-bottom: 0; }

/* Chat */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 23, 0.5);
  position: relative;
  z-index: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.chat-msg {
  margin-bottom: 8px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-author {
  font-weight: 700;
  margin-right: 6px;
}

.chat-system {
  color: #3d4560;
  font-style: italic;
  font-size: 0.8rem;
}

.chat-input-group {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid #1e2538;
}

.chat-input-group input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #1e2538;
  border-radius: 10px;
  background: rgba(15, 20, 35, 0.8);
  color: #e0e6ed;
  font-size: 0.9rem;
  outline: none;
}

.chat-input-group input:focus {
  border-color: #74b9ff;
}

/* ========== GAME ========== */
.game-container {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 220px;
  background: rgba(12, 16, 28, 0.95);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1e2538;
}

.sidebar h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
  color: #fff;
}

.room-info {
  font-size: 0.85rem;
  color: #636e85;
  margin-bottom: 12px;
  font-family: monospace;
  letter-spacing: 2px;
}

.money-display {
  font-size: 1.5rem;
  font-weight: 900;
  color: #ffeaa7;
  margin-bottom: 16px;
  font-family: monospace;
  text-shadow: 0 0 10px rgba(255, 234, 167, 0.3);
}

.earn-rate {
  font-size: 0.8rem;
  color: #00b894;
  font-weight: 600;
}

.sidebar h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3d4560;
  margin-bottom: 12px;
  font-weight: 600;
}

#game-player-list {
  list-style: none;
  flex: 1;
}

#game-player-list li {
  padding: 6px 0;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.admin-panel {
  border-top: 1px solid #1e2538;
  padding-top: 16px;
  margin-top: 16px;
}

.admin-panel h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3d4560;
  margin-bottom: 12px;
}

.admin-badge {
  font-size: 0.6rem;
  background: linear-gradient(135deg, #74b9ff, #5f9df7);
  color: #0a0e17;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}

.admin-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.btn-icon {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e2538;
  color: #636e85;
  transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: #e74c3c;
  color: #fff;
}

/* Map */
.map-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: rgba(10, 14, 23, 0.3);
}

#hex-map {
  width: 90%;
  height: 90%;
  max-width: 900px;
  max-height: 900px;
}

.hex {
  fill: #dfe6e9;
  stroke: #0a0e17;
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.15s, stroke 0.15s, stroke-width 0.15s;
}

.hex:hover {
  stroke: #74b9ff;
  stroke-width: 2.5;
}

.hex-defended {
  stroke: #ffeaa7 !important;
  stroke-width: 3 !important;
}

/* Hex context menu */
.hex-menu {
  position: fixed;
  z-index: 50;
  display: flex;
  gap: 6px;
  transform: translate(-50%, 0);
}

.hex-menu-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, box-shadow 0.2s;
}

.hex-menu-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.hex-menu-earn {
  background: linear-gradient(135deg, #00b894, #00a885);
  color: #fff;
}

.hex-menu-attack {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
}

.hex-menu-defend {
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  color: #0a0e17;
}

.hex-menu-claim {
  background: linear-gradient(135deg, #74b9ff, #5f9df7);
  color: #0a0e17;
}

/* Game Chat Panel */
.chat-panel {
  width: 280px;
  background: rgba(12, 16, 28, 0.95);
  display: flex;
  flex-direction: column;
  border-left: 1px solid #1e2538;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.chat-panel-header h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #3d4560;
  margin: 0;
}

.chat-panel .chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.chat-panel .chat-input-group {
  padding: 12px 16px;
  border-top: 1px solid #1e2538;
}

.show-chat-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #74b9ff, #5f9df7);
  color: #0a0e17;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.15s;
}

.show-chat-btn:hover {
  transform: translateY(-1px);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.3);
  animation: toast-fade 2.5s ease forwards;
}

@keyframes toast-fade {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* Game Over */
.game-over-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(8px);
}

.game-over-box {
  background: rgba(12, 16, 28, 0.95);
  padding: 48px 64px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid #1e2538;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.game-over-box h2 {
  font-size: 2.2rem;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-over-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Mobile toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  z-index: 20;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(30, 37, 56, 0.9);
  color: #e0e6ed;
  backdrop-filter: blur(8px);
}

.mobile-toggle-players {
  top: 12px;
  left: 12px;
}

.sidebar-overlay {
  display: none;
}

/* ========== MOBILE ========== */
/* Mobile money display — only visible on small screens */
.mobile-money {
  display: none;
}

@media (max-width: 640px) {
  /* Landing / Setup */
  .landing {
    padding: 40px 16px;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .landing h1:not(.game-title) {
    font-size: 2.2rem;
  }

  .subtitle {
    margin-bottom: 30px;
    font-size: 0.85rem;
  }

  .form-group {
    margin-bottom: 20px;
  }

  .color-swatch {
    width: 36px;
    height: 36px;
  }

  .color-picker {
    gap: 8px;
    justify-content: center;
  }

  .btn {
    padding: 14px 24px;
  }

  .btn-large {
    padding: 16px 24px;
    font-size: 1.05rem;
  }

  /* Lobby */
  .lobby-container {
    flex-direction: column;
  }

  .lobby-sidebar {
    width: 100%;
    max-height: 40vh;
    overflow-y: auto;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid #1e2538;
  }

  .chat-area {
    flex: 1;
    min-height: 0;
  }

  .invite-copy input {
    font-size: 0.65rem;
  }

  /* Game */
  .game-container {
    flex-direction: column;
    position: relative;
  }

  .game-container .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
  }

  .game-container .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 25;
  }

  .map-area {
    height: 100vh;
    width: 100vw;
  }

  #hex-map {
    width: 98%;
    height: 85%;
  }

  .mobile-toggle {
    display: block;
  }

  /* Floating money on mobile */
  .mobile-money {
    display: block;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 20;
    font-size: 1.2rem;
    font-weight: 900;
    font-family: monospace;
    color: #ffeaa7;
    text-shadow: 0 0 10px rgba(255, 234, 167, 0.4);
    background: rgba(12, 16, 28, 0.85);
    padding: 6px 14px;
    border-radius: 8px;
    backdrop-filter: blur(8px);
    border: 1px solid #1e2538;
  }

  /* Chat panel as bottom sheet */
  .chat-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 40vh;
    z-index: 20;
    border-left: none;
    border-top: 1px solid #1e2538;
  }

  .show-chat-btn {
    bottom: 12px;
    right: 12px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  /* Hex menu — bigger touch targets */
  .hex-menu {
    flex-wrap: wrap;
    max-width: 280px;
    justify-content: center;
  }

  .hex-menu-btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    min-height: 40px;
  }

  /* Game over */
  .game-over-box {
    padding: 32px 28px;
    margin: 0 16px;
  }

  .game-over-box h2 {
    font-size: 1.6rem;
  }
}
