/* Base styles */
body {
  font-family: Arial, 'Segoe UI', sans-serif;
  background: #242d34;
  color: #fff;
  margin: 0;
}

/* NEW: Game Title Area */
.top-title-area {
    text-align: center;
    padding: 20px 0 0 0;
    margin-bottom: -15px; /* Pulls the header up slightly */
}
.game-title {
    font-size: 2.8em;
    color: #ff4757; /* Pokéball red */
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    font-weight: bold;
}
.game-credits {
    font-size: 0.9em;
    color: #5b8ff3; /* Button blue */
    margin: 0;
    padding-bottom: 5px;
}

/* Header & Footer */
header, footer {
  background: #2e3942;
  padding: 12px 0;
  box-shadow: 0 2px 6px #1b18185a;
}
header .game-header {
  max-width: 1280px; 
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
footer {
  text-align: center;
  font-size: 0.98em;
  color: #9bb7c4;
}
footer a {
  color: #7ecbff;
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* Score Group Wrapper */
.score-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Prominent Score Display (Current Score) */
.main-score-display {
  font-size: 1.4em;
  font-weight: 500;
  color: #ffda79;
  line-height: 1.2;
}
.main-score-display strong {
  font-weight: bold;
  color: #fff;
  margin-left: 5px;
}
/* High Score Display */
.high-score-display {
    font-size: 0.9em;
    color: #9bb7c4;
}
.high-score-display strong {
    color: #fff;
}

/* NEW: POKEDEX TRACKER STYLING */
#map-pokedex-tracker-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 20px;
    background: #1f252a;
    box-shadow: 0 2px 8px #0004;
    border-radius: 0 0 10px 10px;
    text-align: center;
}
.map-pokedex-header h3 {
    margin: 5px 0 10px;
    color: #a1ffcb;
    font-size: 1.1em;
}
#pokedex-progress {
    font-weight: bold;
    color: #fff;
}
.pokedex-tracker {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 5px 0;
}
.pokedex-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 0.75em;
    padding: 5px;
    border-radius: 5px;
    background: rgba(0,0,0,0.1);
    width: 60px; /* Fixed width for alignment */
    opacity: 0.25; /* Default: Not caught */
    transition: opacity 0.3s;
}
.pokedex-entry.caught {
    opacity: 1; /* Fully visible when caught */
    background: rgba(0,0,0,0.3);
}
.pokedex-entry img {
    width: 30px;
    height: 30px;
    margin-bottom: 2px;
    border-radius: 50%;
}
.pokedex-entry .poke-points {
    font-weight: bold;
    color: #ffda79;
    margin-top: 2px;
}
.pokedex-entry .poke-name {
    line-height: 1.2;
}


/* Game container */
.game-container {
  display: flex;
  max-width: 1280px; 
  margin: 30px auto;
  gap: 20px; 
  align-items: flex-start;
}

/* Panel Wrapper for Item Log & Exchange */
.item-inventory-panel-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 200px;
}

/* Item Log Panel Style */
.item-inventory-panel {
  width: 200px; 
  background: #2e3942;
  box-shadow: 0 2px 16px #0004;
  border-radius: 16px;
  padding: 18px;
  min-height: 150px; 
  flex-shrink: 0;
}

/* Capture Log Panel Style (remains 200px) */
.capture-log-panel {
  width: 200px; 
  background: #2e3942;
  box-shadow: 0 2px 16px #0004;
  border-radius: 16px;
  padding: 18px;
  min-height: 370px;
  flex-shrink: 0;
}

/* Gemstone Exchange Panel Styling */
.gemstone-exchange-panel {
    width: 200px;
    background: #1f252a;
    box-shadow: 0 2px 8px #0004;
    border: 2px solid #6de6ee;
    border-radius: 16px;
    padding: 18px;
    text-align: center;
    transition: opacity 0.3s;
}

.gemstone-exchange-panel.hidden {
    display: none; 
}

.gemstone-exchange-panel h4 {
    margin-top: 0;
    color: #6de6ee;
    border-bottom: 1px solid #4a5966;
    padding-bottom: 5px;
}

.gemstone-exchange-panel p {
    font-size: 0.9em;
    margin: 5px 0;
}

.gemstone-exchange-panel strong {
    color: #ffe771;
}

.exchange-offer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #4a5966;
}

.exchange-offer p {
    font-size: 0.95em;
    color: #a1ffcb;
}

.exchange-offer button {
    margin-top: 8px;
    padding: 6px 12px;
    background: #57d785;
    color: #1d2920;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.1s;
}

