/* === Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* === Map Container === */
#map {
  height: 100%;
  width: 100%;
  background-color: #e8f5e9;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  opacity: 0.4;
}

/* === Bottom Controls Container === */
#bottom-controls {
  position: fixed;
  bottom: 30px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  z-index: 1000;
  pointer-events: none;
}

/* Individual floating pills – shared styles */
.bottom-panel {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 183, 77, 0.5);
  border-radius: 20px;
  padding: 12px 16px;
  min-width: 80px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #fff;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.bottom-panel:active {
  transform: scale(0.95);
}

/* Amber panel specific */
#amber-panel {
  gap: 2px;
  border: 2px solid rgba(255, 183, 77, 0.5);
  background: rgba(0, 0, 0, 0.75);
  font-family: inherit;
}

/* Amber icon styling */
.bb-icon {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 2px;
}

/* Value text (number) */
.bb-value {
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

/* Label text */
.bb-label {
  font-size: 0.6em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-top: 2px;
}

/* === Combined Distance + Pause Panel === */
#distance-pause-panel {
  flex-direction: row;
  align-items: center;
  gap: 0;
  padding: 12px 12px;
  min-width: auto;
  min-height: 64px;
  cursor: default;
}

#distance-pause-panel:active {
  transform: none;
}

/* Distance button (tappable for stats) */
.distance-button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0 8px 0 0;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 80px;
}

.distance-button:active {
  opacity: 0.7;
}

.distance-button .bb-value {
  font-size: 1.8em;
  font-weight: 700;
}

.distance-button .bb-label {
  font-size: 0.6em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
  margin-top: 2px;
}

/* Split line */
.split-line {
  width: 0;
  height: 32px;
  border-left: 2px dashed rgba(255, 255, 255, 0.7);
  align-self: center;
  margin: 0 4px;
}

/* Pause button area */
.pause-button {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-button:active {
  opacity: 0.7;
}

.pause-icon {
  font-size: 24px;
  line-height: 1;
}

/* === Start Overlay === */
#start-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

#start-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#start-card {
  background: #1B5E20;
  border-radius: 30px;
  padding: 40px 30px;
  text-align: center;
  color: #fff;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  max-width: 320px;
  width: 90%;
}

#start-icon {
  font-size: 60px;
  margin-bottom: 10px;
}

#start-card h1 {
  font-size: 1.8em;
  margin-bottom: 10px;
  font-weight: 700;
}

#start-card p {
  font-size: 0.95em;
  opacity: 0.8;
  margin-bottom: 25px;
  line-height: 1.4;
}

#start-btn {
  background: #FF8F00;
  color: #1B5E20;
  border: none;
  padding: 15px 40px;
  font-size: 1.2em;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255,143,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

#start-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 10px rgba(255,143,0,0.6);
}

/* === Modal Overlay (shared) === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: #fff;
  border-radius: 24px;
  padding: 30px 24px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  color: #000;
  font-size: 0.95em;
  line-height: 1.5;
}

.modal-card h2 {
  color: #334086;
  font-size: 1.5em;
  margin-bottom: 16px;
}

#lab-content,
#hatch-content {
  text-align: left;
  margin-bottom: 20px;
  max-height: 300px;
  overflow-y: auto;
}

#lab-content p,
#hatch-content p {
  margin: 8px 0;
}

#lab-content .positive {
  color: #1B5E20;
  font-weight: 600;
}

#lab-content .negative {
  color: #888;
}

#lab-close-btn,
#hatch-close-btn {
  background: #334086;
  color: #fff;
  border: none;
  padding: 12px 32px;
  font-size: 1em;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(51, 64, 134, 0.3);
  transition: transform 0.2s;
}

#lab-close-btn:active,
#hatch-close-btn:active {
  transform: scale(0.95);
}

/* === Hatch Modal Specific === */
#hatch-content {
  text-align: center;
}

#hatch-content p {
  margin: 6px 0;
}

/* === Incubator Menu (Slide Up) === */
.slide-up-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  background: #fff;
  border-radius: 24px 24px 0 0;
  z-index: 4000;
  transform: translateY(100%);
  transition: transform 0.35s ease-out;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
}

.slide-up-menu.visible {
  transform: translateY(0);
}

.slide-up-menu.hidden {
  transform: translateY(100%);
  pointer-events: none;
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.menu-header h2 {
  color: #334086;
  font-size: 1.3em;
  margin: 0;
}

#incubator-close-btn,
#stats-close-btn {
  background: #f0f0f0;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}

#incubator-close-btn:active,
#stats-close-btn:active {
  background: #ddd;
}

/* Incubator cards */
.incubator-section {
  padding: 16px 20px;
}

.incubator-title {
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin-bottom: 8px;
}

.incubator-card {
  background: #f5f5f5;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  text-align: center;
}

