* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    padding: 0;
    /* Adjust max-width to account for minimum margins (8.5" - 0.5" = 8" = 768px) */
    max-width: 768px;
    margin: 0 auto;
    overflow-x: hidden; /* Changed from auto to hidden */
    position: relative; /* Add this */
}

.character-sheet {
    position: relative; /* Add this */
    max-width: 768px;
    margin: 0 auto;
    background-color: white;
    padding: 2px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    height: 1008px;
    overflow: hidden;
    width: 768px;
}

.section-one {
    border: 1px solid #000;
    border-radius: 3px;
    padding: 3px;
    margin-bottom: 3px;
}

.name-banner {
    border-bottom: 1px solid #000;
    padding-bottom: 3px;
    margin-bottom: 3px;
}

.name-banner input {
    width: 100%;
    padding: 3px;
    font-size: 1em;
    border: none;
    border-bottom: 1px solid #000;
    outline: none;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-item label {
    font-size: 0.6em;
    color: #000;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.detail-item input {
    padding: 2px;
    border: 1px solid #000;
    border-radius: 2px;
    font-size: 0.8em;
}

/* Main content grid layout */
.main-content {
    display: grid;
    grid-template-columns: 90px 160px 250px 1fr;
    gap: 3px;
    width: 100%; /* Ensure it spans the character-sheet width for correct scrolling */
}

.left-column {
    grid-column: 1;
    width: 90px;
    flex-shrink: 0; /* Prevent from shrinking */
}

.left-sidebar {
    grid-column: 2;
    width: 160px;
    flex-shrink: 0; /* Prevent from shrinking */
}

.center-column {
    grid-column: 3;
    flex-shrink: 0; /* Prevent from shrinking */
}

.right-column {
    grid-column: 4;
    flex-shrink: 0; /* Prevent from shrinking */
}

/* Remove spinner arrows from number inputs - with !important to ensure override */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button,
.prof-bonus-container input::-webkit-inner-spin-button,
.prof-bonus-container input::-webkit-outer-spin-button,
.ability-value::-webkit-inner-spin-button,
.ability-value::-webkit-outer-spin-button,
.ability-modifier::-webkit-inner-spin-button,
.ability-modifier::-webkit-outer-spin-button,
.save-value::-webkit-inner-spin-button,
.save-value::-webkit-outer-spin-button,
.skill-value::-webkit-inner-spin-button,
.skill-value::-webkit-outer-spin-button,
.hp-max-input::-webkit-inner-spin-button,
.hp-max-input::-webkit-outer-spin-button,
.hd-total-input::-webkit-inner-spin-button,
.hd-total-input::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
}

/* Firefox - with !important to ensure override */
input[type="number"],
.prof-bonus-container input,
.ability-value,
.ability-modifier,
.save-value,
.skill-value,
.hp-max-input,
.hd-total-input {
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

/* Additional catch-all rule */
input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
}

input {
    -moz-appearance: textfield !important;
    appearance: textfield !important;
}

/* Ability Scores Styles */
.ability-scores {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ability-score {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    text-align: center;
    background-color: white;
}

.ability-score label {
    display: block;
    font-size: 0.6em;
    font-weight: bold;
    margin-bottom: 3px;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.ability-value {
    width: 45px;
    height: 45px;
    text-align: center;
    font-size: 1.2em;
    border: 1px solid #000;
    border-radius: 3px;
}

.ability-modifier {
    width: 30px;
    height: 30px;
    text-align: center;
    font-size: 1em;
    border: 1px solid #000;
    border-radius: 50%;
}

/* Proficiency Bonus Styles */
.proficiency-bonus {
    margin-bottom: 3px;
}

.prof-bonus-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 3px;
}

.prof-bonus-container input {
    width: 25px;
    height: 25px;
    text-align: center;
    font-size: 1em;
}

.prof-bonus-container input::-webkit-inner-spin-button,
.prof-bonus-container input::-webkit-outer-spin-button {
    opacity: 1;
}

.prof-bonus-container label {
    font-size: 0.7em;
    font-weight: bold;
    flex-grow: 1;
}

/* Inspiration Styles */
.inspiration {
    margin-bottom: 3px;
}

.inspiration-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    align-items: center;
    gap: 3px;
    margin-bottom: 3px;
}

.inspiration-container input[type="checkbox"] {
    width: 15px;
    height: 15px;
}

.inspiration-container label {
    font-size: 0.7em;
    font-weight: bold;
    flex-grow: 1;
}

/* Section Labels */
.section-label {
    font-size: 0.6em;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #000;
    padding-bottom: 2px;
    width: 100%;
    display: block;
    margin-bottom: 2px;
}

/* Saving Throws Styles */
.saving-throws {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    margin-bottom: 3px;
}

.save-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.save-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.save-item input[type="checkbox"] {
    width: 12px;
    height: 12px;
}

.save-item .save-value {
    width: 29px;
    height: 20px;
    text-align: center;
    font-size: 0.8em;
}

.save-item label {
    font-size: 0.7em;
}

/* Skills Styles */
.skills {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    margin-bottom: 3px;
}

.skill-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.skill-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.skill-item input[type="checkbox"] {
    width: 12px;
    height: 12px;
}

.skill-item .skill-value {
    width: 29px;
    height: 20px;
    text-align: center;
    font-size: 0.8em;
}

.skill-item label {
    font-size: 0.6em;
}

/* Passive Wisdom Styles */
.passive-wisdom {
    margin-bottom: 3px;
    width: 253px;
    margin-left: -93px;
    position: relative;
    flex-shrink: 0;/* Prevent from shrinking */
}

.passive-wisdom-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    align-items: center;
    gap: 3px;
}

.passive-wisdom-container input {
    width: 45px;
    height: 30px;
    text-align: center;
    font-size: 1.2em;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 2px;
    margin: 0;
}

.passive-wisdom-container label {
    font-size: 0.7em;
    font-weight: bold;
    flex-grow: 1;
}

/* Other Proficiencies Styles */
.other-proficiencies {
    margin-bottom: 0px;
    width: 253px;
    margin-left: -93px;
    position: relative;
    flex-shrink: 0;/* Prevent from shrinking */
}

.other-proficiencies-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
}

.other-proficiencies-container textarea {
    width: 100%;
    height: 195px;
    border: none;
    resize: none;
    font-size: 0.8em;
    font-family: Arial, sans-serif;
    margin-bottom: 3px;
}

