/* =========================================================
   FANTASY MATCH: THE SHATTERED REALMS
   Core Theme, Global Typography & Fantasy RPG Frames
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=MedievalSharp&family=Nunito:wght@600;700;800;900&display=swap');

:root {
  --bg-dark: #0e0d13;
  --panel-bg: #1c1822;
  --panel-border: #4d3824;
  --panel-border-inner: #876135;
  --gold: #f39c12;
  --gold-glow: #ffeaa7;
  --gold-dark: #b87309;
  --crimson: #c0392b;
  --crimson-glow: #ff7675;
  --azure: #2980b9;
  --emerald: #27ae60;
  --amethyst: #8e44ad;
  --text-main: #f5f6fa;
  --text-muted: #a4b0be;
  
  --rarity-common: #b0bec5;
  --rarity-uncommon: #4caf50;
  --rarity-rare: #2196f3;
  --rarity-epic: #9c27b0;
  --rarity-legendary: #ff9800;
  --rarity-mythic: #e91e63;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #07060d;
  background-image: 
    radial-gradient(circle at 50% 50%, rgba(10, 8, 16, 0.3) 0%, rgba(3, 2, 6, 0.85) 100%),
    url('../assets/wallpaper.svg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text-main);
  font-family: 'Nunito', sans-serif;
  overflow: hidden;
  width: 100%;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  box-sizing: border-box;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Master Game Container - Max aspect ratio fit */
