/* Base styles from original CSS */
body {
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  overflow: hidden;
  background-color: #222;
  color: white;
  position: fixed; /* Lock the viewport */
  width: 100%;
  height: 100%;
  touch-action: none; /* Disable browser default touch actions */
}

canvas {
  display: block;
  margin: 0 auto;
  touch-action: none; /* Disable browser default touch actions on canvas */
}

#game-container {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#ui-container {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 20;
  pointer-events: none; /* Allow clicks to pass through to canvas by default */
}

/* But enable pointer events for specific UI elements */
#ui-container button,
#ui-container input,
#ui-container .modal,
#ui-container .team-edit,
#ui-container .card,
#ui-container .monster-list,
#ui-container .queue {
  pointer-events: auto;
}

.labyrinth {
  bottom: 0 !important;
}

.battle, 
.main-menu {
  bottom: auto !important;
}

/* Enhanced button styling from paste.txt */
.button {
  background: linear-gradient(to bottom, #5a67d8, #4c51bf);
  border: none;
  color: white;
  padding: 12px 24px;
  text-align: center;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.5px;
}

.button:hover {
  background: linear-gradient(to bottom, #6875f5, #5a67d8);
  transform: translateY(-2px);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4);
}

.button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

/* Tile styles exactly matching the Editor.css */
.tile-wall {
  background-color: #8B4513;
}

.tile-walltop {
  background-color: #A0522D;
  background-image: linear-gradient(to bottom, #8B4513, #A0522D);
}

.tile-wallfront {
  background-color: #CD853F;
  background-image: linear-gradient(to top, #8B4513, #CD853F);
}

.tile-corner {
  background-color: #8B4513;
  background-image: linear-gradient(135deg, #8B4513 25%, #A0522D 25%, #A0522D 50%, #8B4513 50%, #8B4513 75%, #A0522D 75%);
  background-size: 20px 20px;
}

.tile-road {
  background-color: #D2B48C;
}

.tile-grass {
  background-color: #90EE90;
}

.tile-tree {
  background-color: #228B22;
  position: relative;
}

.tile-entrance {
  background-color: #FFD700;
  position: relative;
}

.tile-boss {
  background-color: #FF4500;
  position: relative;
}

.tile-boss::after {
  content: "👑";
  font-size: 20px;
  position: absolute;
}

.tile-water {
  background-color: #3498db;
  position: relative;
}

.tile-water::after {
  content: "~";
  font-size: 24px;
  position: absolute;
  color: #fff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  animation: wave 2s ease-in-out infinite;
}

@keyframes wave {
  0%, 100% {
      transform: translateY(0);
  }
  50% {
      transform: translateY(-3px);
  }
}

/* Enhanced monster styling from paste.txt */
.monster {
  position: relative;
  width: 130px;
  height: 180px;
  border-radius: 12px;
  padding: 8px;
  margin: 5px;
  background: linear-gradient(135deg, rgba(30, 30, 40, 0.8), rgba(10, 10, 15, 0.9));
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  color: white;
  text-align: center;
  display: inline-block;
  vertical-align: top;
  overflow: hidden;
}

.monster:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(255, 255, 255, 0.1);
}

.monster-name {
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.7), transparent, rgba(0, 0, 0, 0.7));
  padding: 3px 0;
  border-radius: 3px;
  z-index: 2;
  position: relative;
}

.monster-image-container {
  width: 110px;
  height: 90px;
  margin: 0 auto;
  border-radius: 8px;
  background: radial-gradient(circle at center, rgba(60, 60, 70, 0.5), rgba(20, 20, 30, 0.8));
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
}

.monster-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Fallback monster image */
.monster-image-container div.monster-image {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.monster-hp, .monster-type, .monster-level {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  border-radius: 5px;
  padding: 3px 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 2;
  position: relative;
  font-size: 12px;
  margin: 3px 0;
}

.monster-hp {
  color: #4ade80;
  font-weight: bold;
  text-shadow: 0 0 5px rgba(74, 222, 128, 0.5);
}

.monster-type {
  position: absolute;
  bottom: 5px;
  right: 5px;
  font-size: 10px;
  font-weight: bold;
}

.monster-level {
  position: absolute;
  bottom: 5px;
  left: 5px;
  font-size: 10px;
  font-weight: bold;
}

/* Enhanced card styling from paste.txt */
.card {
  width: 120px;
  height: 170px;
  border-radius: 10px;
  margin: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.3));
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  display: inline-flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.card.selected {
  z-index: 11;
  transform: translateY(-8px) scale(1.12) rotate(0deg) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.6);
}

.card-header {
  height: 30px;
  padding: 5px 8px;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  font-size: 12px;
}