.exchange-offer button:hover:not(:disabled) {
    background: #44be74;
}

.exchange-offer button:disabled {
    background: #4a5966;
    cursor: not-allowed;
    color: #bbb;
}


/* Log Content Styling */
.log-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed #3a4753;
}

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

.log-left {
  display: flex;
  align-items: center;
  gap: 5px;
}

.log-sprite {
  border-radius: 50%;
  padding: 1px;
  background: #3f4a56;
}
.shiny-sprite {
  box-shadow: 0 0 5px gold;
}
.mythic-sprite {
    background: #4a148c; 
    box-shadow: 0 0 10px #e040fb;
}

.log-points {
  font-weight: bold;
  color: #a1ffcb;
  font-size: 0.95em;
}
.item-points {
  color: #ffbc5b;
}

.no-catches {
  text-align: center;
  color: #9bb7c4;
  font-style: italic;
  font-size: 0.9em;
  margin-top: 15px;
}


/* Game area */
.game-area {
  flex-grow: 1; 
  width: 100%;
  max-width: 800px; 
  margin: 0; 
  background: rgba(0,0,0,0.17);
  box-shadow: 0 2px 16px #0004;
  border-radius: 16px;
  padding: 18px;
  min-height: 370px;
  position: relative;
  overflow: hidden;
}

/* Pokéball Inventory Display */
.pokeball-inventory-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.15em;
  margin-bottom: 10px;
  color: #eaeeff;
  padding: 5px 0;
  background: rgba(46, 57, 66, 0.5); 
  border-radius: 8px;
}
.pokeball-inventory-display strong {
  color: #ff4757;
}
.pokeball-inventory-display .masterball-count-separator {
    color: #4a5966;
    margin: 0 5px;
}
#masterballs-count {
    color: #e040fb; 
}


/* Catch Streak Display */
.catch-streak-display {
  text-align: center;
  font-size: 1.05em;
  color: #7ecbff;
  margin-bottom: 15px;
  font-weight: 500;
  transition: all 0.3s ease; 
}
.catch-streak-display strong {
  font-weight: bold;
  color: #fff;
}
/* Streak Visual Cue (Multiplier active) */
.catch-streak-display.active {
    color: #ffda79;
    font-size: 1.15em;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 218, 121, 0.8);
    animation: streakGlow 1.5s infinite alternate;
}
@keyframes streakGlow {
    from { box-shadow: 0 0 0px rgba(0,0,0,0); }
    to { box-shadow: 0 0 10px rgba(255, 218, 121, 0.5); }
}


.capture-log-panel h3,
.item-inventory-panel h3 {
  margin-top: 0;
  padding-bottom: 5px;
  border-bottom: 1px solid #4a5966;
  text-align: center;
}

/* Map themes (backgrounds) */
#game-map {
  width: 100%;
  height: 480px; /* increased map height for more spawn area */
  position: relative;
  border-radius: 12px;
  margin-bottom: 16px; 
  clear: both; /* ensure the map sits below floated controls like the start button */
  margin-top: 12px; /* extra gap so the button doesn't overlap */
  background-color: #cbe1f1; /* fallback color only */
  transition: background 0.6s;
  box-shadow: 0 1.5px 16px #1d23404c;
}

/* More specific selectors: target #game-map with the theme class to ensure higher specificity
   and use relative paths so images load when opening the file locally. */
#game-map.theme-volcano {
  /* Volcano theme: lighter gradient overlay so the image shows through */
  background-image: linear-gradient(90deg, rgba(226,88,34,0.18) 70%, rgba(255,188,91,0.18)), url('PADDown/volcan.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: normal;
}
#game-map.theme-forest {
  /* Forest theme: lighter gradient overlay so the image shows through */
  background-image: linear-gradient(90deg, rgba(103,190,114,0.16) 80%, rgba(170,226,161,0.16)), url('PADDown/bosque.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: normal;
}
#game-map.theme-tundra {
  /* Tundra theme: lighter gradient overlay so the image shows through */
  background-image: linear-gradient(90deg, rgba(214,231,248,0.14) 80%, rgba(139,188,250,0.14)), url('PADDown/tundra.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-blend-mode: normal;
}

