/* Coordinated avatar-ability and combat-log HUD skin.
   Layout/open-state rules stay in style.css and mobile-game.css. */
body.in-game .ability-panel,
body.in-game .log-panel {
  --hud-panel-accent: 218, 166, 69;
  --hud-panel-accent-soft: 244, 216, 139;
  isolation: isolate;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d6a441 rgba(32, 23, 10, 0.72);
  border: 1px solid rgba(219, 171, 76, 0.62) !important;
  border-radius: 4px !important;
  background:
    radial-gradient(circle at 50% -8%, rgba(225, 177, 79, 0.14), transparent 43%),
    linear-gradient(145deg, rgba(206, 154, 61, 0.1), transparent 36%),
    linear-gradient(180deg, rgba(17, 20, 21, 0.99), rgba(5, 8, 10, 0.985)) !important;
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.42),
    inset 0 0 0 4px rgba(232, 186, 92, 0.08),
    inset 0 1px rgba(255, 255, 255, 0.1),
    0 14px 34px rgba(0, 0, 0, 0.52),
    0 0 18px rgba(218, 166, 69, 0.1) !important;
}

body.in-game .log-panel {
  --hud-panel-accent: 184, 133, 47;
}

/* Keep the title rail outside the scrolling area.  When the whole panel was
   scrollable, ability text could leak through the panel's top padding above
   the sticky header. */
body.in-game:not(.spectator-mode) .ability-panel {
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
}

body.in-game .ability-panel .hud-panel-header {
  position: relative;
  top: auto;
  flex: 0 0 auto;
  background:
    linear-gradient(90deg, rgb(38, 31, 19), rgb(10, 12, 13) 68%),
    rgb(10, 12, 13);
}

body.in-game .ability-panel .ability-cards {
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  grid-auto-rows: max-content;
  overflow-x: hidden;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #d6a441 rgba(32, 23, 10, 0.72);
}

body.in-game .ability-panel .ability-cards::-webkit-scrollbar,
body.in-game .log-panel::-webkit-scrollbar {
  width: 8px;
}

body.in-game .ability-panel .ability-cards::-webkit-scrollbar-track,
body.in-game .log-panel::-webkit-scrollbar-track {
  border-left: 1px solid rgba(231, 190, 100, 0.12);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025), transparent),
    rgba(24, 17, 8, 0.76);
  box-shadow: inset 1px 0 4px rgba(0, 0, 0, 0.58);
}

body.in-game .ability-panel .ability-cards::-webkit-scrollbar-thumb,
body.in-game .log-panel::-webkit-scrollbar-thumb {
  min-height: 34px;
  border: 1px solid rgba(255, 229, 154, 0.72);
  border-radius: 2px;
  background:
    linear-gradient(90deg, rgba(255, 244, 202, 0.26), transparent 42%),
    linear-gradient(180deg, #e0b552, #9a5f18);
  box-shadow:
    inset 0 0 0 1px rgba(72, 38, 7, 0.34),
    0 0 6px rgba(218, 166, 69, 0.34);
}

body.in-game .ability-panel .ability-cards::-webkit-scrollbar-thumb:hover,
body.in-game .log-panel::-webkit-scrollbar-thumb:hover {
  background:
    linear-gradient(90deg, rgba(255, 248, 220, 0.34), transparent 42%),
    linear-gradient(180deg, #f0cf79, #b77720);
}

body.in-game .hud-panel-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  margin: -2px -2px 10px;
  padding: 4px 4px 9px 2px;
  border-bottom: 1px solid rgba(222, 176, 84, 0.42);
  background:
    linear-gradient(90deg, rgba(38, 31, 19, 0.98), rgba(10, 12, 13, 0.98) 68%),
    rgba(10, 12, 13, 0.98);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.18);
}

body.in-game .hud-panel-header::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #dcae55 28%, #f4dd9c 50%, #dcae55 72%, transparent);
  pointer-events: none;
}

body.in-game .hud-panel-header h3 {
  min-width: 0;
  margin: 0 !important;
  color: #fff4d1 !important;
  font-family: "Cinzel", Georgia, serif;
  font-size: clamp(0.78rem, 1.08vw, 0.98rem) !important;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-shadow: 0 2px 3px #000, 0 0 12px rgba(var(--hud-panel-accent-soft), 0.32);
  overflow-wrap: anywhere;
}

body.in-game .hud-panel-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.in-game .hud-panel-emblem::after {
  content: none;
}

