/* A fitted brass spell case. Elemental colour belongs to the device and its
   readiness line; names and costs remain readable in every casting state. */
#ui #spellbar {
  container: crown-spells / inline-size;
  right: var(--spell-right-w, var(--right-w, 0px));
  pointer-events: none;
  overflow: visible;
}
#ui #spellbar .spell-rack {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: max-content;
  max-width: calc(100% - 12px);
  padding: 7px;
  position: relative;
  border: 1px solid var(--border-lt);
  border-radius: var(--r-card);
  background: linear-gradient(110deg, #675037 0%, #281f18 8%, #201d1a 85%, #584630);
  box-shadow: inset 0 1px #e6c99066, inset 0 -2px #0d0c0b, 0 5px 16px #0008;
  pointer-events: auto;
}
#ui #spellbar .spell {
  --spell-accent: #c7b58b;
  --spell-aura: #83765a38;
  display: grid;
  grid-template-rows: 55px 30px 18px;
  justify-items: center;
  align-content: start;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  width: 94px;
  height: auto;
  min-height: 127px;
  padding: 8px 6px 10px;
  border: 1px solid #78654b;
  border-radius: var(--r-ctl);
  background: radial-gradient(ellipse at 50% 18%, var(--spell-aura), transparent 65%), linear-gradient(160deg, #292928, #15191b 58%, #101415);
  box-shadow: inset 0 1px #eee0c126, inset 0 -1px #000, 0 1px 3px #0009;
  color: var(--parch);
  isolation: isolate;
  transition: border-color .16s, background-color .16s, transform .16s, box-shadow .16s;
}
#ui #spellbar .spell[data-s="fireball"] { --spell-accent: #e9ad71; --spell-aura: #ce793638; }
#ui #spellbar .spell[data-s="frostnova"] { --spell-accent: #b0d7dd; --spell-aura: #719daa38; }
#ui #spellbar .spell[data-s="healrain"] { --spell-accent: #a6d2af; --spell-aura: #6f9d8038; }
#ui #spellbar .spell[data-s="meteor"] { --spell-accent: #e1a77f; --spell-aura: #b7724738; }
#ui #spellbar .spell[data-s="timewarp"] { --spell-accent: #c7b5df; --spell-aura: #8f7daf38; }
#ui #spellbar .spell[data-s="spirits"] { --spell-accent: #abd0cc; --spell-aura: #70a1a338; }
#ui #spellbar .spell::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid #ad93602e;
  border-radius: 1px;
  pointer-events: none;
}
#ui #spellbar .spell::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  background: linear-gradient(to right, var(--spell-accent) var(--spell-ready, 100%), #070b0d var(--spell-ready, 100%));
  opacity: .6;
  pointer-events: none;
}
#ui #spellbar .spell-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 55px;
  height: 55px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--spell-aura), #111719 69%);
  border: 1px solid #b09b684a;
  box-shadow: inset 0 0 0 3px #0d121370, 0 1px #dfc28b17;
}
#ui #spellbar .spell-icon svg {
  width: 51px;
  height: 51px;
  overflow: visible;
  filter: drop-shadow(0 2px 2px #0009);
}
#ui #spellbar .spell-name {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  width: 100%;
  min-width: 0;
  max-width: none;
  font: 600 11px/1.3 var(--font-head);
  letter-spacing: .015em;
  text-align: center;
  color: #f0e5ca;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  text-wrap: balance;
}
#ui #spellbar .spell-cost {
  gap: 5px;
  color: #cbbfd9;
  font: 600 13px/18px var(--font-body);
  font-variant-numeric: tabular-nums;
}
#ui #spellbar .spell-cost svg { opacity: .85; }
#ui #spellbar .spell-cd {
  inset: 8px auto auto 50%;
  transform: translateX(-50%);
  width: 55px;
  height: 55px;
  border: 1px solid #ac94666b;
  border-radius: 50%;
  background: #101619e8;
  color: #f2e8ce;
  font: 600 24px/1 var(--font-head);
  font-variant-numeric: tabular-nums;
  gap: 1px;
}
#ui #spellbar .spell-cd::after { content: 's'; font: 12px var(--font-body); margin-top: 8px; color: var(--muted); }
#ui #spellbar .spell-aim {
  display: none;
  position: absolute;
  z-index: 2;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border: 1px solid #cfb17a;
  border-radius: 2px;
  background: #32291c;
  color: #ffe9b1;
  font: 600 9px/1.2 var(--font-body);
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
#ui #spellbar .spell:hover {
  transform: translateY(-2px);
  border-color: #d2bd8b;
  box-shadow: inset 0 1px #eee0c136, 0 3px 10px #0008;
}
#ui #spellbar .spell:hover .spell-icon { border-color: var(--spell-accent); }
#ui #spellbar .spell.selected {
  border-color: #e2c78c;
  background: radial-gradient(ellipse at 50% 20%, var(--spell-aura), transparent 75%), linear-gradient(160deg, #3e3829, #1e201d 70%);
  box-shadow: inset 0 0 0 1px #dfc38a66, 0 0 0 1px #b6995766, 0 3px 10px #0008;
}
#ui #spellbar .spell.selected .spell-aim { display: block; }
#ui #spellbar .spell.selected::after { opacity: 1; }
#ui #spellbar .spell:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; z-index: 3; }
#ui #spellbar .spell:active { transform: translateY(1px); }
#ui #spellbar .spell.cooling { opacity: 1; }
#ui #spellbar .spell.cooling .spell-name { color: #c4baa5; }
#ui #spellbar .spell.poor { filter: none; border-color: #766353; }
#ui #spellbar .spell.poor .spell-icon { filter: saturate(.35); opacity: .65; }
#ui #spellbar .spell.poor .spell-cost { color: #e8b398; }
#ui #spellbar .spell.poor:hover { border-color: #bd977b; }
#ui.uiw-lt1200 #spellbar .spell { width: 82px; min-height: 115px; padding: 7px 5px 9px; grid-template-rows: 48px 28px 17px; }
#ui.uiw-lt1200 #spellbar .spell-icon { width: 48px; height: 48px; }
#ui.uiw-lt1200 #spellbar .spell-icon svg { width: 45px; height: 45px; }
#ui.uiw-lt1200 #spellbar .spell-cd { top: 7px; width: 48px; height: 48px; }
#ui.uiw-lt1200 #spellbar .spell-name { font-size: 10.5px; }
@container crown-spells (max-width: 550px) {
  #ui #spellbar .spell-rack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 450px; gap: 7px 5px; }
  #ui #spellbar .spell-rack .spell {
    width: 100%; min-width: 0; min-height: 69px; padding: 7px 5px 9px;
    grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: 28px 18px; column-gap: 5px;
  }
  #ui #spellbar .spell-rack .spell-icon { grid-column: 1; grid-row: 1 / 3; width: 36px; height: 36px; }
  #ui #spellbar .spell-rack .spell-icon svg { width: 35px; height: 35px; }
  #ui #spellbar .spell-rack .spell-name { grid-column: 2; grid-row: 1; font-size: 10px; text-align: left; justify-content: flex-start; }
  #ui #spellbar .spell-rack .spell-cost { grid-column: 2; grid-row: 2; justify-self: start; font-size: 12px; gap: 3px; }
  #ui #spellbar .spell-rack .spell-cd { top: 13px; left: 23px; width: 36px; height: 36px; font-size: 18px; }
  #ui #spellbar .spell-rack:not(:has(.spell:nth-child(3))) .spell { width: 135px; }
  #ui #spellbar .spell-rack:not(:has(.spell:nth-child(3))) { display: flex; width: max-content; }
}
@container crown-spells (max-width: 390px) {
  #ui #spellbar .spell-rack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container crown-spells (max-width: 260px) {
  #ui #spellbar .spell-rack { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { #ui #spellbar .spell { transition: none; } }
body.reduce-motion #ui #spellbar .spell { transition: none; }