.incubator-card.active {
  background: #e8f5e9;
  border: 2px solid #4CAF50;
}

.incubator-card.empty {
  background: #fafafa;
  border: 2px dashed #ccc;
}

.incubator-status {
  font-size: 1.1em;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: #4CAF50;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Buy extra incubator placeholder */
.buy-incubator-btn {
  width: 100%;
  padding: 12px;
  background: #334086;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.5;
  pointer-events: none;
  margin-top: 4px;
}

/* Unincubated amber list */
.amber-list-section {
  padding: 0 20px 20px;
}

.level-header {
  font-size: 0.85em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 0 6px;
  color: #666;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.level-header.gold {
  color: #DAA520;
}

.level-header.silver {
  color: #808080;
}

.level-header.bronze {
  color: #CD7F32;
}

.amber-dna-item {
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s, background 0.2s;
}

.amber-dna-item:active {
  border-color: #4CAF50;
  background: #f0f8f0;
}

.amber-dna-item .dna-icon {
  font-size: 20px;
  margin-right: 10px;
}

.amber-dna-item .dna-level {
  font-weight: 600;
  color: #333;
  flex: 1;
}

.amber-dna-item .dna-hatch-distance {
  font-size: 0.8em;
  color: #888;
}

.no-amber-msg {
  text-align: center;
  color: #888;
  padding: 20px;
  font-size: 0.9em;
}

/* === Stats Page === */
.stats-section {
  padding: 16px 20px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-label {
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

.stats-value {
  font-size: 1.2em;
  font-weight: 700;
  color: #334086;
}

/* Island section */
.island-section {
  padding: 0 20px 20px;
}

.island-title {
  font-size: 0.9em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #334086;
  padding: 16px 0 10px;
  border-top: 2px solid #e0e0e0;
  margin-top: 8px;
}

.dino-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f5f5f5;
}

.dino-name {
  font-weight: 600;
  color: #333;
  flex: 1;
}

.dino-level-badge {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 10px;
  margin-right: 10px;
}

.dino-level-badge.gold {
  background: #FFF8DC;
  color: #B8860B;
}

.dino-level-badge.silver {
  background: #F5F5F5;
  color: #696969;
}

.dino-level-badge.bronze {
  background: #FDF5E6;
  color: #8B4513;
}

.dino-count {
  font-weight: 700;
  color: #334086;
  min-width: 40px;
  text-align: right;
}

.no-dinos-msg {
  text-align: center;
  color: #888;
  padding: 20px;
  font-size: 0.9em;
}

/* Species progress */
.species-progress {
  padding: 12px 0;
  text-align: center;
}

.species-progress-text {
  font-size: 0.9em;
  font-weight: 600;
  color: #334086;
  margin-bottom: 6px;
}

.species-progress .progress-bar {
  width: 100%;
  height: 10px;
  background: #e0e0e0;
  border-radius: 5px;
  overflow: hidden;
}

.species-progress .progress-fill {
  height: 100%;
  background: #FF8F00;
  border-radius: 5px;
  transition: width 0.3s ease;
}

/* === Toast Notification (centre) === */
#toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 20px 24px;
  border-radius: 20px;
  font-size: 1.1em;
  line-height: 1.5;
  z-index: 2500;
  text-align: center;
  white-space: normal;
  max-width: 85%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 183, 77, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* === Top Toast (for slide-up menus) === */
#top-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 1em;
  line-height: 1.4;
  z-index: 7000;
  text-align: center;
  white-space: normal;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 183, 77, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#top-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === PWA Install Prompt === */
#pwa-prompt {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: rgba(27, 94, 32, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 16px 20px;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9em;
  transform: translateY(100%);
  transition: transform 0.4s ease;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.3);
}

#pwa-prompt.show {
  transform: translateY(0);
}

#pwa-prompt-text {
  flex: 1;
  line-height: 1.4;
}

#pwa-prompt-close {
  background: #fff;
  color: #1B5E20;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85em;
  cursor: pointer;
  white-space: nowrap;
}

/* === Status Bar === */
#status-bar {
  position: fixed;
  top: 70px;
  left: 20px;
  right: 20px;
  background: rgba(180, 30, 30, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85em;
  z-index: 1500;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  word-wrap: break-word;
  line-height: 1.4;
  text-align: center;
}

#status-bar.visible { opacity: 1; }
#status-bar.hidden { opacity: 0; }

/* === Leaflet Overrides === */
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom {
  border: 2px solid rgba(0, 0, 0, 0.2) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: rgba(255, 255, 255, 0.9) !important;
  color: #333 !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 18px !important;
}

/* === Landscape warning === */
@media screen and (orientation: landscape) and (max-width: 900px) {
  #map::after {
    content: "Please rotate to portrait mode";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    font-size: 1.2em;
    padding: 20px;
    text-align: center;
  }
}