.card-name {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.card-cost {
  background: linear-gradient(135deg, rgba(60, 60, 70, 0.7), rgba(20, 20, 30, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  min-width: 25px;
  height: 25px;
  border-radius: 50%;
  padding: 0 2px;
}

.energy-icon {
  font-size: 14px;
  margin-left: 2px;
}

.card-image-container {
  position: relative;
  background: radial-gradient(circle at center, rgba(50, 50, 60, 0.5), rgba(30, 30, 40, 0.7));
  height: 80px;
  overflow: hidden;
}

.card-image-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  pointer-events: none;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-image-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.card-effect-overlay {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  text-transform: uppercase;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 5px 0;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: white;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
}

.card-effect-overlay.damage-effect {
  background-color: rgba(231, 76, 60, 0.7);
}

.card-effect-overlay.heal-effect {
  background-color: rgba(46, 204, 113, 0.7);
}

.card-effect-overlay.stun-effect {
  background-color: rgba(243, 156, 18, 0.7);
}

.card-info {
  background: linear-gradient(to bottom, rgba(40, 40, 50, 0.8), rgba(20, 20, 30, 0.9));
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex: 1;
  display: flex;
  flex-direction: column;
  color: white;
}

.card-type {
  font-size: 9px;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-description {
  font-size: 10px;
  flex: 1;
  overflow: hidden;
}

/* Status Effects and Indicators */
.effects-container {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  flex-direction: column;
  z-index: 3;
}

.effect-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.effect-icon.damage {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  color: white;
}

.effect-icon.heal {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  color: white;
}

.effect-icon.stun {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: white;
}

.turn-counter {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background-color: black;
  color: white;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  font-size: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Enhanced team containers from paste.txt */
#player-team, #enemy-team {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin: 15px 0;
  padding: 10px;
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
}

/* Animation effects */
@keyframes damage-flash {
  0% { background-color: rgba(0, 0, 0, 0.7); }
  50% { background-color: rgba(231, 76, 60, 0.7); }
  100% { background-color: rgba(0, 0, 0, 0.7); }
}

.damage-flash {
  animation: damage-flash 0.6s;
}

@keyframes heal-flash {
  0% { background-color: rgba(0, 0, 0, 0.7); }
  50% { background-color: rgba(46, 204, 113, 0.7); }
  100% { background-color: rgba(0, 0, 0, 0.7); }
}

.heal-flash {
  animation: heal-flash 0.6s;
}

@keyframes stun-flash {
  0% { background-color: rgba(0, 0, 0, 0.7); }
  50% { background-color: rgba(243, 156, 18, 0.7); }
  100% { background-color: rgba(0, 0, 0, 0.7); }
}

.stun-flash {
  animation: stun-flash 0.6s;
}

.stun-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(243, 156, 18, 0.3);
  z-index: 5;
  pointer-events: none;
  animation: stun-pulse 2s infinite;
}

@keyframes stun-pulse {
  0% { opacity: 0.3; }
  50% { opacity: 0.5; }
  100% { opacity: 0.3; }
}

/* Enhanced hand container from paste.txt */
#hand-container {
  padding: 15px;
  padding-top: 0;
  /* margin-top: 40px; */
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 15px;
  margin: 15px 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow-x: visible;
  overflow-y: visible !important;
  position: relative;
  z-index: 5;
  min-height: 220px; /* Increased height to accommodate the cards */
  width: 90%; /* Slightly reduced from 100% to add margins */
  max-width: 800px; /* Limit maximum width */
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 5px 15px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
}

/* Custom scrollbar styling */
#hand-container::-webkit-scrollbar {
  height: 8px;
  position: absolute;
  bottom: 0;
}

#hand-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

#hand-container::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

/* Adjust card spacing and fan effect */
#hand-container .card {
  margin: 0 10px 40px 10px; /* Increased bottom margin to make room for cards when they rise */
  transform-origin: center bottom;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  position: relative; 
  z-index: 5;
}

/* Refined fan effect with less extreme angles */
#hand-container .card:nth-child(1) { transform: rotate(-8deg) translateY(5px); }
#hand-container .card:nth-child(2) { transform: rotate(-4deg) translateY(3px); }
#hand-container .card:nth-child(3) { transform: rotate(0deg); }
#hand-container .card:nth-child(4) { transform: rotate(4deg) translateY(3px); }
#hand-container .card:nth-child(5) { transform: rotate(8deg) translateY(5px); }

/* Enhanced hover effects */
#hand-container .card:hover {
  z-index: 10;
  transform: translateY(-25px) scale(1.08) rotate(0deg) !important;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 255, 255, 0.2);
}

#hand-container .card.selected {
  z-index: 11;
  transform: translateY(-35px) scale(1.12) rotate(0deg) !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(255, 215, 0, 0.6);
}

/* Enhanced battle action buttons */
#battle-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 15px;
}

