/* A spellbook in the same constellation palette as skills and equipment. */
#spells-panel {
  position: fixed; z-index: 20; inset: 0; transform: none;
  width: 100%; height: 100vh; height: 100dvh; max-width: none; max-height: none; min-width: 0;
  box-sizing: border-box; border: 0; border-radius: 0; box-shadow: none;
  display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0;
  overflow: auto; overscroll-behavior: contain; scroll-padding-top: 110px; color: #eff5ff;
  background: radial-gradient(ellipse at 12% 66%, #07697d47, transparent 48%),
    radial-gradient(ellipse at 58% 15%, #7125ba40, transparent 50%),
    radial-gradient(ellipse at 100% 90%, #c2297040, transparent 45%), #080d20;
}
.spells-header {
  position: sticky; top: 0; z-index: 5; flex: 0 0 auto; display: flex;
  align-items: center; justify-content: space-between; gap: 20px;
  padding: max(22px, env(safe-area-inset-top)) max(90px, calc(env(safe-area-inset-right) + 70px)) 20px max(32px, env(safe-area-inset-left));
  border-bottom: 1px solid #929aff28; background: #0b1027;
}
.spells-eyebrow { margin: 0 0 6px; color: #9d9fff; font-size: 10px; font-weight: 700; letter-spacing: .24em; }
#spells-title { margin: 0; color: #f5f3ff; font-size: clamp(24px, 2.8vw, 38px); line-height: 1.1; letter-spacing: .03em; text-align: left; }
.spells-access { margin: 0; color: #b2bddb; font-size: 12px; line-height: 1.7; text-align: right; }
.spells-access strong { display: block; color: #6df0d1; font-size: 13px; letter-spacing: .05em; }
#spells-panel #spells-close {
  position: fixed; z-index: 8; top: max(22px, env(safe-area-inset-top)); right: max(26px, env(safe-area-inset-right));
  display: grid; place-items: center; width: 48px; height: 48px; min-height: 48px; max-width: none;
  padding: 0; border: 1px solid #a0aaff77; border-radius: 12px; color: #e7edff;
  background: #202b4a; font-size: 28px; line-height: 1; cursor: pointer;
}
#spells-panel #spells-close:hover { border-color: #f2baff; background: #593875; color: #fff; }
#spells-panel button:focus-visible { outline: 3px solid #7ff6ff; outline-offset: 3px; }
.spells-content { width: min(100%, 1440px); box-sizing: border-box; margin: 0 auto; padding: 30px 32px; }
#spell-trades-damage { --spell-color: #7ce4d1; color: #d8f8ef; font-size: 13px; line-height: 1.6; }
.spells-section + .spells-section { margin-top: 32px; }
.spells-section-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 16px; }
#spells-panel .spells-section-heading h3 { margin: 0; color: #f1edff; font-size: 21px; letter-spacing: .03em; }
#spells-panel .spells-section-heading p { margin: 0; font-size: 12px; color: #a5b6d7; }
.spells-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.spells-grid-purchased { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.spell-card {
  --spell-color: #aa96ff; position: relative; min-width: 0; padding: 20px; border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--spell-color) 35%, #26304b);
  background: linear-gradient(150deg, color-mix(in srgb, var(--spell-color) 9%, #131b36), #0d142b);
  box-shadow: 0 15px 40px #02061233;
}
.spell-card[data-spell="attack"] { --spell-color: #ffb76f; }
.spell-card[data-spell="guard"] { --spell-color: #7fc9ff; }
.spell-card[data-spell="counter"] { --spell-color: #f1bdff; }
.spell-card[data-spell="evade"] { --spell-color: #6de6e4; }
.spell-card[data-spell="charge"] { --spell-color: #ffe083; }
.spell-card[data-spell="jump"] { --spell-color: #a5bcff; }
.spell-card[data-spell="heal"] { --spell-color: #72f0bd; }
.spell-card[data-spell="absorb"] { --spell-color: #ff709f; }
.spell-card[data-spell="unleash"] { --spell-color: #e899ff; }
.spell-card[data-spell="power-beam"] { --spell-color: #ffa36a; }
.spell-card[data-spell="oblivion"] { --spell-color: #ed879d; }
.spell-card[hidden] { display: none; }
.spell-art { display: block; width: 88px; height: 88px; max-width: 100%; margin: 0 auto 12px; object-fit: contain; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--spell-color) 20%, transparent)); }
.spell-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
#spells-panel .spell-card h4 { margin: 0; color: #f7f4ff; font-size: 17px; line-height: 1.2; }
.spell-key { padding: 5px 8px; border: 1px solid color-mix(in srgb, var(--spell-color) 40%, transparent); border-radius: 6px; background: #0c132b; color: var(--spell-color); font: 700 11px/1.2 'Trebuchet MS', sans-serif; white-space: nowrap; }
#spells-panel .spell-card p { color: #b8c7e4; font-size: 12px; line-height: 1.6; margin: 12px 0 0; }
.spell-unlocked { display: inline-block; margin: 14px 0 0; color: #8bf3d4; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.spell-unlocked::before { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #72e9c8; margin-right: 6px; box-shadow: 0 0 9px #72e9c877; }
.spells-grid-purchased .spell-card { padding: 26px; }
.spells-grid-purchased .spell-art { width: 128px; height: 128px; margin-bottom: 16px; }
#spells-panel .spells-grid-purchased h4 { font-size: 25px; }
.spell-heal-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 11px; text-align: center; }
.spell-heal-table th, .spell-heal-table td { padding: 8px 4px; border-bottom: 1px solid #8abeb02c; }
.spell-heal-table th { color: #9fb9c7; font-weight: 400; }
.spell-heal-table td { color: #a6f5d5; font-weight: 700; }
.spell-heal-table th:first-child { text-align: left; }
#spells-panel .spell-callout { border-left: 2px solid var(--spell-color); background: color-mix(in srgb, var(--spell-color) 8%, transparent); border-radius: 4px; padding: 10px 12px; }
.spells-meter-guide { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 24px; padding: 18px 20px; border: 1px solid #a18cff35; border-radius: 12px; background: #171e3933; }
.spell-meter-example { display: flex; gap: 5px; flex: 0 0 auto; }
.spell-meter-example i { display: block; position: relative; width: 25px; height: 14px; border: 1px solid #aa8cff; border-radius: 3px; background: #8466da; }
.spell-meter-example i:nth-child(-n+3)::after { content: ''; position: absolute; inset: 3px 2px; border: 1px solid #ffadc6; border-radius: 2px; background: #ff426d; box-shadow: 0 0 6px #ff4b7355; }
#spells-panel .spells-meter-guide p { flex: 1 1 240px; margin: 0; color: #b9c7e1; font-size: 12px; line-height: 1.6; }
.spells-meter-guide strong { color: #ff99ba; }
.spells-footer { padding: 4px 32px max(24px, env(safe-area-inset-bottom)); margin: auto 0 0; color: #93a5c8; font-size: 11px; text-align: center; }
@media (max-width: 1150px) { .spells-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .spells-grid-purchased { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; } .spells-grid-purchased .spell-card { padding: 20px; } }
@media (max-width: 800px) {
  .spells-header { padding: max(18px, env(safe-area-inset-top)) 76px 16px max(18px, env(safe-area-inset-left)); }
  .spells-eyebrow { font-size: 8px; letter-spacing: .18em; }
  #spells-title { font-size: 26px; }
  .spells-access { display: none; }
  #spells-panel #spells-close { top: max(18px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); }
  .spells-content { padding: 24px 18px; }
  .spells-grid { gap: 10px; }
  .spells-grid-purchased { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .spell-card { padding: 16px; }
  .spells-grid-purchased .spell-art { width: 104px; height: 104px; }
  .spells-footer { padding: 0 18px 22px; }
}
@media (max-width: 500px) { .spells-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .spells-grid-purchased { grid-template-columns: minmax(0, 1fr); } .spell-art { width: 72px; height: 72px; } .spell-card-head { gap: 6px; } }

/* Small landscape phones need two rows to preserve 44px combat targets. */
@media (orientation: landscape) and (max-width: 620px) {
  body.touch-enabled { --touch-deck-space: 162px; }
  body.touch-enabled:has(#touch-trial-status:not([hidden])) { --touch-deck-space: 182px; }
  body.touch-enabled.tutorial-active { --touch-deck-space: 246px; }
  .touch-enabled #touch-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* This final spell is only offered by an equipped Ruin mastery. */
#touch-actions #touch-oblivion { grid-column: 1 / -1; min-height: 44px; background: #381b36; border-color: #e58bad; color: #ffe5f1; }
#touch-actions #touch-oblivion[hidden] { display: none; }
@media (orientation: portrait) {
  body.touch-enabled:has(#touch-oblivion:not([hidden])) { --touch-deck-space: 392px; }
  body.touch-enabled:has(#touch-oblivion:not([hidden])):has(#touch-trial-status:not([hidden])) { --touch-deck-space: 412px; }
}
@media (orientation: landscape) {
  body.touch-enabled:has(#touch-oblivion:not([hidden])) { --touch-deck-space: 162px; }
  body.touch-enabled:has(#touch-oblivion:not([hidden])):has(#touch-trial-status:not([hidden])) { --touch-deck-space: 182px; }
}
@media (orientation: landscape) and (max-width: 620px) {
  body.touch-enabled:has(#touch-oblivion:not([hidden])) { --touch-deck-space: 212px; }
  body.touch-enabled:has(#touch-oblivion:not([hidden])):has(#touch-trial-status:not([hidden])) { --touch-deck-space: 232px; }
}
#oblivion-ending-panel {
  position: fixed; z-index: 100; inset: 0; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 30px; padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: #000; color: #fff; text-align: center;
}
#oblivion-ending-panel[hidden] { display: none; }
#oblivion-ending-title { margin: 0; max-width: 900px; color: #f3edf4; font: 400 clamp(24px, 4vw, 52px)/1.35 'Trebuchet MS', sans-serif; letter-spacing: .04em; text-transform: none; }
#oblivion-main-menu { min-width: 180px; min-height: 48px; padding: 12px 24px; border: 1px solid #88818b; border-radius: 8px; background: #161219; color: #f4ecf7; font: 400 15px/1.4 'Trebuchet MS', sans-serif; cursor: pointer; }
#oblivion-main-menu:hover { background: #2b2330; border-color: #e4c9ed; }
#oblivion-main-menu:focus-visible { outline: 3px solid #ed879d; outline-offset: 5px; }
