/* MOBILE-OPTIMIZED CSS */
:root {
  --card-hover-color: #ffc107;
  --energy-color: #00b8ff;
  --player-slot-color: rgba(0, 150, 255, 0.4);
  --player-slot-hover: rgba(0, 150, 255, 0.6);
  --enemy-slot-color: rgba(255, 0, 0, 0.2);
  --background-dark: #121212;
  --surface-dark: #1e1e1e;
  --primary-text: #e0e0e0;
  --border-color: #444;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Poppins", sans-serif;
  font-size: 14px;
  touch-action: manipulation;
}

body {
  background: rosybrown;
  color: var(--primary-text);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#game-container {
  width: 100vw;
  height: 100vh;
  background-color: #1c1c1c;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* OVERLAYS - Mobile Optimized */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 10, 0.95);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 15px;
  text-align: center;
  overflow-y: auto;
}

.overlay h1 {
  color: var(--card-hover-color);
  text-shadow: 2px 2px 5px black;
  font-size: 1.5rem;
  margin: 10px 0;
}

.setup-button {
  padding: 12px 20px;
  font-size: 0.9rem;
  border: none;
  display: block;
      justify-self: anchor-center;

  background-color: #0e8d27;
  color: #ffffff;
  cursor: not-allowed;
  border-radius: 8px;
  transition: all 0.3s;
  width: 100%;
  max-width: 300px;
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 1px;
  margin: 5px 25%;
}

.setup-button.ready {
  background-color: #28a745;
  color: white;
  cursor: pointer;
}

.setup-button.ready:active {
  background-color: #218838;
  transform: scale(0.98);
}
 
/* STATS DISPLAY */
#stats-display {
  display: flex;
  gap: 15px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 15px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: 0.85rem;
}

#stats-display p {
  margin: 0;
  font-weight: 600;
}

#stats-display .wins {
  color: #28a745;
}

#stats-display .losses {
  color: #dc3545;
}

/* CHARACTER ROSTER - Mobile Grid */
#character-roster {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 15px 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: 10px;
  width: 100%;
}

.roster-char {
  background-color: rgba(0, 0, 0, 0.5);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-size: 0.75rem;
  height: 160px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s;
}

.roster-char:active {
  transform: scale(0.95);
}

.roster-char.selected {
  opacity: 0.5;
  border-color: #28a745;
}

.roster-char-front,
.roster-char-back {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 8px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 6px;
}

.roster-char-back {
  background-color: #333;
  transform: rotateY(180deg);
  justify-content: center;
  gap: 3px;
  font-size: 0.65rem;
}

.roster-sprite {
  width: 100%;
  height: 100px;
  border-radius: 5px;
  margin-bottom: 5px;
  object-fit: cover;
}

.stat-bar-container {
  font-size: 0.6rem;
  text-align: left;
}

.stat-bar {
  width: 100%;
  height: 6px;
  background-color: #555;
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  background-color: var(--card-hover-color);
}

.stat-bar-fill.max-stat {
  background: linear-gradient(to right, #a133ff, #d633ff);
}

/* PLACEMENT SIDEBAR - Mobile Version */
#placement-sidebar {
  width: 100%;
  background-color: var(--surface-dark);
  border-bottom: 2px solid var(--border-color);
  padding: 10px;
  display: flex;
  flex-direction: column;
  text-align: center;
  max-height: 40vh;
  overflow-y: auto;
}

#placement-sidebar h2 {
  color: var(--card-hover-color);
  font-size: 1rem;
  margin: 5px 0;
}

#placement-sidebar p {
  font-size: 0.75rem;
  margin: 5px 0;
}

#placement-roster {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0;
}

#placement-roster .roster-char {
  min-width: 80px;
  height: 100px;
  flex-shrink: 0;
}

#placement-roster .roster-sprite {
  height: 60px;
}

/* MAIN GAME AREA - Mobile Layout */
#main-game-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#battlefield {
  flex-grow: 1;
  background: url(bg/normal.jpg) center/cover;
  display: grid;
  grid-template-columns: 1fr 1fr 0.1fr 1fr 1fr;
  grid-template-rows: repeat(2, 1fr);
  padding: 5px;
  gap: 3px;
  min-height: 0;
}

#dividing-line {
  grid-column: 3;
  grid-row: 1 / -1;
  width: 100%;
  background-color: rgba(255, 0, 0, 0.073);
}