.other-proficiencies-container textarea:focus {
    outline: none;
}

.other-proficiencies-container label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid #666;
    padding-top: 3px;
}

/* Combat Stats Styles */
.combat-stats {
    display: flex;
    justify-content: space-between;
    gap: 5px;
    margin-bottom: 3px;
}

.combat-stat {
    flex: 1;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    height: fit-content;
    min-width: 0; /* Prevents flex items from overflowing */
}

.combat-stat input {
    width: 45px;
    height: 45px;
    text-align: center;
    font-size: 1.2em;
    border: 1px solid #000;
    border-radius: 5px;
    margin-bottom: 2px;
}

.combat-stat label {
    font-size: 0.7em;
    font-weight: bold;
}

.combat-stat input:focus {
    border-color: #000;
    outline: none;
}

/* Personality Traits Styles */
.personality-traits-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
    margin-bottom: 3px;
}

.personality-traits-container textarea {
    width: 100%;
    height: 55px;
    border: none;
    resize: none;
    font-size: 0.8em;
    font-family: Arial, sans-serif;
    margin-bottom: 3px;
}

.features-traits-container {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
    margin-bottom: 0px;
}

.features-traits-container textarea {
    width: 100%;
    height: 510px;
    border: none;
    resize: none;
    font-size: 0.8em;
    font-family: Arial, sans-serif;
    margin-bottom: 3px;
}

.features-traits-container label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid #000;
    padding-top: 3px;
}

.personality-traits-container textarea:focus {
    outline: none;
}

.personality-traits-container label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid #000;
    padding-top: 3px;
}

/* Hit Points Styles */
.hit-points-section {
    margin-bottom: 1px;
    display: flex;
    gap: 3px;
}

.current-hit-points,
.temporary-hit-points {
    flex: 1;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    margin-bottom: 2px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.temporary-hit-points::before {
    content: '';
    height: 31px;
    margin-bottom: 2px;
}

.hp-max-line {
    display: flex;
    align-items: center;
    gap: 3px;
    padding-bottom: 3px;
    border-bottom: 1px solid #000;
    margin-bottom: 3px;
}

.hp-max-input {
    width: 45px;
    height: 25px;
}

.hp-max-label {
    font-size: 0.7em;
    font-weight: bold;
    color: #000;
}

.current-hit-points input#current-hp,
.temporary-hit-points input {
    width: 100%;
    height: 40px;
    text-align: center;
    font-size: 1.2em;
    border: none !important;
    padding: 3px;
    margin-bottom: 3px;
}

.current-hit-points label,
.temporary-hit-points label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid #000;
    padding-top: 3px;
}

/* Hit Dice and Death Saves Styles */
.hit-dice-death-saves {
    display: flex;
    gap: 3px;
    margin-bottom: 3px;
}

.hit-dice {
    flex: 1;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
}

.hd-total-line {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-bottom: 5px;
    border-bottom: 1px solid #000;
    margin-bottom: 1px;
}

.hd-total-input {
    width: 45px;
    height: 25px;
    text-align: center;
    font-size: 1.2em;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
}

.hd-total-label {
    font-size: 0.7em;
    font-weight: bold;
    color: #000;
}

.hit-dice input#hit-dice {
    width: 100%;
    text-align: center;
    font-size: 1.2em;
    border: none;
    padding: 3px;
    margin-bottom: 3px;
}

.hit-dice label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-top: 1px solid #000;
    padding-top: 3px;
}

.death-saves {
    flex: 1;
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.death-saves-title {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 3px;
}

.saves-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

.save-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.save-label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
}

.circles {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.save-circle {
    appearance: none;
    width: 12px;
    height: 12px;
    border: 1px solid #000;
    border-radius: 50%;
    cursor: pointer;
}

.save-circle:checked {
    background-color: #000;
}

/* Attacks & Spellcasting Styles */
.attacks-spellcasting {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    margin-bottom: 3px;
}

.attacks-table {
    width: 100%;
    margin-bottom: 3px;
}

.attack-row {
    display: grid;
    grid-template-columns: 1fr 30px 1fr;
    gap: 1px;
    margin-bottom: 2px;
}

.attack-row.header {
    margin-bottom: 0px;
}

.attack-row.header div {
    font-size: 0.6em;
    font-weight: bold;
    color: #000;
    text-align: center;
}

.attack-row input {
    width: 100%;
    height: 25px;
    padding: 3px;
    border: 1px solid #000;
    border-radius: 3px;
    font-size: 0.8em;
}

.attack-row input.atk-input {
    text-align: center;
}

.attack-row input:focus {
    border-color: #000;
    outline: none;
}

.attacks-spellcasting textarea {
    width: 100%;
    height: 100px;
    margin: 0;
    border: 1px solid #000;
    border-radius: 3px;
    padding: 3px;
    font-size: 0.8em;
    font-family: Arial, sans-serif;
    resize: none;
}

.attacks-spellcasting textarea:focus {
    border-color: #000;
    outline: none;
}

/* Equipment Styles */
.equipment {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    margin-bottom: 3px;
}

.equipment-container {
    display: flex;
    gap: 3px;
    margin-bottom: 3px;
}

.equipment-inputs {
    flex: 0 0 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.equipment-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.equipment-item label {
    font-size: 0.6em;
    font-weight: bold;
    width: 12px;
}

.equipment-input {
    width: 35px;
    height: 25px;
    padding: 3px;
    border: 1px solid #000;
    border-radius: 3px;
    font-size: 0.8em;
    text-align: center;
}

.equipment-input:focus {
    border-color: #000;
    outline: none;
}

.equipment-notes {
    flex: 1;
}

.equipment-notes textarea {
    width: 100%;
    height: 348px;
    border: 1px solid #000;
    border-radius: 3px;
    padding: 3px;
    font-size: 0.8em;
    font-family: Arial, sans-serif;
    resize: none;
}

.equipment-notes textarea:focus {
    border-color: #000;
    outline: none;
}

.attacks-spellcasting .section-label,
.equipment .section-label {
    font-size: 0.7em;
    font-weight: bold;
    text-align: center;
    border-bottom: none; /* Remove bottom border */
    padding-bottom: 0; /* Remove bottom padding */
    width: 100%;
    display: block;
    margin-bottom: 0; /* Remove bottom margin */
}

.attacks-equipment-label {
    border-bottom: none;
    border-top: 1px solid #000;
    margin-top: 3px;
    padding-top: 3px;
    font-size: 0.7em;
}

#passive-wisdom::placeholder {
    color: black; /* Set the placeholder text color to black */
    opacity: 1; /* Ensure the placeholder is fully visible */
}

#initiative::placeholder {
    color: black; /* Set the placeholder text color to black */
    opacity: 1; /* Ensure the placeholder is fully visible */
}

