.spellbook-content {
  background-color: #1a1a1a;
  background-size: cover;
  height: 100%;
  padding: 15px;
  color: #fff;
  font-family: Arial, sans-serif;
  overflow-y: auto;
}

.spellbook-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.spellbook-header h2 {
  margin: 0;
  font-size: 24px;
  color: #FFD700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}



.spellbook-action-bar {
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.spellbook-spell-types {
  display: flex;
  gap: 0.5em;
}

.spellbook-tab {
  padding: 0.5em 1em;
  background: #333;
  border: 1px solid #555;
  color: #FFD700;
  cursor: pointer;
  border-radius: 4px;
  font-size: 18px;
  transition: background 0.2s ease;
}

.spellbook-tab:hover {
  background: #555;
}

.spellbook-targeting {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.spellbook-targeting label {
  background: none;
  color: #fff;
}

.spellbook-targeting select {
  background: #2b2b2b;
  color: #fff;
  border: 1px solid #666;
  padding: 6px;
  border-radius: 4px;

}

.spellbook-spells {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}
.spellbook-spell-button {
  position: relative;
  width: 72px;
  height: 72px;
  background: #2b2b2b;
  border: 2px solid #FFD700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 4px;
  transition: transform 0.2s ease;
  overflow: hidden;
  text-align: center;
  cursor: pointer;
}

.spellbook-spell-button:hover {
  transform: scale(1.1);
}

.spell-icon {
  font-size: 32px;
  line-height: 1;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-label {
  font-size: 10px;
  color: #fff;
  margin-top: 2px;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 100%;
  text-wrap: auto;
}

.spellbook-spell-button.cooldown .cooldown-overlay {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  animation-name: cooldownAnim;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  border-radius: 8px;
  z-index: 2;
}

@keyframes cooldownAnim {
  from {
    height: 100%;
  }
  to {
    height: 0%;
  }
}

.spellbook-spell-button.cooldown::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  animation: cooldownAnim linear forwards;
  border-radius: 8px;
  z-index: 2;
}

.spellbook-spell-button.cooldown-active {
  pointer-events: none;
  opacity: 0.6;
  cursor: not-allowed;
}

.spellbook-spell-button.valid-target {
  border-color: #00ff99;
  opacity: 1;
}

.spellbook-spell-button.invalid-target {
  border-color: #666;
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile media query */
@media (max-width: 767px) and (pointer: coarse) and (hover: none) {
    html {
        font-size: 16px; /* Base font size */
    }

    .spellbook-content {
        padding: 1.25rem 0.75rem; /* 20px 12px */
        font-size: 1rem; /* ~16px, was 1.4em (~22.4px), too large */
        margin-bottom: 4rem; /* ~64px, clears taskbar (~48px + 8px bottom) */
        box-sizing: border-box;
        min-height: calc(100vh - 4rem); /* Ensure content fills viewport minus taskbar */
    }

    .spellbook-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem; /* 12px */
        margin-bottom: 1.5rem; /* 24px */
    }

    .spellbook-header h2 {
        font-size: 1.75rem; /* ~28px, was 36px, fits better */
        text-align: left;
        margin: 0;
    }

    .spellbook-action-bar {
        gap: 1rem; /* ~16px, was 1.5em (~24px), tighter for mobile */
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .spellbook-spell-types {
        flex-wrap: wrap;
        gap: 0.5rem; /* ~8px, was 0.75em (~12px), tighter */
        width: 100%;
    }

    .spellbook-tab {
        font-size: 1.25rem; /* ~20px, was 28px, more compact */
        padding: 0.5rem 1rem; /* ~8px 16px, was 0.75em 1.25em */
        width: calc(50% - 0.25rem); /* Two tabs per row, minus gap */
        text-align: center;
        box-sizing: border-box;
        min-height: 2.75rem; /* ~44px, touch-friendly */
    }

    .spellbook-targeting {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem; /* ~12px, was 1em (~16px) */
        width: 100%;
    }

    .spellbook-targeting select {
        width: 100%;
        font-size: 1.25rem; /* ~20px, was 24px/64px, resolves conflict */
        padding: 0.75rem; /* 12px */
        box-sizing: border-box;
        min-height: 2.75rem; /* ~44px, touch-friendly */
    }

    .spellbook-spells {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem; /* 16px */
    }

    .spellbook-spell-button {
        width: min(40vw, 10rem); /* ~150px on 375px, was 256px, prevents overflow */
        height: min(40vw, 10rem);
        padding: 0.5rem; /* 8px */
        box-sizing: border-box;
        min-height: 2.75rem; /* ~44px, touch-friendly */
    }

    .spell-icon {
        font-size: 4rem; /* ~64px, was 164px, fits better */
        line-height: 1;
    }

    .spell-label {
        font-size: 1.25rem; /* ~20px, was 64px, prevents overflow */
        line-height: 1.2;
    }
}