.placement-slot {
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.placement-slot.player-zone.available {
  background-color: var(--player-slot-color);
  border: 2px dashed var(--player-slot-color);
}

.placement-slot.player-zone.available:active {
  background-color: var(--player-slot-hover);
}

/* Slot positioning */
#slot-p1 { grid-column: 1; grid-row: 1; }
#slot-p2 { grid-column: 1; grid-row: 2; }
#slot-p3 { grid-column: 2; grid-row: 1; }
#slot-p4 { grid-column: 2; grid-row: 2; }
#slot-e1 { grid-column: 4; grid-row: 1; }
#slot-e2 { grid-column: 4; grid-row: 2; }
#slot-e3 { grid-column: 5; grid-row: 1; }
#slot-e4 { grid-column: 5; grid-row: 2; }

/* CHARACTER ELEMENTS - Mobile Sized */
.character {
  max-width: 90px;
  width: 50%;
  aspect-ratio: 2 / 3;
  border: 2px solid transparent;
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2px;
  position: relative;
  transition: all 0.2s;
  border-radius: 5px;
  margin: auto;
}

.character.active-turn {
filter: drop-shadow(0 0 4px var(--card-hover-color));
}

.character.targetable {
  cursor: pointer;
  transform: scale(1.05);
  filter: drop-shadow(0 0 8px #dc3545);
}

.character.dead {
  opacity: 0.5;
  filter: grayscale(100%);
}

.character.enemy {
  transform: scaleX(-1);
}

.character.enemy.targetable {
  transform: scaleX(-1) scale(1.05);
}

.character.enemy .character-name,
.character.enemy .health-bar-container,
.character.enemy .energy-bar-container,
.character.enemy .status-effects-container {
  transform: scaleX(-1);
}

.character-sprite {
  width: 95%;
  height: 95%;
  margin-bottom: 3px;
  border-radius: 4px;
  object-fit: contain;
  filter: drop-shadow(1px 1px 3px black);
  z-index: 1;
}

.character-name {
  font-size: 0.6rem;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
      color: lavenderblush;

}

.health-bar-container,
.energy-bar-container {
  width: 100%;
  height: 6px;
  background-color: #333;
  border: 1px solid #111;
  border-radius: 3px;
  margin-top: 2px;
  position: relative;
}

.health-bar {
  height: 100%;
  background: linear-gradient(to right, #28a745, #5cff80);
  border-radius: 2px;
  transition: width 0.5s;
}

.energy-bar {
  height: 100%;
  background: linear-gradient(to right, #00b8ff, #80dfff);
  border-radius: 2px;
  transition: width 0.5s;
}

.shield-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background-color: rgba(0, 191, 255, 0.7);
  border-radius: 2px;
  transition: width 0.5s;
}

/* STATUS EFFECTS - Mobile */
.status-effects-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  height: 16px;
  margin-top: 2px;
  position: absolute;
  bottom: -18px;
  width: 100%;
}

.status-icon {
  width: 14px;
  height: 14px;
  position: relative;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  padding: 0px;
}

.status-icon img {
  width: 100%;
  height: 100%;
}

/* EFFECT OVERLAYS */
.effect-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 70%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.effect-overlay img {
  max-width: 120%;
  max-height: 120%;
}

/* DAMAGE POPUPS - Mobile */
.damage-popup {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: bold;
  text-shadow: 2px 2px 4px black;
  pointer-events: none;
  animation: float-up 1s ease-out forwards;
  z-index: 20;
}
.tooltip-text {
    visibility: hidden;
    width: 140px;
    background-color: #111;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    border: 1px solid var(--card-hover-color);
    position: absolute;
    z-index: 10;
    bottom: 135%;
    left: 50%;
    margin-left: -70px;
    opacity: 0;
    transition: opacity 0.3s;
}


.damage-low { color: white; }
.damage-medium { color: yellow; }
.damage-high { color: red; font-size: 1.2rem; }

@keyframes float-up {
  from {
    transform: translate(-50%, 0);
    opacity: 1;
  }
  to {
    transform: translate(-50%, -30px);
    opacity: 0;
  }
}

.status-dodged {
  color: var(--energy-color);
  font-size: 1rem;
  font-style: italic;
}

.card-played-popup {
  color: #ffeb3b;
  font-size: 0.9rem;
  top: -5%;
}

/* UI PANEL - Mobile Optimized */
#ui-panel {
  flex: 0 0 auto;
  height: 30vh;
  max-height: 200px;
  background-color: var(--surface-dark);
  border-top: 2px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 8px;
  overflow: hidden;
}

#turn-info {
  text-align: center;
  font-size: 0.85rem;
  margin-bottom: 5px;
  color: var(--card-hover-color);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#player-hand {
  display: flex;
  justify-content:center;
  gap: 5px;
  flex-grow: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 0;
}

.card {
  min-width: 100px;
  max-width: 100px;
  height: 92%;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background-color: #2a2a2a;
  padding: 3px 5px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

.card:active {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 5px 10px var(--card-hover-color);
  border-color: var(--card-hover-color);
}

.card.disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(50%);
}

.card.copied-card {
  border-color: #8a2be2;
  box-shadow: 0 0 10px #8a2be2;
}

.card-name {
  font-size: 0.7rem;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
}

.card-type {
  font-size: 0.6rem;
  font-style: italic;
  text-align: center;
  color: #ccc;
  margin: 3px 0;
}

.card-cost {
  font-size: 0.65rem;
  font-weight: bold;
  text-align: right;
  color: var(--energy-color);
}

/* CARD TOOLTIP - Mobile */
#card-tooltip {
  position: fixed;
  background-color: #222;
  border: 1px solid var(--card-hover-color);
  border-radius: 5px;
  padding: 10px;
  max-width: 80%;
  font-size: 0.75rem;
  text-align: center;
  z-index: 300;
  pointer-events: none;
}