.save-item .save-value::placeholder,
.skill-item .skill-value::placeholder {
    color: black;
    opacity: 1;
}

/* Base styles for all checkboxes */
input[type="checkbox"] {
    background-color: white !important;
    background-image: none !important;
}

/* Regular checkboxes - MUST NOT have data-state attribute */
input[type="checkbox"]:not([data-state]) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border: 1px solid #000 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    position: relative !important;
}

input[type="checkbox"]:not([data-state]):checked {
    background-color: transparent !important;
}

input[type="checkbox"]:not([data-state]):checked::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Dark mode regular checkboxes */
.dark-mode input[type="checkbox"] {
    background-color: #555 !important;
    background-image: none !important;
}

.dark-mode input[type="checkbox"]:not([data-state]) {
    background-color: #555 !important;
    border-color: #666 !important;
}

.dark-mode input[type="checkbox"]:not([data-state]):checked {
    background-color: #555 !important;
}

.dark-mode input[type="checkbox"]:not([data-state]):checked::after {
    color: white !important;
    background: none !important;
}

/* Tristate checkboxes - MUST have data-state attribute */
input[type="checkbox"][data-state],
.skill-item input[type="checkbox"][data-state] {
    background-color: transparent !important;
    background-image: none !important;
}

/* Unchecked state (clear) */
input[type="checkbox"][data-state="unchecked"] {
    background-color: white !important;
}

/* Proficiency state (dot) */
input[type="checkbox"][data-state="checked"] {
    background-color: transparent !important;
}

input[type="checkbox"][data-state="checked"]::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Expertise state (double dot) */
input[type="checkbox"][data-state="expertise"] {
    background-color: transparent !important;
}

input[type="checkbox"][data-state="expertise"]::after {
    content: '••' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Dark mode styles */
.dark-mode input[type="checkbox"] {
    background-color: #555 !important;
    border-color: #666 !important;
}

/* Dark mode regular checkbox (non-tristate) */
.dark-mode input[type="checkbox"]:not([data-state]):checked {
    background-color: #eee !important;
}

/* Dark mode tristate base styles - remove ALL backgrounds */
.dark-mode input[type="checkbox"][data-state],
.dark-mode .skill-item input[type="checkbox"][data-state],
.dark-mode .save-item input[type="checkbox"][data-state] {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Dark mode unchecked state only */
.dark-mode input[type="checkbox"][data-state="unchecked"] {
    background-color: #555 !important;
}

/* Dark mode checked (single dot) */
.dark-mode input[type="checkbox"][data-state="checked"],
.dark-mode .skill-item input[type="checkbox"][data-state="checked"],
.dark-mode .save-item input[type="checkbox"][data-state="checked"] {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Dark mode expertise (double dot) */
.dark-mode input[type="checkbox"][data-state="expertise"],
.dark-mode .skill-item input[type="checkbox"][data-state="expertise"],
.dark-mode .save-item input[type="checkbox"][data-state="expertise"] {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Ensure after pseudo-elements have no background */
.dark-mode input[type="checkbox"][data-state="checked"]::after,
.dark-mode input[type="checkbox"][data-state="expertise"]::after,
.dark-mode .skill-item input[type="checkbox"][data-state="checked"]::after,
.dark-mode .skill-item input[type="checkbox"][data-state="expertise"]::after,
.dark-mode .save-item input[type="checkbox"][data-state="checked"]::after,
.dark-mode .save-item input[type="checkbox"][data-state="expertise"]::after {
    background: none !important;
}

/* Remove any accent-color */
* {
    accent-color: unset !important;
}

body .buttons-container {
    position: fixed;
    top: 50%;
    right: calc(50% - 489px);
    transform: translateY(-50%);
    display: flex !important; /* Force display */
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    width: 100px;
}

body .buttons-container button {
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
    min-width: fit-content;
    display: block !important; /* Force display */
}

/* Add responsive handling with increased specificity */
@media screen and (max-width: 900px) {
    body .buttons-container {
        right: 10px;
        background: rgba(255, 255, 255, 0.9);
        padding: 10px;
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
}

/* Dark mode styles */
.dark-mode {
  background-color: #222;
  color: #eee;
}

.dark-mode .character-sheet {
  background-color: #444;
  color: #eee;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.dark-mode .section-one,
.dark-mode .name-banner,
.dark-mode .ability-score,
.dark-mode .prof-bonus-container,
.dark-mode .inspiration-container,
.dark-mode .saving-throws,
.dark-mode .skills,
.dark-mode .passive-wisdom-container,
.dark-mode .other-proficiencies-container,
.dark-mode .combat-stat,
.dark-mode .personality-traits-container,
.dark-mode .features-traits-container,
.dark-mode .current-hit-points,
.dark-mode .temporary-hit-points,
.dark-mode .hit-dice,
.dark-mode .death-saves,
.dark-mode .attacks-spellcasting,
.dark-mode .equipment {
  background-color: #444;
  border-color: #666;
}

.dark-mode input,
.dark-mode textarea {
  background-color: #555;
  color: #eee;
  border-color: #666;
}

.dark-mode input::placeholder,
.dark-mode textarea::placeholder {
  color: #ccc;
}

.dark-mode .name-banner input {
  border-bottom-color: #666;
}

.dark-mode .section-label,
.dark-mode .ability-score label,
.dark-mode .save-item label,
.dark-mode .skill-item label,
.dark-mode .hp-max-label,
.dark-mode .combat-stat label,
.dark-mode .current-hit-points label,
.dark-mode .temporary-hit-points label,
.dark-mode .hit-dice label,
.dark-mode .death-saves-title,
.dark-mode .save-label,
.dark-mode .attack-row.header div {
  color: #ccc;
}

.dark-mode .ability-modifier,
.dark-mode .ability-value,
.dark-mode .save-value,
.dark-mode .skill-value,
.dark-mode .combat-stat input,
.dark-mode .hp-max-input,
.dark-mode .hd-total-input,
.dark-mode .attack-row input {
  background-color: #555;
  color: #eee;
  border-color: #666;
}

.dark-mode .save-circle {
  border-color: #999;
}

.dark-mode .save-circle:checked {
  background-color: #eee;
}

.dark-mode input[type="checkbox"] {
  accent-color: #777;
}

.dark-mode .personality-traits-container label,
.dark-mode .features-traits-container label,
.dark-mode .current-hit-points label,
.dark-mode .temporary-hit-points label,
.dark-mode .hit-dice label {
  border-top-color: #666;
}

.dark-mode .hp-max-line,
.dark-mode .hd-total-line {
  border-bottom-color: #666;
}

/* Fix labels in dark mode */
.dark-mode .detail-item label,
.dark-mode .hd-total-label {
    color: #eee;
}

/* Fix placeholder text in dark mode */
.dark-mode #passive-wisdom::placeholder,
.dark-mode #initiative::placeholder,
.dark-mode .save-item .save-value::placeholder,
.dark-mode .skill-item .skill-value::placeholder {
    color: #eee;
    opacity: 1;
}

/* Style for print dialog box in dark mode */
.dark-mode .modal-content,
.dark-mode #print-modal {
  background-color: #444;
  color: #eee;
}

.dark-mode #print-modal p,
.dark-mode #print-modal li,
.dark-mode #print-modal strong {
  color: #eee;
}

.dark-mode #print-modal h2 {
  color: #fff;
}

.second-page {
    max-width: 768px;
    margin: 2px auto;
    background-color: white;
    padding: 2px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    height: 1008px;
    width: 768px;
}

.spellcasting-section {
    display: flex;
    justify-content: space-between;
    padding: 2px;
    border: 1px solid #000;
    border-radius: 5px;
    background-color: white;
    margin-bottom: 2px; /* Add 2px margin below the header */
}

.spellcasting-field {
    display: flex;
    flex-direction: column;
    width: 30%;
}

.spellcasting-field.small-field {
    width: 15%;
}

.spellcasting-field label {
    font-size: 0.8em;
    font-weight: bold;
    margin-bottom: 2px;
}

.spellcasting-field input {
    padding: 2px;
    border: 1px solid #000;
    border-radius: 5px;
    font-size: 1em;
    text-align: center; /* Center text for spell save DC and attack bonus */
}

/* Exception for spellcasting class dropdown/input */
.spellcasting-field select,
#custom-spellcasting-ability {
    text-align: left;
}

.dark-mode .spellcasting-section {
    background-color: #444;
    border-color: #666;
}

.dark-mode .spellcasting-field input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

.dark-mode .spellcasting-field input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Spell Sections */
.spell-sections {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px; /* Add 2px gap between columns */
    margin-top: 0px; /* Remove the gap */
    height: calc(100% - 130px);
}

/* Target only the middle column of spell sections */
.spell-sections .spell-column:nth-child(2) {
    gap: 8px;  /* Adjust this value to increase/decrease vertical spacing */
}

/* Target only the right column of spell sections */
.spell-sections .spell-column:nth-child(3) {
    gap: 5px;  /* Adjust this value to increase/decrease vertical spacing */
}

.spell-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
}

.spell-level-section {
    border: 1px solid #000;
    border-radius: 5px;
    background-color: white;
    display: flex;
    flex-direction: column;
    flex: none;
    overflow: hidden; /* Ensure corners are rounded */
    margin: 0; /* Remove all margins */
}

.spell-level-section.cantrips-section {
    flex: 0 0 auto; /* Don't grow or shrink, size to content */
}

.spell-header {
    display: flex;
    align-items: center;
    padding: 2px;
    border-bottom: 1px solid #000;
    background-color: #FFFFFF;
    border-top-left-radius: 5px; /* Add top left corner radius */
    border-top-right-radius: 5px; /* Add top right corner radius */
}

.spell-level-icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #000;
    border-radius: 5px;
    font-weight: bold;
    margin-right: 2px;
    background-color: white;
}

