/* styles/ui.css */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;  /* 🚫 disables scrollbars */
    font-family: 'Silkscreen', cursive;
  }

/* Container around the whole app */
#app {
    position: relative;
    width: 1240px;          /* = CANVAS_W = MAP_W (1000) + SIDEBAR_W (240) */
    margin: 20px auto 20px 40px;  /* min 80px left margin prevents overlap with vertical title */
  }

  #toolbar {
    position: absolute;
    top: 0px;
    right: 300px;

    display: flex;
    flex-direction: column;   /* stack rows: input, then button row */
    gap: 10px;

    background: rgba(255,255,255,0.9);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    z-index: 10;
  }

  #toolbar-top-row {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  #toolbar textarea {
    width: 240px;
    min-height: 50px;     /* starting height */
    font-size: 14px;
    padding: 6px 8px;
    resize: none;         /* prevent manual resize (optional) */
    overflow: hidden;     /* hide scrollbars while it grows */
    box-sizing: border-box;
    font-family: 'Silkscreen', cursive;
  }

  #toolbar textarea::placeholder {
    font-size: 14px;
  }
  
  /* Button row */
  #button-row {
    display: flex;
    gap: 8px;              /* space between Start and Reset */
  }
  
  #button-row button {
    flex: 1;               /* make both buttons equal width */
    padding: 8px;
    margin: 1.5px;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Silkscreen', cursive;
  }

/* Map Selector Dropdown */
#map-selector {
  flex: 1;
  padding: 5px 8px;
  margin-top: 0px;
  font-family: 'Silkscreen', cursive;
  font-size: 12px;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

#map-selector:hover {
  border-color: #999;
}

#map-selector:focus {
  outline: none;
  border-color: #4CAF50;
}

/* Leaderboard */
#leaderboard {
  position: absolute;
  top: 250px;  /* Position 5px below toolbar */
  right: 300px;

  background: rgba(255, 255, 255, 0.95);
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  z-index: 10;
  width: 304px;
  box-sizing: border-box;
  font-family: 'Silkscreen', cursive;
}

#leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 6px;
}

#leaderboard-title {
  font-size: 14px;
  font-weight: bold;
}

#copy-leaderboard-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background-color 0.2s;
  position: relative;
  top: -5px;
}

#copy-leaderboard-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

#copy-toast {
  position: absolute;
  top: 40px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: bold;
  z-index: 1000;
  pointer-events: none;
  animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; }
}

#leaderboard-list {
  font-size: 14px;
  line-height: 19px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-height: 420px;
}

#leaderboard-list div {
  padding: 2px 0;
  color: #333;
  flex: 0 0 auto;
  width: calc(50% - 6px);
  display: flex;
  align-items: center;
}

#leaderboard-list .name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

#leaderboard-list div.finished {
  color: #000;
  font-weight: bold;
}

#leaderboard-list .checkmark {
  color: #00aa00;
  margin-left: 4px;
  font-weight: bold;
  flex: 0 0 auto;
}

/* Canvas Cursor Hover */
canvas {
    cursor: grab; /* looks like a hand */
    touch-action: none; /* Prevent scrolling/gestures on canvas only */
}

canvas:active {
    cursor: grabbing; /* looks like you're dragging */
}

/* Suggestion Button (Higher up at bottom-left) */
#suggest-btn {
  position: fixed;
  bottom: 70px;
  left: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-family: 'Silkscreen', cursive;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 999;
  transition: all 0.3s ease;
}

#suggest-btn:hover {
  background-color: #45a049;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

#suggest-btn:active {
  transform: translateY(0px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* What's New Button (Below Suggest Button) */
#making-of-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-family: 'Silkscreen', cursive;
  background-color: #757575;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 999;
  transition: all 0.3s ease;
}

#making-of-btn:hover {
  background-color: #616161;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

#making-of-btn:active {
  transform: translateY(0px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Config Button (In top row with map selector) */
#config-btn {
  position: static;
  width: 24px;
  height: 24px;
  font-size: 20px;
  font-family: 'Silkscreen', cursive;
  background-color: transparent;
  color: #333;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

#config-btn:hover {
  transform: scale(1.15);
}

#config-btn:active {
  transform: scale(1.05);
}

/* Config Modal Specific Styles */
.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

#gravity-slider {
  flex: 1;
}

#gravity-value {
  min-width: 40px;
  font-weight: bold;
  color: #333;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

#slowmo-toggle {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

#reset-config {
  padding: 10px;
  font-size: 14px;
  background-color: #FF9800;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Silkscreen', cursive;
  margin-top: 10px;
  transition: background-color 0.3s ease;
}

