/* ==========================================================================
   6. MOBILE RESPONSIVENESS (MEDIA QUERIES)
   ========================================================================== */

/* Targets screens smaller than 768px (most mobile phones and vertical tablets) */
/* ==========================================================================
   6. MOBILE RESPONSIVENESS (CLEAN SIDE-BY-SIDE SIDEBAR LAYOUT)
   ========================================================================== */

@media screen and (max-width: 768px) {
  body {
    padding: 10px 5px;
    overflow-x: hidden;
  }

  h1 {
    font-size: 20px;
    margin-bottom: 15px;
    line-height: 1.3;
  }

  /* Split screen cleanly 50/50 without any overflow */
  .arena {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
    margin: 10px 0;
    width: 100%;
    align-items: start;
    box-sizing: border-box;
  }

  /* Refined Team Boxes */
  .team-box {
    width: 100%;
    padding: 10px 6px;
    box-sizing: border-box;
    border-width: 2px; /* Slimmer borders look cleaner on mobile */
    border-radius: 10px;
  }

  .team-box h2 {
    font-size: 13px;
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
    padding-bottom: 5px;
  }

  /* Force 1 single vertical column of Pokémon per team */
  .grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px;
    width: 100%;
  }

  /* Overhauled Card Layout: Horizontal row format instead of a vertical stack */
  .poke-card {
    display: flex !important;
    flex-direction: row !important; /* Image left, text right */
    align-items: center;
    justify-content: flex-start;
    padding: 6px;
    font-size: 11px;
    width: 100%;
    box-sizing: border-box;
    gap: 6px;
    border-radius: 6px;
    min-height: 65px;
  }

  /* Shrink images slightly and isolate them on the left */
  .poke-card img {
    width: 40px;
    height: 40px;
    margin: 0;
    flex-shrink: 0; /* Prevents the image from getting squeezed */
  }

  /* Wrap text nodes on the right side cleanly */
  .poke-card div {
    text-align: left !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    overflow: hidden;
  }

  .poke-card strong {
    font-size: 11px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
  }

  /* Display evolution tag on its own line below the name */
  .poke-card span {
    display: block;
    font-size: 9px !important;
    margin-top: 1px;
  }

  /* Clean up stats typography */
  .poke-card div:nth-of-type(1) {
    font-size: 10px;
    color: #ccc;
  }

  /* Keep the HP progress bar small and compact under the text */
  .hp-bar-bg {
    height: 5px;
    margin-top: 4px;
    border-radius: 3px;
    border: none;
  }

  /* Align Action Control Buttons */
  .controls {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
  }

  button {
    width: 95%;
    max-width: 280px;
    padding: 10px;
    font-size: 14px;
    border-width: 2px;
    box-shadow: 0 4px 0 #1d2c5e;
  }
  
  #battle-btn {
    box-shadow: 0 4px 0 #1b5e20;
  }

  #battle-log {
    height: 120px;
    font-size: 12px;
    padding: 8px;
    margin: 15px auto;
    width: 95%;
  }
}

/* Extra optimization for very small mobile screens (under 400px width) */
@media screen and (max-width: 400px) {
  .grid {
    grid-template-columns: 1fr; /* 1 card per row on tiny screens */
  }
}
/* ==========================================================================
   1. GLOBAL REBOOT & TYPOGRAPHY
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  background: #111 url('https://images.unsplash.com/photo-1613376023733-0a73315d9b06?q=80&w=1920') no-repeat center center/cover;
  background-blend-mode: overlay;
  color: #f5f5f5;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

h1 {
  text-shadow: 3px 3px 0px #1d2c5e, -1px -1px 0px #1d2c5e, 1px -1px 0px #1d2c5e, -1px 1px 0px #1d2c5e, 1px 1px 0px #1d2c5e;
  color: #ffcb05;
  font-size: 42px;
  margin-top: 10px;
  margin-bottom: 25px;
  letter-spacing: 2px;
}

h2 {
  margin-top: 0;
  font-size: 20px;
  letter-spacing: 1px;
}

/* ==========================================================================
   2. INTERACTIVE CONTROLS & BUTTONS
   ========================================================================== */