.spell-level-title {
    display: none;
}

.cantrips-section .spell-level-title {
    display: block; /* Show title only in cantrips section */
}

.spell-slots {
    display: none;
}

.spell-slots-container {
    flex-grow: 1;
    display: flex;
    gap: 2px;
    justify-content: flex-end;
}

.cantrips-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px;
    margin: 0;
}

.cantrip-input {
    width: 100%;
    height: 20px; /* Reduced from 24px */
    border: none;
    border-bottom: 1px solid #ccc;
    font-size: 0.7em; /* Reduced from 0.8em */
    padding: 0;
    margin: 0;
    display: block;
    text-align: left;
    line-height: 20px; /* Match height to remove internal padding */
}

.dark-mode .cantrip-input {
    background-color: #444;
    color: #fff;
    border-bottom-color: #666;
}

.spell-list {
    padding: 5px;
    flex-grow: 1;
    overflow-y: auto;
}

.spell-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 0.8em;
    padding-left: 5px; /* Add some padding since we removed the circle */
}

.spell-prepared {
    display: none; /* Hide the circles */
}

.spell-name {
    flex-grow: 1;
    border-bottom: none; /* Remove the lines */
}

/* Cantrips section (special case) */
.cantrips-section .spell-header {
    background-color: #FFFFFF;
}

/* Adjust heights for different spell level sections */
.cantrips-section, .level-1-section, .level-2-section, .level-3-section, .level-4-section, .level-5-section, .level-6-section, .level-7-section, .level-8-section, .level-9-section {
    flex: none;
}

/* Dark mode styles for spell sections */
.dark-mode .spell-level-section {
    background-color: #444;
    border-color: #666;
}

.dark-mode .spell-header {
    background-color: #444;
    border-color: #666;
}

.dark-mode .spell-level-icon {
    background-color: #555;
    border-color: #777;
    color: #eee;
}

.dark-mode .spell-level-title {
    color: #eee;
}

.dark-mode .spell-slot {
    border-color: #777;
}

.dark-mode .spell-prepared {
    border-color: #777;
}

.dark-mode .spell-prepared.checked {
    background-color: #eee;
}

.dark-mode .spell-name {
    border-color: #555;
    color: #eee;
}

.dark-mode .cantrips-section .spell-header {
    background-color: #444;
}

/* Responsive adjustments for spell sections */
@media (max-width: 768px) {
    .spell-sections {
        grid-template-columns: 1fr;
    }
}