/* Buttons */
.map-theme-btn, .spawn-btn {
  margin: 0 0 0 10px;
  padding: 5px 15px;
  border: none;
  color: #fff;
  background: #5b8ff3;
  cursor: pointer;
  border-radius: 7px;
  font-weight: bold;
  box-shadow: 0 1px 4px #345a7a25;
  outline: none;
  transition: background 0.18s, transform 0.13s;
  font-size: 1em;
}
.map-theme-btn:hover,
.spawn-btn:hover {
  background: #5089ed;
  transform: translateY(-1.5px) scale(1.04);
}
.spawn-btn {
  margin-top: 14px;
  background: #57d785;
  color: #1d2920;
}
.spawn-btn:hover {
  background: #44be74;
}

/* Place spawn/start button above the map so it doesn't cover spawns */
.game-area .spawn-btn {
  /* default appearance when not inside the inline controls */
  margin: 0 0 36px 12px; /* keep bottom spacing */
  padding: 8px 14px;
  font-size: 0.95em;
  position: relative; /* ensure z-index applies */
  z-index: 50; /* keep button visually above the map */
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}

@media (max-width: 700px) {
  .game-area .spawn-btn {
    margin: 0 0 28px 8px;
    padding: 7px 12px;
    font-size: 0.92em;
  }
}

/* Controls row above the map: streak + start button */
.map-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.map-controls .catch-streak-display {
  margin-bottom: 0; /* remove extra bottom margin inside the controls */
}
.map-controls .spawn-btn {
  float: none; /* ensure button sits inline inside the flex container */
  margin: 0; /* handled by flex gap */
}

/* Disabled state for map/theme button */
.map-theme-btn:disabled,
.map-theme-btn[disabled] {
  background: #4a5966; /* muted grey */
  color: #c9d6d9;
  cursor: not-allowed;
  opacity: 0.75;
  transform: none; /* avoid hover transform */
  box-shadow: none;
}
.map-theme-btn:disabled:hover,
.map-theme-btn[disabled]:hover {
  transform: none;
}