body.in-game .hud-panel-emblem img {
  width: 118%;
  height: 118%;
  object-fit: contain;
  filter: saturate(1.08) contrast(1.05) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.72)) drop-shadow(0 0 5px rgba(var(--hud-panel-accent-soft), 0.32));
}

body.in-game .hud-panel-emblem.log-emblem img {
  width: 105%;
  height: 105%;
}

body.in-game .hud-panel-header .close-panel-btn {
  justify-self: end;
  width: 27px;
  height: 27px;
  margin: 0;
  border: 1px solid rgba(255, 224, 143, 0.38);
  border-radius: 50%;
  background: rgba(1, 8, 14, 0.62);
  color: #ffe9ad;
  line-height: 24px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07);
}

body.in-game .ability-cards {
  gap: 9px !important;
}

body.in-game .ability-card {
  position: relative;
  overflow: hidden;
  padding: 10px !important;
  border: 1px solid rgba(190, 145, 61, 0.34) !important;
  border-radius: 4px !important;
  background:
    linear-gradient(135deg, rgba(221, 172, 76, 0.10), transparent 42%),
    linear-gradient(180deg, rgba(25, 25, 22, 0.97), rgba(9, 11, 12, 0.97)) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 7px 16px rgba(0, 0, 0, 0.25) !important;
}

body.in-game .ability-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: linear-gradient(180deg, #f4d88b, #c68c2c 54%, transparent);
  box-shadow: 0 0 9px rgba(222, 170, 66, 0.38);
}

body.in-game .ability-card-header {
  gap: 7px;
}

body.in-game .ability-card strong {
  color: #fff4d6 !important;
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.76rem !important;
  line-height: 1.2;
  text-shadow: 0 1px 2px #000;
}

body.in-game .ability-card-header > div:first-child > span {
  display: block;
  margin-top: 3px;
  color: rgba(219, 190, 128, 0.86) !important;
  font-size: 0.61rem !important;
  line-height: 1.2;
}

body.in-game .ability-uses-badge {
  min-width: 38px;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(244, 207, 116, 0.68) !important;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 241, 190, 0.16), transparent 46%),
    linear-gradient(180deg, rgba(119, 78, 24, 0.92), rgba(45, 30, 13, 0.96)) !important;
  color: #ffe3a0 !important;
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.62rem !important;
  font-weight: 900;
  letter-spacing: 0.025em;
  text-shadow: 0 1px 2px #000;
  box-shadow:
    inset 0 1px rgba(255, 244, 204, 0.13),
    0 2px 5px rgba(0, 0, 0, 0.38);
}

body.in-game .ability-uses-badge.is-infinite {
  color: #f6ca69 !important;
  text-shadow: 0 0 7px rgba(225, 174, 72, 0.4);
}

body.in-game .ability-card p {
  margin: 7px 0 9px !important;
  color: rgba(238, 244, 245, 0.92) !important;
  line-height: 1.34 !important;
}

body.in-game .ability-card.locked,
body.in-game .ability-card.used {
  opacity: 0.58;
  filter: saturate(0.55);
}

body.in-game .ability-card:not(.locked):not(.used):has(.ability-use-btn:not(:disabled)) {
  border-color: rgba(255, 222, 122, 0.66) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.09), 0 0 15px rgba(218, 166, 69, 0.16) !important;
}

body.in-game .ability-use-btn {
  min-height: 38px !important;
  border: 1px solid rgba(255, 226, 145, 0.78) !important;
  border-radius: 4px !important;
  background:
    linear-gradient(180deg, rgba(255, 236, 169, 0.34), transparent 42%),
    linear-gradient(180deg, #dca746, #9b6017) !important;
  color: #211204 !important;
  box-shadow:
    inset 0 1px rgba(255, 250, 217, 0.48),
    inset 0 -2px rgba(75, 39, 3, 0.32),
    0 4px 10px rgba(0, 0, 0, 0.38),
    0 0 10px rgba(218, 166, 69, 0.18) !important;
}

body.in-game .ability-use-btn span {
  color: #ffffff !important;
  font-family: "Cinzel", Georgia, serif;
  font-size: 0.78rem !important;
  letter-spacing: 0.075em;
  text-shadow: 0 2px 3px rgba(34, 16, 1, 0.92), 0 0 8px rgba(255, 239, 180, 0.22) !important;
}

body.in-game .ability-use-btn:not(:disabled):hover,
body.in-game .ability-use-btn:not(:disabled):focus-visible {
  filter: brightness(1.13);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.38), 0 0 17px rgba(237, 187, 78, 0.34) !important;
}