.controls {
  margin: 25px 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

button {
  background: #ffcb05;
  color: #1d2c5e;
  border: 4px solid #1d2c5e;
  padding: 14px 35px;
  font-size: 18px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 6px 0 #1d2c5e;
  transition: all 0.1s ease;
  text-transform: uppercase;
}

button:hover:not(:disabled) {
  background: #ffe066;
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #1d2c5e;
}

button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #1d2c5e;
}

button:disabled {
  background: #444;
  color: #888;
  border-color: #222;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

#battle-btn {
  background: #4caf50;
  color: white;
  border-color: #1b5e20;
  box-shadow: 0 6px 0 #1b5e20;
}

#battle-btn:hover:not(:disabled) {
  background: #66bb6a;
  box-shadow: 0 8px 0 #1b5e20;
}

#battle-btn:active:not(:disabled) {
  box-shadow: 0 2px 0 #1b5e20;
}

/* ==========================================================================
   3. BATTLE ARENA LAYOUT
   ========================================================================== */
.arena {
  display: flex;
  justify-content: space-around;
  margin: 30px 0;
  gap: 25px;
}

.team-box {
  background: rgba(10, 20, 40, 0.85);
  border: 4px solid #3b4cca;
  border-radius: 16px;
  padding: 20px;
  width: 48%;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
}

.team-box h2 {
  color: #4fc3f7;
  border-bottom: 2px dashed rgba(79, 195, 247, 0.4);
  padding-bottom: 10px;
}

/* Opponent Variant overrides */
.team-box.opponent {
  background: rgba(40, 10, 10, 0.85);
  border-color: #cc0000;
}

.team-box.opponent h2 {
  color: #ff5252;
  border-bottom: 2px dashed rgba(255, 82, 82, 0.4);
}

/* ==========================================================================
   4. POKEMON CARDS GRID
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 15px;
}

.poke-card {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 8px;
  font-size: 13px;
  text-transform: capitalize;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.poke-card:hover:not(.fainted) {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffcb05;
  transform: scale(1.03);
}

.poke-card img {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0px 4px 4px rgba(0,0,0,0.5));
}

.poke-card strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

/* HP Progress Bars */
.hp-bar-bg {
  background: #222;
  width: 100%;
  height: 100%;
  max-height: 10px;
  height: 10px;
  border: 1px solid #444;
  border-radius: 5px;
  margin-top: 8px;
  overflow: hidden;
}

.hp-bar-fill {
  background: #4caf50;
  height: 100%;
  width: 100%;
  border-radius: 5px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Fainted State Override */
.fainted {
  opacity: 0.25;
  background: rgba(20, 20, 20, 0.6);
  border-color: #ff5252;
  filter: grayscale(80%);
}

.fainted::after {
  content: "FAINTED";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15px);
  color: #ff5252;
  font-weight: bold;
  font-size: 16px;
  text-shadow: 2px 2px 4px #000;
  border: 2px solid #ff5252;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 1px;
}

/* ==========================================================================
   5. GAME LOG BOX
   ========================================================================== */
#battle-log {
  background: rgba(0, 0, 0, 0.9);
  border: 3px solid #ffcb05;
  border-radius: 12px;
  height: 200px;
  overflow-y: auto;
  padding: 15px 20px;
  text-align: left;
  font-size: 15px;
  line-height: 1.6;
  max-width: 900px;
  margin: 20px auto;
  box-shadow: inset 0 0 15px rgba(255, 203, 5, 0.15), 0 8px 16px rgba(0,0,0,0.5);
  scrollbar-width: thin;
  scrollbar-color: #ffcb05 #111;
}

/* Custom Scrollbar styling for Webkit browsers */
#battle-log::-webkit-scrollbar {
  width: 8px;
}
#battle-log::-webkit-scrollbar-track {
  background: #111;
  border-radius: 0 8px 8px 0;
}
#battle-log::-webkit-scrollbar-thumb {
  background: #ffcb05;
  border-radius: 4px;
}

/* Log Color Codings */
#battle-log p {
  margin: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 4px;
}

.log-player {
  color: #66bb6a; /* Green text for your attacks */
}

.log-opp {
  color: #ff7474; /* Soft red text for enemy attacks */
}

.log-system {
  color: #ffd54f; /* Golden yellow for system notices/faints */
  font-weight: bold;
}