/* Print-specific styles */
@media print {
    /* Remove break-inside from spell-level-section */
    .spell-level-section {
        break-inside: auto !important;
        page-break-inside: auto !important;
        overflow: visible !important;
    }

    /* Adjust spell sections */
    .spell-level-section {
        flex: none !important;
    }

    /* Fix for page 2 printing - ensure columns are maintained */
    .second-page .spell-sections {
        display: table !important; /* Use table layout for better print support */
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: separate !important;
        border-spacing: 2px !important;
        height: auto !important;
    }

    .second-page .spell-column {
        display: table-cell !important; /* Use table-cell for columns */
        width: 33.33% !important; /* Each column takes exactly 1/3 of the width */
        vertical-align: top !important;
        float: none !important;
        height: auto !important;
    }

    /* Ensure spell sections don't overflow */
    .second-page .spell-level-section {
        width: 100% !important;
        margin-bottom: 2px !important;
        page-break-inside: avoid !important; /* Avoid breaking spell sections across pages */
    }

    .spell-header {
        border-top-left-radius: 5px !important; /* Add top left corner radius */
        border-top-right-radius: 5px !important; /* Add top right corner radius */
    }

    /* Hide non-printable elements */
    .no-print {
        display: none !important;
    }

    body .buttons-container.no-print {
        display: none !important;
    }
}

/* Style for the custom text input to initially be hidden */
#custom-spellcasting-ability {
    display: none; /* Initially hidden */
    margin-top: 5px; /* Add a little space above */
    width: 100%;
    box-sizing: border-box;
}

/* Show the custom input when the relevant class is added */
.show-custom-input #custom-spellcasting-ability {
    display: block;
}

/* Add these styles to fix dark mode input formatting */

/* Proficiency Bonus */
.dark-mode .prof-bonus-container input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Saving Throws */
.dark-mode .saving-throws input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Skills */
.dark-mode .skills input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Maximum Hit Points */
.dark-mode .hp-max-input {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Ensure placeholder text is visible in dark mode for these fields */
.dark-mode .prof-bonus-container input::placeholder,
.dark-mode .saving-throws input::placeholder,
.dark-mode .skills input::placeholder,
.dark-mode .hp-max-input::placeholder {
    color: #eee;
    opacity: 1;
}

/* Ensure focus states maintain dark mode aesthetics */
.dark-mode .prof-bonus-container input:focus,
.dark-mode .saving-throws input:focus,
.dark-mode .skills input:focus,
.dark-mode .hp-max-input:focus {
    outline-color: #777;
    background-color: #666;
}

/* Standardize all input fields */
input[type="text"],
input[type="number"],
input.save-value,
input.skill-value,
input.ability-value,
input.ability-modifier,
input.prof-bonus-container input,
input.hp-max-input,
input.hd-total-input,
input.equipment-input,
textarea {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: none;
}

/* Remove any default browser styling */
input[type="text"]:focus,
input[type="number"]:focus,
input.save-value:focus,
input.skill-value:focus,
input.ability-value:focus,
input.ability-modifier:focus,
input.prof-bonus-container input:focus,
input.hp-max-input:focus,
input.hd-total-input:focus,
input.equipment-input:focus,
textarea:focus {
    outline: none;
    border-color: #000;
    box-shadow: none;
}

/* Dark mode styling for all inputs */
.dark-mode input[type="text"],
.dark-mode input[type="number"],
.dark-mode input.save-value,
.dark-mode input.skill-value,
.dark-mode input.ability-value,
.dark-mode input.ability-modifier,
.dark-mode .prof-bonus-container input,
.dark-mode .hp-max-input,
.dark-mode .hd-total-input,
.dark-mode .equipment-input,
.dark-mode textarea {
    background-color: #555;
    color: #eee;
    border-color: #666;
    border-radius: 5px;
    box-shadow: none;
}

/* Dark mode focus states */
.dark-mode input[type="text"]:focus,
.dark-mode input[type="number"]:focus,
.dark-mode input.save-value:focus,
.dark-mode input.skill-value:focus,
.dark-mode input.ability-value:focus,
.dark-mode input.ability-modifier:focus,
.dark-mode .prof-bonus-container input:focus,
.dark-mode .hp-max-input:focus,
.dark-mode .hd-total-input:focus,
.dark-mode .equipment-input:focus,
.dark-mode textarea:focus {
    outline: none;
    border-color: #777;
    background-color: #666;
    box-shadow: none;
}

/* Style select boxes to match other inputs */
select {
    border: 1px solid #000;
    border-radius: 5px;
    padding: 3px;
    background-color: white;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-shadow: none;
    font-family: Arial, sans-serif;
    font-size: 1em;
    cursor: pointer;
}

/* Remove default arrow */
select::-ms-expand {
    display: none;
}

/* Add custom arrow */
.spellcasting-field select {
    background-image: url("data:image/svg+xml;utf8,<svg fill='black' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 3px center;
    background-size: 16px;
    padding-right: 25px;
}

/* Dark mode styles for select */
.dark-mode select {
    background-color: #555;
    color: #eee;
    border-color: #666;
}

/* Dark mode custom arrow */
.dark-mode .spellcasting-field select {
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
}

/* Focus state */
select:focus {
    outline: none;
    border-color: #000;
    box-shadow: none;
}

.dark-mode select:focus {
    border-color: #777;
    background-color: #666;
}

/* Add spell save DC input to the placeholder color rules */
#spell-save-dc::placeholder {
    color: black;
    opacity: 1;
}

/* Add to dark mode placeholder rules */
.dark-mode #spell-save-dc::placeholder {
    color: #eee;
    opacity: 1;
}

/* Add spell attack bonus input to the placeholder color rules */
#spell-attack-bonus::placeholder {
    color: black;
    opacity: 1;
}

/* Add to dark mode placeholder rules */
.dark-mode #spell-attack-bonus::placeholder {
    color: #eee;
    opacity: 1;
}

/* Dark mode styles */
.dark-mode .section-label,
.dark-mode .personality-traits-container label,
.dark-mode .features-traits-container label,
.dark-mode .current-hit-points label,
.dark-mode .temporary-hit-points label,
.dark-mode .hit-dice label,
.dark-mode .attacks-equipment-label,
.dark-mode .equipment-notes textarea {
    border-color: #666 !important; /* Force grey borders */
}