body.in-game .ability-use-btn:disabled {
  border-color: rgba(163, 132, 75, 0.28) !important;
  background: linear-gradient(180deg, rgba(126, 103, 64, 0.24), rgba(43, 37, 28, 0.42)) !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04) !important;
}

body.in-game .ability-use-btn:disabled span {
  color: rgba(207, 187, 148, 0.48) !important;
  text-shadow: 0 1px 2px #000 !important;
}

body.in-game .game-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.in-game .game-log > .small {
  padding: 12px 8px;
  border: 1px dashed rgba(106, 207, 229, 0.28);
  border-radius: 9px;
  color: rgba(210, 231, 235, 0.78);
  text-align: center;
}

body.in-game .log-entry {
  position: relative;
  margin: 0 !important;
  padding: 8px 8px 8px 12px !important;
  border: 1px solid rgba(184, 139, 55, 0.2) !important;
  border-left: 3px solid rgba(211, 162, 65, 0.82) !important;
  border-radius: 3px;
  background: linear-gradient(100deg, rgba(180, 132, 45, 0.10), rgba(7, 10, 12, 0.7)) !important;
  color: rgba(237, 246, 246, 0.94) !important;
  font-size: 0.72rem !important;
  line-height: 1.36;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

body.in-game .log-entry:first-child {
  border-color: rgba(255, 222, 132, 0.34) !important;
  border-left-color: #f5cc67 !important;
  background: linear-gradient(100deg, rgba(225, 171, 54, 0.15), rgba(4, 14, 22, 0.58)) !important;
}

body.in-game .log-entry.log-entry-enemy {
  border-color: rgba(167, 49, 42, 0.42) !important;
  border-left-color: #d94b40 !important;
  background: linear-gradient(100deg, rgba(136, 29, 25, 0.24), rgba(18, 8, 9, 0.76)) !important;
  color: #ffaaa0 !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.86), 0 0 7px rgba(215, 55, 45, 0.18);
}

body.in-game .mobile-panel-toggle {
  gap: 6px;
  overflow: hidden;
  border-color: rgba(218, 168, 72, 0.7) !important;
  border-radius: 4px !important;
  background: linear-gradient(180deg, rgba(47, 37, 20, 0.98), rgba(10, 12, 13, 0.98)) !important;
  color: #fff0c3 !important;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.12), 0 5px 14px rgba(0, 0, 0, 0.42), 0 0 13px rgba(218, 168, 72, 0.16) !important;
}

body.in-game .mobile-panel-toggle-icon {
  width: 31px;
  height: 31px;
  margin: -5px 0 -4px;
  flex: 0 0 auto;
  object-fit: contain;
  filter: saturate(1.12) contrast(1.05) drop-shadow(0 0 5px rgba(87, 208, 255, 0.46));
}

body.in-game .mobile-panel-toggle.log-toggle .mobile-panel-toggle-icon {
  width: 28px;
  height: 28px;
}

@media (max-width: 760px), (pointer: coarse) and (max-width: 1366px) {
  body.in-game .hud-panel-header {
    grid-template-columns: 40px minmax(0, 1fr) 28px;
    min-height: 45px;
    gap: 7px;
    margin-bottom: 7px;
    padding-bottom: 7px;
  }

  body.in-game .hud-panel-emblem {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  body.in-game .hud-panel-header h3 {
    font-size: clamp(0.72rem, 3vw, 0.88rem) !important;
  }

  body.in-game .ability-cards {
    gap: 7px !important;
  }

  body.in-game .ability-card {
    padding: 8px !important;
  }

  body.in-game .ability-card p {
    margin: 5px 0 7px !important;
  }

  body.in-game .ability-use-btn {
    min-height: 32px !important;
  }

  body.in-game .log-entry {
    padding: 7px 7px 7px 10px !important;
    font-size: clamp(0.65rem, 2.55vw, 0.75rem) !important;
  }

  body.in-game .mobile-panel-toggle-icon {
    width: 29px;
    height: 29px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  body.in-game .hud-panel-emblem.ability-emblem img {
    animation: hud-ability-glow 2.8s ease-in-out infinite;
  }
}

@keyframes hud-ability-glow {
  0%, 100% {
    filter: saturate(1.04) contrast(1.04) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.72)) drop-shadow(0 0 4px rgba(244, 216, 139, 0.24));
  }
  50% {
    filter: saturate(1.12) contrast(1.07) brightness(1.08) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.72)) drop-shadow(0 0 6px rgba(244, 216, 139, 0.36));
  }
}
