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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  color: #e0e0e0;
}

/* Lobby Styles */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 3rem;
  color: #f0f0f0;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
  margin-bottom: 0.5rem;
}

.logo-hex {
  display: inline-block;
  background: #d4dbe3;
  padding: 30px;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  margin-bottom: 0.5rem;
}

header .logo {
  max-width: 350px;
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 520px) {
  .logo-hex {
    padding: 20px;
    max-width: 85vw;
  }

  header .logo {
    max-width: 100%;
  }
}

.subtitle {
  color: #888;
  font-size: 1.1rem;
}

.lobby {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
}

.card h2 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
  color: #fff;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: #aaa;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.3);
}

.form-group select {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  cursor: pointer;
}

/* Visually mask password fields while preventing autofill */
#gamePassword, #joinPassword {
  -webkit-text-security: disc;
  text-security: disc;
}

.form-group .hint {
  display: block;
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.3rem;
}

/* Checkbox styling */
.checkbox-group {
  margin-top: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  color: #e0e0e0;
  font-size: 1rem;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
  accent-color: #3498db;
}

.help-text {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.3rem;
  margin-left: 26px;
}

.btn {
  width: 100%;
  padding: 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
}

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

.btn.primary {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn.primary:hover {
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.5);
}

.btn.secondary {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

.btn.secondary:hover {
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.5);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: #666;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
  padding: 0 1rem;
}

.error-message {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid #e74c3c;
  border-radius: 8px;
  padding: 1rem;
  color: #e74c3c;
  text-align: center;
  display: none;
}

.error-message.visible {
  display: block;
}

/* Form row for side-by-side inputs */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Advanced Options Collapsible */
.advanced-options {
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.advanced-options summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: #aaa;
  font-size: 0.9rem;
  background: rgba(0, 0, 0, 0.2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.advanced-options summary::-webkit-details-marker {
  display: none;
}

.advanced-options summary::before {
  content: '▶';
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.advanced-options[open] summary::before {
  transform: rotate(90deg);
}

.advanced-options summary:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
}

.advanced-options-content {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.1);
}

.advanced-options-content .form-group:last-child {
  margin-bottom: 0;
}

/* Game List Styles */
.game-list {
  max-height: 300px;
  overflow-y: auto;
}

.game-list-empty {
  text-align: center;
  color: #888;
  padding: 1rem;
}

.game-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.2s;
}

.game-list-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.game-list-item.clickable {
  cursor: pointer;
}

.game-list-item.clickable:hover {
  background: rgba(255, 255, 255, 0.1);
}

.game-list-item.has-password {
  border-left: 3px solid #f39c12;
}

.game-info {
  flex: 1;
}

.game-name {
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.25rem;
}

.game-details {
  font-size: 0.8rem;
  color: #888;
}

.game-details span {
  margin-right: 0.75rem;
}

.game-join-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s;
}

.game-join-btn:hover {
  transform: scale(1.05);
}

/* Password modal */
.password-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.password-modal-content {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 300px;
  width: 90%;
}

.password-modal h3 {
  margin-bottom: 1rem;
  color: #fff;
}

.password-modal .form-group {
  margin-bottom: 1rem;
}

.password-modal-buttons {
  display: flex;
  gap: 0.5rem;
}

.password-modal-buttons .btn {
  flex: 1;
  padding: 0.6rem;
}

footer {
  text-align: center;
  margin-top: 2rem;
  color: #aaa;
  font-size: 0.9rem;
}

.version-info {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: #888;
  font-family: monospace;
}