.dark-mode .personality-traits-container,
.dark-mode .features-traits-container,
.dark-mode .current-hit-points,
.dark-mode .temporary-hit-points,
.dark-mode .hit-dice,
.dark-mode .equipment {
    border-color: #666 !important; /* Force grey borders */
}

/* Ensure top borders of labels are also grey */
.dark-mode .personality-traits-container label,
.dark-mode .features-traits-container label,
.dark-mode .current-hit-points label,
.dark-mode .temporary-hit-points label,
.dark-mode .hit-dice label {
    border-top-color: #666 !important; /* Force grey top borders */
}

/* Update other border colors to match */
.dark-mode input,
.dark-mode textarea,
.dark-mode select {
    border-color: #666 !important;
}

.dark-mode .character-sheet {
    border-color: #666 !important;
}

.dark-mode .section-one,
.dark-mode .name-banner,
.dark-mode .ability-score,
.dark-mode .prof-bonus-container,
.dark-mode .inspiration-container,
.dark-mode .saving-throws,
.dark-mode .skills,
.dark-mode .passive-wisdom-container,
.dark-mode .other-proficiencies-container,
.dark-mode .combat-stat {
    border-color: #666 !important;
}

.dark-mode .hp-max-line,
.dark-mode .hd-total-line {
    border-bottom-color: #666 !important;
}

.dark-mode .name-banner input {
    border-bottom-color: #666 !important;
}

/* Reset all checkbox styles first */
input[type="checkbox"],
.save-circle,
.spell-prepared,
.skill-item input[type="checkbox"],
.save-item input[type="checkbox"],
.inspiration-container input[type="checkbox"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border: 1px solid #000 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    position: relative !important;
}

/* Regular checkbox checked state (for saving throws and other non-skill checkboxes) */
input[type="checkbox"]:not([data-state]):checked {
    background-color: black !important;
}

/* Tristate checkboxes - MUST have data-state attribute */
input[type="checkbox"][data-state],
.skill-item input[type="checkbox"][data-state] {
    background-color: transparent !important;
    background-image: none !important;
}

/* Unchecked state (clear) */
input[type="checkbox"][data-state="unchecked"] {
    background-color: white !important;
}

/* Proficiency state (dot) */
input[type="checkbox"][data-state="checked"] {
    background-color: transparent !important;
}

input[type="checkbox"][data-state="checked"]::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Expertise state (double dot) */
input[type="checkbox"][data-state="expertise"] {
    background-color: transparent !important;
}

input[type="checkbox"][data-state="expertise"]::after {
    content: '••' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Dark mode styles */
.dark-mode input[type="checkbox"] {
    background-color: #555 !important;
    border-color: #666 !important;
}

/* Dark mode regular checkbox */
.dark-mode input[type="checkbox"]:not([data-state]):checked {
    background-color: #eee !important;
}

/* Dark mode tristate - expertise (double dot) */
.dark-mode input[type="checkbox"][data-state="expertise"] {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}

.dark-mode input[type="checkbox"][data-state="expertise"]::after {
    content: '••' !important;
    position: absolute !important;
    color: #eee !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Dark mode tristate - checked (dot) */
.dark-mode input[type="checkbox"][data-state="checked"] {
    background: none !important;
    background-color: transparent !important;
    background-image: none !important;
}

.dark-mode input[type="checkbox"][data-state="checked"]::after {
    content: '•' !important;
    position: absolute !important;
    color: #eee !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
}

/* Add these rules to center input text */
input[type="text"],
input[type="number"],
input.save-value,
input.skill-value,
input.ability-value,
input.ability-modifier,
input.prof-bonus-container input,
input.hp-max-input,
input.hd-total-input,
input.equipment-input {
    text-align: center;
}

/* Exception for specific inputs that shouldn't be centered */
.name-banner input,
.detail-item input,
.personality-traits-container textarea,
.features-traits-container textarea,
.equipment-notes textarea,
.attacks-spellcasting textarea {
    text-align: left;
}

.spell-slots-container input {
    text-align: center;
}

.spell-slot input {
    text-align: center;
}

/* Ensure these take precedence */
.spell-slots input[type="text"],
.spell-slots input[type="number"] {
    text-align: center !important;
}

/* Left justify spellcasting class input specifically */
#spellcasting-class {
    text-align: left !important;
}

/* Left justify specific fields with high specificity */
.spellcasting-section .spellcasting-field input#spellcasting-class {
    text-align: left !important;
}

/* Left justify other specific fields */
.spellcasting-field select,
#custom-spellcasting-ability,
.attack-row .name-input,
.attack-row .damage-input {
    text-align: left;
}

/* Keep attack bonus centered */
.attack-row .atk-input {
    text-align: center;
}

/* Add this more specific rule */
.cantrips-list input[type="text"].cantrip-input,
.cantrips-section .cantrips-list .cantrip-input {
    text-align: left !important;
}

/* Style for spell input rows */
.spell-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 2px;
}

.spell-row input[type="checkbox"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border: 1px solid #000 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
}

.spell-row input[type="checkbox"]:checked {
    background-color: #000 !important;
}

.spell-row input[type="text"].spell-input {
    width: 100%;
    height: 20px; /* Reduced from 24px */
    background-color: white !important; /* Match global input background */
    border: 1px solid #000 !important; /* Match global input border */
    border-radius: 5px !important; /* Match global input border-radius */
    font-size: 0.7em; /* Reduced from 0.8em */
    padding: 0;
    margin: 0;
    display: block;
    text-align: left;
    line-height: 20px; /* Match height to remove internal padding */
}

/* Update dark mode styling to match global dark mode inputs */
.dark-mode .spell-row input[type="text"].spell-input {
    background-color: #555 !important; /* Match global dark mode input background */
    color: #eee !important;
    border-color: #666 !important;
}

.dark-mode .spell-row input[type="text"].spell-input:focus {
    border-color: #777 !important;
    background-color: #666 !important;
}

/* Dark mode styles */
.dark-mode .spell-row input[type="checkbox"] {
    background-color: #555 !important;
    border-color: #666 !important;
}

.dark-mode .spell-row input[type="checkbox"]:checked {
    background-color: #eee !important;
}

.dark-mode .spell-row input[type="text"].spell-input {
    background-color: #444;
    color: #fff;
    border-bottom-color: #666;
}