/* Game map entity spawns (pokemon or items) */
.spawn-entity {
  position: absolute;
  cursor: pointer;
  user-select: none;
  z-index: 2;
  border-radius: 50%;
  box-shadow: 0 2px 6px #30353f60;
  transition: filter 0.13s, transform 0.09s;
  border: 2.5px solid #fafaff;
  padding: 2px;
  background: #2d343d;
}
.spawn-entity:hover {
  filter: brightness(1.18) drop-shadow(0 0 6px #baca17cc);
  transform: scale(1.13) rotate(-2deg);
  z-index: 10;
  border: 2.5px solid #ffe771;
  background: #fffedf;
}

.spawn-entity.pokemon {
  border-color: #1e6aff;
  background: #314480;
}
.spawn-entity.shiny {
  border-color: gold;
  background: #fff6d2;
  filter: drop-shadow(0 0 12px #ffe771cc);
}
.spawn-entity.mythic {
    border-color: #e040fb;
    background: #4a148c;
    filter: drop-shadow(0 0 15px #e040fb);
}
.mythic-aura {
    color: #e040fb;
    font-size: 19px;
    margin-left: 3px;
    text-shadow: 0 0 6px #fff;
    filter: drop-shadow(0 0 5px #fae595);
}


.spawn-entity.item {
  border-color: #a1ffcb;
  background: #2ed191;
}
.spawn-entity.gem {
  background: #6de6ee;
  border-color: #53d8e7;
}

/* Shiny icon star */
.shiny-star {
  color: gold;
  font-size: 19px;
  margin-left: 3px;
  text-shadow: 0 0 6px #fff590;
  filter: drop-shadow(0 0 5px #fae595);
}

h3 {
  color: #f9e2ff;
  margin-bottom: 7px;
}

ul {
  color: #f0eefd;
}

/* Instructions section styling */
.instructions-section {
    max-width: 800px; /* Match the game-area max-width */
    margin: 30px auto 0 auto;
    text-align: center;
}

/* Collapsible instructions styling */
.instructions-details {
  max-width: 800px;
  margin: 18px auto 0 auto;
  text-align: left;
}
.instructions-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  background: #2e3942;
  color: #a1ffcb;
  display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.instructions-summary h3 {
  margin: 0;
  font-size: 1.05em;
  color: inherit;
}
.instructions-summary::-webkit-details-marker { /* hide default marker */
  display: none;
}
.instructions-content {
  margin-top: 8px;
  background: #1f252a;
  padding: 14px 18px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.instructions-content ul { /* keep original centered width */
  margin: 0 auto;
}

/* Instructions layout */
@media (max-width: 1280px) { /* Adjust breakpoint for larger map */
  .game-container {
    flex-direction: column;
    max-width: 650px;
    margin: 30px auto;
  }
  .game-area {
    max-width: 100%;
    margin-bottom: 20px;
  }
  .instructions-section {
      max-width: 650px;
  }
  /* Stacking panels below the map */
  .item-inventory-panel-wrapper {
      width: 100%;
      max-width: 650px;
      flex-direction: row; /* Keep the item log and exchange side-by-side */
      gap: 15px;
      margin-bottom: 15px;
  }
  .capture-log-panel {
    width: 100%;
    min-height: auto;
    max-width: 650px;
    margin-bottom: 15px;
  }
  .item-inventory-panel,
  .gemstone-exchange-panel {
      width: 50%;
      min-height: auto;
  }
  header .game-header {
    max-width: 650px;
  }
  /* Adjusted score group alignment for stacking */
  .score-group {
      flex-direction: row;
      justify-content: space-between;
      width: 100%;
      align-items: center;
      margin-right: 15px;
  }
  .main-score-display {
      font-size: 1.2em;
  }
  .high-score-display {
      font-size: 0.8em;
  }
}

@media (max-width: 700px) {
  .game-area,
  header .game-header {
    max-width: 98vw;
    padding: 6vw 2vw;
  }
  #game-map {
    height: 42vw; /* keep responsive scaling for smaller screens */
    min-height: 200px;
  }
  /* Force item panels to stack vertically on small screens */
  .item-inventory-panel-wrapper {
      flex-direction: column;
      gap: 10px;
  }
  .item-inventory-panel,
  .gemstone-exchange-panel {
      width: 100%;
  }
}
@media (max-width: 520px) {
  .game-area {
    padding: 2vw 1vw;
    min-height: 230px;
  }
  #game-map {
    height: 36vw;
    min-height: 120px;
  }
  header, footer {
    padding: 8px 0;
  }
}
/* Countdown timer on entities */
.countdown-timer {
  position: absolute;
  bottom: -8px;
  right: -8px;
  background: #ff4757;
  color: white;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 5;
}

/* Game Message Panel Styling */
.game-message-panel {
    background: #3a4753;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    min-height: 20px;
    margin-bottom: 10px;
    font-size: 0.95em;
    transition: background 0.3s;
}

.game-message-panel p {
    margin: 0;
    line-height: 1.4;
}
.game-message-panel h4 {
    margin: 5px 0;
}
.game-message-panel strong {
    color: #ffda79;
}

/* Message Types */
.message-error {
    background: #c0392b;
    color: #fff;
}
.message-success {
    background: #2ecc71;
}
.message-alert {
    background: #e67e22;
}
.message-bonus {
    background: #9b59b6;
}
.message-start {
    background: #3498db;
}
.message-summary {
    background: #2c3e50;
    color: #fff;
    border: 1px solid #ffda79;
}

/* Score Popup Styles */
.score-popup {
  position: absolute;
  font-size: 1.2em;
  font-weight: bold;
  color: #fff;
  background: #3ed062; 
  padding: 3px 8px;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  animation: floatUpAndFade 0.9s ease-out forwards;
  z-index: 100; 
  pointer-events: none; 
  transform: translateX(-50%); 
}

.score-popup.shiny-popup {
  background: gold;
  color: #242d34;
  font-size: 1.4em;
  text-shadow: 0 0 3px #fff;
}

.score-popup.mythic-popup {
  background: #e040fb; 
  color: #fff;
  font-size: 1.5em;
  border: 2px solid #fff;
}

/* Animation to float up and fade out */
@keyframes floatUpAndFade {
  0% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -40px);
  }
}

/* History section styling */
.game-history-section {
  max-width: 1280px;
  margin: 20px auto 30px auto;
  background: #1f252a;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.game-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.history-card {
  background: #2e3942;
  border-radius: 10px;
  padding: 10px;
  color: #e6f7f0;
  font-size: 0.92em;
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
}
.history-card h4 {
  margin: 0 0 6px 0;
  font-size: 1em;
  color: #a1ffcb;
}
.history-row { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:6px 0; }
.history-label { color:#9bb7c4; font-weight:600; }
.history-sprites { display:flex; gap:6px; align-items:center; }
.history-sprites img { width:28px; height:28px; border-radius:6px; background:#fff; padding:2px; }
.history-small { font-size:0.85em; color:#cfeee6; }
.history-empty { text-align:center; color:#9bb7c4; font-style:italic; }

/* Row hover highlight for history cards */
.history-card .history-row {
  transition: background-color 0.15s ease, transform 0.08s ease;
}
.history-card .history-row:hover {
  background-color: rgba(255,255,255,0.03);
  cursor: pointer;
}