#game-app {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  max-height: 900px;
  background: #11141a;
  box-shadow: 
    0 0 70px rgba(0, 0, 0, 0.95), 
    0 0 0 3px var(--panel-border-inner),
    0 0 0 6px #090710,
    0 0 35px rgba(243, 156, 18, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 14px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* Fantasy RPG Button Styles */
.rpg-btn {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: linear-gradient(to bottom, #795548, #4e342e);
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.1s ease, filter 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.rpg-btn:hover {
  filter: brightness(1.15);
}

.rpg-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 3px rgba(0,0,0,0.6);
}

.rpg-btn.gold {
  background: linear-gradient(to bottom, #f39c12, #b87309);
  color: #1e1102;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  border-color: #ffeaa7;
}

.rpg-btn.danger {
  background: linear-gradient(to bottom, #d63031, #b71540);
  border-color: #ff7675;
}

.rpg-btn.primary {
  background: linear-gradient(to bottom, #0984e3, #0652dd);
  border-color: #74b9ff;
}

/* Modals Overlay */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 8, 14, 0.88);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  width: 100%;
  max-width: 480px;
  max-height: 90%;
  background: linear-gradient(135deg, #1e1927 0%, #130f1b 100%);
  border: 3px solid var(--panel-border-inner);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8), inset 0 0 15px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-window {
  transform: scale(1);
}

.modal-header {
  padding: 14px 18px;
  background: linear-gradient(to bottom, #2d233a, #1a1424);
  border-bottom: 2px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s ease;
}

.modal-close-btn:hover {
  color: #ff4757;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Custom Scrollbars */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--panel-border-inner);
  border-radius: 4px;
}

/* Tabs inside modals */
.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-tab-btn {
  flex: 1;
  padding: 8px 6px;
  background: #251e33;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-tab-btn.active {
  background: var(--panel-border-inner);
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.3);
}

/* =========================================================
   CUSTOM RPG DIALOG & NOTIFICATION MODAL
   ========================================================= */
.modal-overlay.custom-dialog-overlay {
  z-index: 10000;
  background: rgba(8, 6, 12, 0.85);
  backdrop-filter: blur(8px);
}

.custom-dialog-window {
  max-width: 420px;
  background: linear-gradient(160deg, #241a33 0%, #151022 100%);
  border: 2px solid #e1b12c;
  border-radius: 16px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.9), 0 0 25px rgba(225, 177, 44, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.7);
  animation: customDialogPop 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes customDialogPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.custom-dialog-header {
  padding: 14px 18px;
  background: linear-gradient(to right, #34244a, #1d152a);
  border-bottom: 2px solid rgba(225, 177, 44, 0.4);
}

.custom-dialog-header h2 {
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
}

.custom-dialog-body {
  padding: 22px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.custom-dialog-badge-wrapper {
  margin-bottom: 14px;
}

.custom-dialog-badge {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 177, 44, 0.3) 0%, rgba(30, 20, 45, 0.9) 70%);
  border: 2px solid #e1b12c;
  box-shadow: 0 0 18px rgba(225, 177, 44, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  animation: pulseBadge 2.2s infinite ease-in-out;
}

.custom-dialog-badge.warning {
  border-color: #ff7675;
  background: radial-gradient(circle, rgba(231, 76, 60, 0.3) 0%, rgba(30, 20, 45, 0.9) 70%);
  box-shadow: 0 0 18px rgba(231, 76, 60, 0.5);
}

.custom-dialog-badge.success {
  border-color: #2ecc71;
  background: radial-gradient(circle, rgba(46, 204, 113, 0.3) 0%, rgba(30, 20, 45, 0.9) 70%);
  box-shadow: 0 0 18px rgba(46, 204, 113, 0.5);
}

@keyframes pulseBadge {
  0%, 100% { transform: scale(1); box-shadow: 0 0 14px rgba(225, 177, 44, 0.35); }
  50% { transform: scale(1.06); box-shadow: 0 0 22px rgba(225, 177, 44, 0.7); }
}

.custom-dialog-message {
  font-size: 0.95rem;
  color: #f1f2f6;
  line-height: 1.6;
  margin-bottom: 22px;
  background: rgba(14, 11, 22, 0.75);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  white-space: pre-line;
}

.custom-dialog-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.custom-dialog-btn {
  flex: 1;
  padding: 11px 18px;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
}

.custom-dialog-btn.primary {
  background: linear-gradient(135deg, #f1c40f 0%, #d35400 100%);
  color: #1a0f00;
  border: 1px solid #ffd32a;
  box-shadow: 0 4px 14px rgba(241, 196, 15, 0.4);
}

.custom-dialog-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(241, 196, 15, 0.6);
  filter: brightness(1.1);
}

.custom-dialog-btn.danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  color: #fff;
  border: 1px solid #ff7675;
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
}

.custom-dialog-btn.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
  filter: brightness(1.1);
}

.custom-dialog-btn.secondary {
  background: #2c253d;
  color: #bdc3c7;
  border: 1px solid #4a3e63;
}

.custom-dialog-btn.secondary:hover {
  background: #39304f;
  color: #fff;
  transform: translateY(-2px);
}

/* Toast Notification Styles */
.rpg-toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 90vw;
}

.rpg-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(32, 24, 48, 0.96) 0%, rgba(18, 14, 28, 0.98) 100%);
  border: 1.5px solid #f1c40f;
  border-radius: 10px;
  padding: 10px 18px;
  color: #f1f2f6;
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.75), 0 0 12px rgba(241, 196, 15, 0.3);
  animation: toastSlideDown 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toastSlideDown {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.rpg-toast.toast-fadeout {
  opacity: 0;
  transform: translateY(-15px);
}

/* =========================================================
   Mobile Responsive & Fullscreen Anti-Flicker Adaptations
   ========================================================= */
@media (max-width: 600px) {
  html, body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    position: fixed;
    inset: 0;
  }

  #game-app {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
  }

  .modal-overlay {
    padding: 8px;
  }

  .modal-window {
    max-width: 100%;
    max-height: 96%;
    border-radius: 10px;
  }

  .custom-dialog-window {
    max-width: 92vw;
    padding: 18px 16px;
  }

  .fighter-sprite.is-boss-sprite {
    width: clamp(88px, 25vw, 126px);
    height: clamp(84px, 17vh, 124px);
    max-height: calc(100% - 56px);
  }
}

/* Short viewports (landscape or small vertical inspect screens) */
@media (max-height: 680px) {
  #battle-section {
    height: 34%;
    min-height: 185px;
  }
  
  .battle-header-info {
    padding: 3px 8px;
    height: 30px;
  }
  
  .round-pill {
    font-size: 0.72rem;
    padding: 2px 7px;
  }

  .environment-pill {
    font-size: 0.65rem;
    padding: 2px 6px;
    max-width: 36%;
  }

  .fighter-sprite {
    width: clamp(65px, 18vw, 95px);
    height: clamp(68px, 14vh, 98px);
    max-height: calc(100% - 48px);
  }

  .fighter-sprite.is-boss-sprite {
    width: clamp(78px, 23vw, 116px);
    height: clamp(78px, 15vh, 116px);
    max-height: calc(100% - 54px);
  }
}