/* Game Page Styles */
.game-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.game-sidebar {
  width: 280px;
  background: rgba(0, 0, 0, 0.5);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.game-info {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1rem;
}

.game-info h3 {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.game-code {
  font-size: 1.8rem;
  font-family: monospace;
  color: #fff;
  letter-spacing: 4px;
}

.game-name-display {
  font-size: 1.2rem;
  color: #fff;
  word-break: break-word;
}

.turn-indicator {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.turn-indicator.my-turn {
  background: rgba(52, 152, 219, 0.2);
  border: 1px solid #3498db;
}

.turn-indicator.spectating {
  background: rgba(136, 136, 136, 0.2);
  border: 1px solid #666;
}

.turn-timer {
  font-size: 2rem;
  font-weight: bold;
  color: #fff;
}

.turn-timer.warning {
  color: #f39c12;
}

.turn-timer.critical {
  color: #e74c3c;
  animation: pulse 0.5s infinite;
}

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

/* Turn notification border flash */
.turn-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
  border: 6px solid #3498db;
  box-shadow: inset 0 0 30px rgba(52, 152, 219, 0.5);
  animation: borderFlash 0.4s ease-in-out 3;
}

@keyframes borderFlash {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.current-player {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.mobile-turn-name {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-list {
  flex: 1;
  overflow-y: auto;
}

.player-list h3 {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  margin-bottom: 0.3rem;
}

.player-item.current {
  background: rgba(255, 255, 255, 0.1);
}

.player-item.eliminated {
  opacity: 0.5;
  text-decoration: line-through;
}

.player-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.player-name {
  flex: 1;
}

.player-you {
  font-size: 0.8rem;
  color: #888;
}

.game-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.game-controls .btn {
  padding: 0.6rem;
  font-size: 0.9rem;
}

.game-menu-container {
  position: relative;
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  padding: 10px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.hamburger-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

.game-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #1e1e2e;
  border: 1px solid #3a3a4a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.game-menu.visible {
  display: block;
}

.game-menu-item {
  display: block;
  width: 100%;
  padding: 0.7rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.game-menu-item:hover {
  background: #2a2a3e;
}

.game-menu-item:active {
  background: #3a3a4e;
}

.game-menu-divider {
  height: 1px;
  background: #3a3a4a;
  margin: 0.25rem 0;
}

#resignBtn {
  color: #e74c3c;
}

#resignBtn:hover {
  background: #3e2020;
}

.btn.start {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

.game-canvas {
  flex: 1;
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

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

.controls-hint {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  background: rgba(0, 0, 0, 0.6);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #888;
}

/* View Toggle */
.view-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  overflow: hidden;
}

.view-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.view-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.view-btn.active {
  background: rgba(52, 152, 219, 0.5);
  color: #fff;
}

/* Waiting Overlay */
.waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.waiting-content {
  text-align: center;
  padding: 2rem;
}

.waiting-content h2 {
  margin-bottom: 1rem;
}

.waiting-game-name {
  font-size: 1.5rem;
  color: #3498db;
  margin-bottom: 1rem;
  font-weight: 600;
}

.waiting-code {
  font-size: 3rem;
  font-family: monospace;
  color: #3498db;
  letter-spacing: 8px;
  margin-bottom: 1rem;
}

.waiting-hint {
  color: #888;
  margin-bottom: 1.5rem;
}

/* Notifications */
.notification {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  padding: 1rem 1.5rem;
  animation: slideIn 0.3s ease-out;
  z-index: 200;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.info {
  border-left: 4px solid #3498db;
}

.notification.success {
  border-left: 4px solid #2ecc71;
}

.notification.warning {
  border-left: 4px solid #f39c12;
}

.notification.error {
  border-left: 4px solid #e74c3c;
}

/* Game Over Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
}

.modal h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* Loading Modal */
.loading-modal {
  padding: 2.5rem 3rem;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #4a9eff;
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.9);
}

.winner-name {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Game Over Banner */
.game-over-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  z-index: 300;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.game-over-text {
  font-size: 1.5rem;
  font-weight: bold;
}

.game-over-banner .btn {
  width: auto;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Disconnect Banner */
.disconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(135deg, #4a3a1a, #3e3216);
  border-bottom: 2px solid rgba(243, 156, 18, 0.5);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  z-index: 400;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.disconnect-text {
  font-size: 1.2rem;
  font-weight: bold;
  color: #f39c12;
}

.disconnect-banner .btn {
  width: auto;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn.warning {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
}

.btn.warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
  .game-container {
    flex-direction: column;
  }

  .game-sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    padding: 0.4rem;
    gap: 0.4rem;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .game-sidebar h3 {
    display: none;
  }

  .game-info {
    padding: 0.3rem 0.5rem;
    background: transparent;
  }

  .game-name-display {
    font-size: 0.85rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .turn-indicator {
    padding: 0.3rem 0.5rem;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .turn-indicator .turn-timer {
    font-size: 1.2rem;
  }

  .turn-indicator .current-player {
    display: none;
  }

  .turn-indicator .mobile-turn-name {
    display: block;
  }

  .resources-display {
    padding: 0.3rem 0.5rem;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }

  .resources-display .resources-value {
    font-size: 1rem;
  }

  .resources-display .resources-value::before {
    content: '⭐';
    margin-right: 0.2rem;
    font-size: 0.8rem;
  }

  .resources-display .resources-hint {
    display: none;
  }

  .player-list {
    display: none;
  }

  .game-controls {
    flex-direction: row;
    margin-left: auto;
  }

  .game-controls .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .game-controls .btn.start {
    display: none;
  }

  .controls-hint {
    display: none;
  }

  .hamburger-btn {
    width: 40px;
    height: 40px;
    padding: 8px;
  }

  .hamburger-btn span {
    width: 18px;
  }

  .game-menu {
    min-width: 140px;
    right: 0;
    left: auto;
    bottom: auto;
    top: 100%;
    margin-bottom: 0;
    margin-top: 0.5rem;
  }

  .game-menu-item {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
  }
}

/* Placement Menu */
.placement-menu {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  z-index: 400;
  min-width: 200px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.placement-title {
  font-size: 1rem;
  color: #fff;
  margin-bottom: 1rem;
  text-align: center;
}

.placement-btn {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 1.4rem;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols", "Apple Color Emoji", serif;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: rgba(52, 152, 219, 0.3);
  color: #fff;
  transition: background 0.2s;
}

.placement-btn:hover {
  background: rgba(52, 152, 219, 0.5);
}

.placement-btn.cancel {
  background: rgba(231, 76, 60, 0.3);
  margin-top: 0.5rem;
}

.placement-btn.cancel:hover {
  background: rgba(231, 76, 60, 0.5);
}

/* Resources Display */
.resources-display {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.resources-display h3 {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.resources-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: #f39c12;
}

.resources-hint {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.3rem;
}

/* Pause Modal */
.pause-modal {
  min-width: 300px;
}

.pause-modal h2 {
  color: #f39c12;
}

.paused-by {
  color: #888;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.pause-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pause-buttons .btn {
  width: 100%;
}

/* Paused timer state */
.turn-timer.paused {
  color: #f39c12;
  animation: none;
}

/* Lobby Background Scene */
#bgCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}