/* PROGRESSION TRACKER - Mobile */
#progression-overlay {
  flex-direction: column;
  background: rgba(10, 10, 10, 0.85);
  padding: 20px;
}

#round-progression-tracker {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 30px;
  margin-top: 15%;
}

.progression-node {
  border-radius: 50%;
  border: 2px solid var(--primary-text);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.progression-node.small-circle {
  width: 12px;
  height: 12px;
  background-color: #ffffff;
}

.progression-node.small-circle.completed {
  background-color: var(--card-hover-color);
  border-color: var(--card-hover-color);
  transition: background-color 3s ease, border-color 3s ease;
}

.progression-node.boss-round {
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.progression-node.boss-round img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  filter: brightness(100%);
}

.progression-node.boss-round.completed img {
  filter: brightness(50%);
  transition: filter 3s ease;
}

.progression-line {
  height: 2px;
  background-color: var(--primary-text);
  width: 15px;
}

/* LOADING SCREEN - Mobile */
#loading-overlay .content {
  width: 90%;
  max-width: 400px;
}

#progress-bar-container {
  width: 100%;
  height: 25px;
  background-color: #333;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  margin: 15px 0;
  overflow: hidden;
}

#progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #28a745, #5cff80);
  transition: width 0.3s ease-in-out;
}

#progress-text {
  font-size: 1rem;
  font-weight: bold;
  color: var(--card-hover-color);
}

#loading-asset-text {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #ccc;
  font-style: italic;
}

/* DEBUG PANEL - Mobile Hidden by Default */
 
#debug-toggle-button {
        position: absolute;
    top: 0px;
    right: 2px;
    z-index: 999;
    opacity: 0.7;
    padding: 1px 6px;
    background: #fff;
    border: 1px solid #000;
    cursor: pointer;
}
#debug-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 300px;
    max-height: 90vh;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #fff;
    color: #fff;
    z-index: 1000;
    padding: 10px;
    font-family: monospace;
    font-size: 12px;
    overflow-y: auto;
    border-radius: 5px;
}

/* SUPPORT & ONLINE COUNTER - Mobile */
#support-btn {
  position: fixed;
  top: 3px;
  left: 1px;
  z-index: 999;
  padding: 5px 10px;
  background: #1e90ff;
  color: white;
  border: 1px solid #fff;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.75rem;
}

#online-counter {
  position: fixed;
  bottom: 10px;
  left: 10px;
  z-index: 999;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 5px 10px;
  border-radius: 15px;
  border: 1px solid #444;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #ccc;
}

.online-indicator {
  width: 10px;
  height: 10px;
  background-color: #28a745;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(40, 167, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* NEW GAME BUTTON */
#new-game-btn {
  background-color: #dc3545;
}

#new-game-btn:active {
  background-color: #c82333;
}

/* BOSS UNLOCK */
#unlocked-boss-sprite {
  width: 100px;
  height: auto;
  margin: 10px 0;
  border: 3px solid var(--card-hover-color);
  border-radius: 5px;
  background-color: rgba(0, 0, 0, 0.3);
}

/* CONFIRM POPUP */
.confirm-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
  width: 100%;
}

.confirm-buttons .setup-button {
  width: 100%;
  max-width: 100%;
}

#confirm-yes-btn {
  background-color: #dc3545;
  color: white;
  cursor: pointer;
}

/* ANIMATIONS */
@keyframes shake-animation {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.character.is-hit {
  animation: shake-animation 0.3s linear;
}

@keyframes screen-flash {
  0% { background: transparent; }
  50% { background: rgba(255, 255, 255, 0.7); }
  100% { background: transparent; }
}

.flash-animation {
  animation: screen-flash 0.5s ease-out;
}

/* Scrollbar styling for mobile */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #777;
}
/* --- ADD THIS AT THE END OF YOUR CSS FILE --- */

/* Landscape Lock Overlay */
#orientation-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #111;
  z-index: 10000;
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  text-align: center;
  color: white;
}

#orientation-lock-overlay .content h1 {
  color: var(--card-hover-color);
}

/* Media Query to detect Portrait Mode */
@media screen and (orientation: portrait) {
  #orientation-lock-overlay {
    display: flex; /* Show the overlay */
  }
  #game-container {
    display: none; /* Hide the game content */
  }
}
/* --- ADD THIS AT THE END OF YOUR CSS FILE FOR MOBILE FIXES --- */

/* Rule to show the status effect tooltip when tapped (JS will add the .show class) */
.tooltip-text.show {
  visibility: visible !important;
  opacity: 1 !important;
}

/* For Desktop: Make sure hover still works on status icons */
.status-icon:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Add a visual indicator for a card that has been tapped once to show its tooltip */
.card.tooltip-active {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 5px 10px var(--card-hover-color);
  border-color: var(--card-hover-color);
}

/* Make the roster character flip happen with a class instead of hover */
.roster-char.flipped .roster-char-front {
  transform: rotateY(180deg);
}

.roster-char.flipped .roster-char-back {
  transform: rotateY(0deg);
}