/* Enhanced energy indicator */
.energy-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  /* margin: 15px 0; */
  gap: 5px;
  padding: 8px;
  background-color: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.energy-point {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6), inset 0 -2px 5px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.energy-point.used {
  background: linear-gradient(135deg, #6b7280, #4b5563);
  box-shadow: 0 0 5px rgba(75, 85, 99, 0.3), inset 0 -2px 5px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0.6;
}

/* Enhanced targeting */
.monster.potential-target {
  outline: 3px dashed gold;
  outline-offset: 3px;
  animation: targetPulse 1.5s infinite;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
  cursor: pointer;
}

@keyframes targetPulse {
  0%, 100% { outline-offset: 3px; box-shadow: 0 0 15px rgba(255, 215, 0, 0.5); }
  50% { outline-offset: 6px; box-shadow: 0 0 25px rgba(255, 215, 0, 0.7); }
}

.monster.friendly-target.potential-target {
  outline-color: #4ade80;
  box-shadow: 0 0 15px rgba(74, 222, 128, 0.5);
}

.monster.enemy-target.potential-target {
  outline-color: #f87171;
  box-shadow: 0 0 15px rgba(248, 113, 113, 0.5);
}

/* Enhanced target line */
.target-indicator {
  position: fixed;
  pointer-events: none;
  z-index: 150;
  display: none;
}

.target-indicator .target-line {
  position: absolute;
  height: 4px;
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.9), rgba(255, 255, 255, 0.9));
  border-radius: 4px;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.7));
  transform-origin: 0 50%;
}

.target-indicator .target-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 18px solid gold;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.7));
  transform: rotate(90deg);
}

/* Animation keyframes enhancement */
@keyframes float-up {
  0% {
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -200%) scale(1.3);
    opacity: 0;
  }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.7); }
  50% { box-shadow: 0 0 30px rgba(255, 255, 255, 0.9); }
}

@keyframes rotate-attack {
  0% { transform: rotate(-5deg); }
  50% { transform: rotate(5deg); }
  100% { transform: rotate(-5deg); }
}

@keyframes attack-bounce {
  0% { transform: translateX(0) scale(1); }
  40% { transform: translateX(-10px) scale(1.1); }
  60% { transform: translateX(5px) scale(0.9); }
  80% { transform: translateX(-3px) scale(1); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes heal-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

@keyframes stun-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px) rotate(-2deg); }
  20%, 40%, 60%, 80% { transform: translateX(5px) rotate(2deg); }
}

@keyframes explode {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Team Edit Styles */
.team-edit {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  z-index: 20;
  max-width: 80%;
  max-height: 80%;
  overflow-y: auto;
}

.team-edit h2 {
  text-align: center;
}

.monster-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-height: 300px;
  overflow-y: auto;
}

.selected {
  border: 2px solid gold;
}

/* Queue indicators */
.queue {
  display: flex;
  margin-bottom: 10px;
}

.queue-item {
  width: 30px;
  height: 30px;
  margin: 2px;
  background-color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

/* Modal and UI component styles */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  z-index: 100;
  text-align: center;
}

.status-effect {
  position: absolute;
  bottom: 5px;
  left: 5px;
  font-size: 10px;
  color: #e74c3c;
}

/* Volume control styles */
.volume-controls {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.volume-control {
  margin: 0 10px;
}

.volume-slider {
  width: 100px;
}

/* Save/Load styles */
.save-load-controls {
  margin-top: 10px;
  text-align: center;
}

.save-game-btn, .load-game-btn {
  margin: 0 10px;
}

#file-upload {
  display: none;
}

/* Labyrinth map styles */
#labyrinth-map {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

#labyrinth-map:hover {
  transform: scale(1.05);
}

.map-toggle {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

.map-toggle:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
}

.map-toggle:active {
  transform: translateY(1px);
}

/* Fullscreen button styles */
#fullscreen-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 30;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 18px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#fullscreen-button:hover {
  background-color: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

/* Orientation message for mobile devices */
.orientation-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
}

/* Mobile touch indicator */
#mobile-touch-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 90;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
  /* Improve button size for touch */
  button {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 15px;
    margin: 5px;
    font-size: 16px;
  }
  
  /* Ensure text is readable */
  #ui-container {
    font-size: 16px;
  }
  
  /* Make cards larger and easier to tap */
  .card {
    min-width: 100px;
    min-height: 140px;
    margin: 8px;
  }

  #labyrinth-map {
    width: 200px;
    height: 200px;
    top: 5px;
    right: 5px;
  }
  
  .map-toggle {
    top: 5px;
    right: 210px;
    padding: 4px 8px;
    font-size: 12px;
  }
  
  .monster {
    width: 100px;
    height: 140px;
  }
  
  /* Improve control hint readability */
  .control-hint {
    font-size: 14px;
    padding: 8px;
    margin: 5px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 5px;
  }
}

/* Additional styles for landscape mode */
@media (max-width: 768px) and (orientation: landscape) {
  /* Adjust UI for landscape phones */
  #ui-container {
    padding: 5px;
  }
  
  /* Smaller cards in landscape to fit more */
  .card {
    width: 90px;
    height: 130px;
  }
  
  /* Compress team displays */
  #player-team, #enemy-team {
    gap: 8px;
    margin: 8px 0;
    padding: 5px;
  }
  
  .monster {
    width: 80px;
    height: 120px;
    padding: 5px;
  }
}