/* Spell list container */
.spell-list {
    padding: 2px;
    flex-grow: 1;
    overflow-y: auto;
}

/* Remove old spell-item styles */
.spell-item {
    display: none;
}

/* Update spell list styling to match cantrips */
.spell-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px;
    margin: 0;
}

/* Remove any additional spacing from spell rows */
.spell-row {
    margin: 0;
}

/* Ensure consistent styling with cantrips */
.spell-row input[type="text"].spell-input {
    width: 100%;
    height: 20px; /* Reduced from 24px */
    border: 1px solid #000;
    border-radius: 5px;
    font-size: 0.7em; /* Reduced from 0.8em */
    padding: 0;
    margin: 0;
    display: block;
    text-align: left;
    line-height: 20px; /* Match height to remove internal padding */
}

/* Add these styles for the expertise state */
input[type="checkbox"].expertise {
    background: linear-gradient(45deg, #000 0%, #000 100%) !important;
    position: relative;
}

input[type="checkbox"].expertise::after {
    content: '•';
    position: absolute;
    color: white;
    font-size: 14px;
    line-height: 10px;
    width: 100%;
    text-align: center;
    left: 0;
}

/* Dark mode expertise styles */
.dark-mode input[type="checkbox"].expertise {
    background: linear-gradient(45deg, #eee 0%, #eee 100%) !important;
}

.dark-mode input[type="checkbox"].expertise::after {
    color: #555;
}

/* Base checkbox styles with high specificity */
input[type="checkbox"][data-state].skill-item,
.skill-item input[type="checkbox"][data-state] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border: 1px solid #000 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    position: relative !important;
}

/* Unchecked state */
input[type="checkbox"][data-state="unchecked"].skill-item,
.skill-item input[type="checkbox"][data-state="unchecked"] {
    background-color: white !important;
}

/* Proficiency state */
input[type="checkbox"][data-state="checked"].skill-item,
.skill-item input[type="checkbox"][data-state="checked"] {
    background-color: white !important;
}

input[type="checkbox"][data-state="checked"].skill-item::after,
.skill-item input[type="checkbox"][data-state="checked"]::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
}

/* Expertise state */
input[type="checkbox"][data-state="expertise"].skill-item,
.skill-item input[type="checkbox"][data-state="expertise"] {
    background-color: white !important;
}

input[type="checkbox"][data-state="expertise"].skill-item::after,
.skill-item input[type="checkbox"][data-state="expertise"]::after {
    content: '••' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
}

/* Dark mode styles */
.dark-mode input[type="checkbox"][data-state].skill-item,
.dark-mode .skill-item input[type="checkbox"][data-state] {
    background-color: #555 !important;
    border-color: #666 !important;
}

.dark-mode input[type="checkbox"][data-state="checked"].skill-item::after,
.dark-mode .skill-item input[type="checkbox"][data-state="checked"]::after,
.dark-mode input[type="checkbox"][data-state="expertise"].skill-item::after,
.dark-mode .skill-item input[type="checkbox"][data-state="expertise"]::after {
    color: #eee !important;
}

/* Third page styles */
.third-page {
  max-width: 768px;
  margin: 2px auto;
  background-color: white;
  padding: 2px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  height: 1008px;
  width: 768px;
}

.notes-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2px;
  height: 100%;
  padding: 2px;
}

.notes-column {
  height: 100%;
}

.notes-container {
  border: 1px solid #000;
  border-radius: 5px;
  padding: 3px;
  background-color: white;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.notes-container textarea {
  width: 100%;
  height: calc(100% - 20px);
  border: none;
  resize: none;
  font-size: 0.8em;
  font-family: Arial, sans-serif;
  margin-top: 3px;
}

.notes-label {
  font-size: 0.7em;
  font-weight: bold;
  text-align: center;
  border: none;
  border-bottom: 1px solid #000;
  padding-bottom: 3px;
  width: 100%;
  background: transparent;
}

.notes-label::placeholder {
  color: #666;
}

/* Dark mode support */
.dark-mode .notes-container {
  background-color: #444;
  border-color: #666;
}

.dark-mode .notes-container textarea {
  background-color: #555;
  color: #eee;
}

.dark-mode .notes-label {
  color: #eee;
  border-bottom-color: #666;
}

.dark-mode .notes-label::placeholder {
  color: #999;
}

  /* Regular checkboxes - MUST NOT have data-state attribute */
  input[type="checkbox"]:not([data-state]) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 12px !important;
    height: 12px !important;
    border: 1px solid #000 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    position: relative !important;
  }

  input[type="checkbox"]:not([data-state]):checked {
    background-color: transparent !important;
  }

  input[type="checkbox"]:not([data-state]):checked::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
  }

  /* Dark mode regular checkboxes */
  .dark-mode input[type="checkbox"]:not([data-state]) {
    background-color: #555 !important;
    border-color: #666 !important;
  }

  .dark-mode input[type="checkbox"]:not([data-state]):checked {
    background-color: #555 !important;
  }

  .dark-mode input[type="checkbox"]:not([data-state]):checked::after {
    color: white !important;
  }

  /* Tristate checkboxes - MUST have data-state attribute */
  input[type="checkbox"][data-state].skill-item,
  .skill-item input[type="checkbox"][data-state] {
    background-color: transparent !important;
    background-image: none !important;
  }

  /* Override any checked states for tristate boxes */
  input[type="checkbox"][data-state]:checked,
  .skill-item input[type="checkbox"][data-state]:checked {
    background-color: transparent !important;
    background-image: none !important;
  }

  /* Proficiency state */
  input[type="checkbox"][data-state="checked"],
  .skill-item input[type="checkbox"][data-state="checked"] {
    background-color: transparent !important;
    background-image: none !important;
  }

  input[type="checkbox"][data-state="checked"]::after,
  .skill-item input[type="checkbox"][data-state="checked"]::after {
    content: '•' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
  }

  /* Expertise state */
  input[type="checkbox"][data-state="expertise"],
  .skill-item input[type="checkbox"][data-state="expertise"] {
    background-color: transparent !important;
    background-image: none !important;
  }

  input[type="checkbox"][data-state="expertise"]::after,
  .skill-item input[type="checkbox"][data-state="expertise"]::after {
    content: '••' !important;
    position: absolute !important;
    color: black !important;
    font-size: 14px !important;
    line-height: 10px !important;
    width: 100% !important;
    text-align: center !important;
    left: 0 !important;
    background: none !important;
  }

  /* Dark mode overrides */
  .dark-mode input[type="checkbox"] {
    border-color: black !important;
    background-color: white !important;
  }

  /* Dark mode regular checkboxes */
  .dark-mode input[type="checkbox"]:not([data-state]):checked {
    background-color: #555 !important;
    background-image: none !important;
  }

  /* Dark mode tristate checkboxes */
  .dark-mode input[type="checkbox"][data-state],
  .dark-mode .skill-item input[type="checkbox"][data-state] {
    background-color: #555 !important;
    background-image: none !important;
  }

  /* Ensure no backgrounds interfere with the dots */
  .dark-mode input[type="checkbox"][data-state]::after,
  .dark-mode .skill-item input[type="checkbox"][data-state]::after {
    background: none !important;
  }

  /* Hide non-printable elements */
  .no-print {
    display: none !important;
  }