#reset-config:hover {
  background-color: #F57C00;
}

#reset-config:active {
  background-color: #E65100;
}

/* Suggestion Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  font-family: 'Silkscreen', cursive;
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 20px;
  border: 2px solid #888;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

.close:hover,
.close:focus {
  color: #000;
}

.modal-content h2 {
  margin-top: 0;
  font-size: 20px;
  font-family: 'Silkscreen', cursive;
}

#suggestion-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#suggestion-form label {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: -8px;
}

#suggestion-form input,
#suggestion-form textarea {
  padding: 8px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: 'Silkscreen', cursive;
}

#suggestion-form textarea {
  min-height: 120px;
  resize: vertical;
}

#submit-suggestion {
  padding: 10px;
  font-size: 14px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Silkscreen', cursive;
}

#submit-suggestion:hover {
  background-color: #45a049;
}

#submit-suggestion:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

#form-status {
  font-size: 12px;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  display: none;
}

#form-status.success {
  display: block;
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

#form-status.error {
  display: block;
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Debug Overlay */
#debug-overlay {
  position: fixed;
  bottom: 10px;
  right: 10px;

  background: transparent;
  padding: 12px;
  z-index: 10;
  font-family: 'Silkscreen', cursive;
  font-size: 14px;
  line-height: 20px;
  text-align: right;
}

#debug-overlay div {
  color: white;
}

/* Making of Modal - Dev Log Content */
#devlog-content {
  font-family: 'Silkscreen', cursive;
  line-height: 1.6;
}

#devlog-content h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #333;
  font-size: 16px;
}

#devlog-content h4 {
  margin-top: 20px;
  margin-bottom: 10px;
  color: #555;
  font-size: 14px;
}

#devlog-content p {
  margin-bottom: 15px;
  color: #666;
  font-size: 12px;
}

#devlog-content ul {
  margin: 10px 0;
  padding-left: 20px;
}

#devlog-content li {
  margin-bottom: 8px;
  color: #666;
  font-size: 12px;
}

#devlog-content strong {
  color: #333;
}

/* Final Ranking Modal */
.final-ranking-content {
  max-width: 900px;
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.final-ranking-body {
  display: flex;
  gap: 24px;
  margin-bottom: 15px;
}

.final-ranking-left {
  flex: 1;
  min-width: 300px;
  position: relative;
}

.final-ranking-right {
  flex-shrink: 0;
  width: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.final-ranking-right h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  color: #333;
}

.final-ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.final-ranking-header h2 {
  margin: 0;
}

#copy-ranking-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background-color 0.2s;
  position: relative;
  top: -5px;
}

#copy-ranking-btn:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

#copy-ranking-toast {
  position: absolute;
  top: 40px;
  right: 10px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: bold;
  z-index: 1000;
  pointer-events: none;
  animation: fadeInOut 2s ease-in-out;
}

#final-ranking-list {
  max-height: 450px;
  overflow-y: auto;
  margin: 10px 0;
  padding: 10px 20px;
  background-color: #f9f9f9;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
  list-style: none;
}

#final-ranking-list li {
  padding: 4px 0;
  color: #333;
}

/* Two-column layout when .two-column class is added */
#final-ranking-list.two-column {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 4px 12px;
  max-height: 480px;
}

#final-ranking-list.two-column li {
  flex: 0 0 auto;
  width: calc(50% - 6px);
  display: flex;
  align-items: center;
}

.final-ranking-buttons {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.final-ranking-buttons button {
  flex: 1;
  padding: 10px;
  font-size: 14px;
  font-family: 'Silkscreen', cursive;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

#close-ranking-btn {
  background-color: #757575;
  color: white;
}

#close-ranking-btn:hover {
  background-color: #616161;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#race-again-btn {
  background-color: #4CAF50;
  color: white;
}

#race-again-btn:hover {
  background-color: #45a049;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.final-ranking-buttons button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.share-video-btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-family: 'Silkscreen', cursive;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.share-video-btn:hover {
  background-color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.share-video-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

/* Video Loading Spinner */
.video-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 200px;
}

.video-loading-spinner .spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.video-loading-spinner p {
  font-family: 'Silkscreen', cursive;
  font-size: 12px;
  color: #666;
  margin: 0;
}

/* Help Text */
.help-text {
  font-size: 11px;
  color: #666;
  margin-top: -8px;
  margin-bottom: 12px;
  font-family: 'Silkscreen', cursive;
}


.recording-modal-buttons button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}