/* =========================================================
   FANTASY MATCH: THE SHATTERED REALMS
   Gameplay Layout (35% Battle, 55% Board, 10% HUD)
   ========================================================= */

/* Top Section: Battle Scene (~33-36%) */
#battle-section {
  position: relative;
  flex: 0 0 auto;
  height: 35%;
  min-height: 200px;
  max-height: 280px;
  background-size: cover;
  background-position: center bottom;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-bottom: 3px solid var(--panel-border-inner);
  box-shadow: inset 0 -10px 20px rgba(0,0,0,0.6);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Battle Sky & Environment Parallax */
.battle-environment {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.battle-environment svg {
  width: 100%;
  height: 100%;
  display: block;
}

.battle-ground {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 30%;
  background: linear-gradient(to top, rgba(15, 30, 20, 0.95), rgba(40, 75, 45, 0.4));
  border-top: 2px solid rgba(135, 195, 90, 0.3);
  z-index: 1;
  transition: background-color 0.4s ease;
}

/* Round & Milestone Header */
.battle-header-info {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0.2) 75%, transparent);
  flex-shrink: 0;
  height: 34px;
  box-sizing: border-box;
}

.round-pill {
  font-family: 'Cinzel', serif;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--gold-glow);
  background: rgba(20, 15, 28, 0.85);
  padding: 2px 9px;
  border-radius: 14px;
  border: 1px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  white-space: nowrap;
  flex-shrink: 0;
}

.environment-pill {
  font-family: 'Cinzel', serif;
  font-size: 0.68rem;
  color: #fff;
  background: rgba(0,0,0,0.6);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40%;
  text-align: center;
  flex-shrink: 1;
}

/* Battle Screen Specific Locking */
#screen-battle {
  overflow: hidden !important;
  touch-action: none !important;
  user-select: none;
  -webkit-user-select: none;
}

/* Combat Arena: Player Left, Enemy Right */
.combat-arena {
  position: relative;
  z-index: 5;
  flex: 1 1 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 6px 14px 4px;
  min-height: 0;
}

.fighter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  width: 165px;
  max-width: 48%;
  height: 100%;
  min-height: 0;
  transition: width 0.2s ease, max-width 0.2s ease;
}

.fighter-container.is-boss-container {
  width: 195px;
  max-width: 55%;
}

.fighter-sprite {
  width: clamp(72px, 20vw, 110px);
  height: clamp(75px, 15vh, 115px);
  max-height: calc(100% - 52px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6));
  transition: transform 0.15s ease, width 0.2s ease, height 0.2s ease;
  position: relative;
  flex-shrink: 1;
}

/* Colossal Boss Sprites (Dragon, Malakar, Ancient Drake) */
.fighter-sprite.is-boss-sprite {
  width: clamp(92px, 25vw, 138px);
  height: clamp(86px, 17vh, 128px);
  max-height: calc(100% - 58px);
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.85)) drop-shadow(0 0 16px rgba(224, 86, 253, 0.45));
  z-index: 6;
}

.fighter-sprite img,
.fighter-sprite svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Middle Section: Match-3 Board (Flex-fill remaining space) */
#board-section {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  background: #14111a;
  background-image: 
    radial-gradient(#201b2a 15%, transparent 16%),
    radial-gradient(#201b2a 15%, transparent 16%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  padding: 4px 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.board-outer-frame {
  position: relative;
  aspect-ratio: 7 / 6;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #1d1825;
  border: 3px solid var(--panel-border-inner);
  border-radius: 12px;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.8), 0 4px 10px rgba(0,0,0,0.6);
  padding: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
  margin: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 7 Columns x 6 Rows Board Grid */
#match3-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 3px;
  width: 100%;
  height: 100%;
  aspect-ratio: 7 / 6;
  min-height: 0;
  min-width: 0;
  touch-action: none;
  margin: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.grid-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
  background: #231d2e;
  border-radius: 6px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform 0.1s ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.gem-piece {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: transform 0.18s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.gem-piece img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.gem-piece.selected {
  transform: scale(1.12);
  filter: drop-shadow(0 0 8px var(--gold-glow)) brightness(1.2);
  z-index: 20;
}

/* Bottom Section: RPG HUD */
#hud-section {
  position: relative;
  flex: 0 0 auto;
  background: linear-gradient(to bottom, #1f192b, #130f1c);
  border-top: 2px solid var(--panel-border-inner);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 5px 8px 6px;
  z-index: 30;
}

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.hud-player-level {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lvl-badge {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 900;
  color: #1e1102;
  background: var(--gold);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #ffeaa7;
}

.xp-bar-container {
  width: 110px;
  height: 10px;
  background: #2d263b;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15);
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(to right, #00b894, #55efc4);
  width: 0%;
  transition: width 0.3s ease;
}

.gold-display {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.hud-actions-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 3px;
  width: 100%;
}

.hud-action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 1px 4px;
  background: #292036;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: #dfe4ea;
  font-size: 0.62rem;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  min-width: 0;
}

.hud-action-btn:hover {
  background: var(--panel-border-inner);
  color: var(--gold);
  border-color: var(--gold);
}

.hud-action-btn:active {
  transform: translateY(1px);
}

.hud-btn-icon {
  font-size: 0.95rem;
  line-height: 1;
  margin-bottom: 2px;
}

/* Floating Combat Numbers */
.floating-number {
  position: absolute;
  font-family: 'Cinzel', serif;
  font-weight: 900;
  font-size: 1.25rem;
  pointer-events: none;
  z-index: 50;
  animation: floatUpFade 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.8);
}

.floating-number.physical { color: #ffffff; }
.floating-number.crit { color: #f1c40f; font-size: 1.55rem; filter: drop-shadow(0 0 6px #e67e22); }
.floating-number.magic { color: #e74c3c; font-size: 1.35rem; }
.floating-number.burn { color: #e67e22; font-size: 1.1rem; }
.floating-number.frost { color: #74b9ff; font-size: 1.1rem; }
.floating-number.heal { color: #2ecc71; font-size: 1.25rem; }
.floating-number.shield { color: #fed330; font-size: 1.15rem; }
.floating-number.gold { color: #ffeaa7; font-size: 1.1rem; }
.floating-number.enemy_hit { color: #ff4757; font-size: 1.3rem; }

/* Combo Banner */
.combo-display-banner {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: linear-gradient(135deg, #d35400, #f39c12);
  border: 2px solid #fff;
  border-radius: 20px;
  padding: 6px 18px;
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  box-shadow: 0 0 20px rgba(243, 156, 18, 0.7);
  z-index: 60;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-display-banner.active {
  transform: translateX(-50%) scale(1);
}