/* Modal styling (for print and dice roller) */
#print-modal,
#dice-roller-modal {
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 5px;
  max-width: 500px;
  width: 80%;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
  gap: 10px;
}

.modal-buttons button {
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 4px;
  border: none;
}

/* Dark mode specific styles for modals */
.dark-mode .modal-content {
  background-color: #333;
  color: #eee;
  border: 1px solid #555;
}

.dark-mode #print-modal h2,
.dark-mode #dice-roller-modal h2 {
  color: #fff;
}

.dark-mode #print-modal p,
.dark-mode #print-modal li,
.dark-mode #print-modal strong,
.dark-mode #dice-roller-modal p,
.dark-mode #dice-roller-modal h3 {
  color: #eee;
}

.dark-mode .modal-buttons button {
  background-color: #555;
  color: #fff;
  border: 1px solid #777;
}

.dark-mode .modal-buttons button:hover {
  background-color: #666;
}

/* Dice Roller Specific Styles */
.dice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
  justify-content: center;
}

.dice-btn {
  padding: 10px 15px;
  font-size: 16px;
  border-radius: 5px;
  border: 1px solid #ccc;
  background-color: #f5f5f5;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dice-btn:hover {
  background-color: #e0e0e0;
}

.dark-mode .dice-btn {
  background-color: #555;
  color: #eee;
  border-color: #777;
}

.dark-mode .dice-btn:hover {
  background-color: #666;
}

.dice-custom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
  align-items: center;
  justify-content: center;
}

.dice-custom label {
  font-size: 14px;
}

.dice-custom input {
  width: 60px;
  padding: 5px;
  border-radius: 3px;
  border: 1px solid #ccc;
}

.dice-results {
  margin-top: 20px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f9f9f9;
}

.dark-mode .dice-results {
  background-color: #444;
  border-color: #666;
}

#dice-result-display {
  font-size: 16px;
  line-height: 1.5;
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  padding: 10px;
  margin-top: 10px;
  border-radius: 3px;
  background-color: #fff;
  border: 1px solid #ddd;
}

.dark-mode #dice-result-display {
  background-color: #333;
  border-color: #555;
  color: #eee;
}

/* Print lines styles - only active when toggled */
.print-lines textarea {
  background-image: linear-gradient(to bottom, #eee 1px, transparent 1px);
  background-size: 100% 1.2em;
  line-height: 1.2em;
  padding-bottom: 0;
  background-attachment: local;
  background-repeat: repeat;
}

/* Dark mode adjustments */
.dark-mode.print-lines textarea {
  background-image: linear-gradient(to bottom, #555 1px, transparent 1px);
}

/* Print lines styles for printing - only active when toggled and printing */
@media print {
  body.print-lines-printing textarea,
  body.print-lines-printing .other-proficiencies-container textarea,
  body.print-lines-printing .personality-traits-container textarea,
  body.print-lines-printing .features-traits-container textarea,
  body.print-lines-printing .equipment-notes textarea,
  body.print-lines-printing .notes-container textarea {
    background-image: linear-gradient(to bottom, #000 1px, transparent 1px) !important;
    background-size: 100% 1.2em !important;
    line-height: 1.2em !important;
    padding-bottom: 0 !important;
    background-attachment: local !important;
    background-repeat: repeat !important;
  }
}

/* Print-specific styles */
@media print {
    /* Force print lines when the button is enabled */
    textarea {
        background-image: none !important;
    }

    body.print-lines-printing textarea {
        background-image: linear-gradient(to bottom, #000 1px, transparent 1px) !important;
        background-size: 100% 1.2em !important;
        line-height: 1.2em !important;
        padding-bottom: 0 !important;
        background-attachment: local !important;
        background-repeat: repeat !important;
    }


    /* Remove break-inside from spell-level-section */
    .spell-level-section {
        break-inside: auto !important; /* Changed from avoid to auto */
        page-break-inside: auto !important; /* Changed from avoid to auto */
    }
    /* Adjust spell sections */
    .spell-level-section {
        overflow: visible !important; /* Changed from hidden to visible */
        flex: none !important; /* Changed from 1 to none */
    }
    /* Adjust spell sections */
    .spell-sections {
        display: block !important; /* Changed from grid to block */
    }
    .spell-column {
        float: left !important; /* Changed from flex to float */
        width: 33.33% !important; /* Changed from flex to float */
    }
    .spell-level-section {
        width: 100% !important;
    }
}

/* Spell Sections */
.spell-sections {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
    margin-top: 0;  /* Remove the gap */
    height: calc(100% - 130px);
}

/* Target only the middle column of spell sections */
.spell-sections .spell-column:nth-child(2) {
    gap: 8px;  /* Adjust this value to increase/decrease vertical spacing */
}

/* Target only the right column of spell sections */
.spell-sections .spell-column:nth-child(3) {
    gap: 5px;  /* Adjust this value to increase/decrease vertical spacing */
}

.spell-column {
    display: flex;
    flex-direction: column;
    gap: 2px;  /* Changed from 0 to 2px */
    height: 100%;
}

.spell-level-section {
    border: 1px solid #000;
    border-radius: 5px;
    background-color: white;
    display: flex;
    flex-direction: column;
    flex: none; /* Changed from 1 to none */
    overflow: visible; /* Changed from hidden to visible */
    margin: 0; /* Remove all margins */
}

.spell-level-section.cantrips-section {
    flex: 0 0 auto; /* Don't grow or shrink, size to content */
}

/* ... (Rest of your CSS) ... */
