:root {
    --char-bg-night: #08121f;
    --char-bg-forest: #102238;
    --char-surface: rgba(18, 32, 52, 0.82);
    --char-surface-soft: rgba(29, 46, 71, 0.8);
    --char-surface-ink: rgba(11, 20, 36, 0.88);
    --char-border: rgba(201, 168, 97, 0.36);
    --char-border-soft: rgba(186, 156, 93, 0.2);
    --char-accent: #d4a94d;
    --char-accent-soft: rgba(212, 169, 77, 0.2);
    --char-rune: #70e1c8;
    --char-text: #efe6d1;
    --char-muted: #b8b39f;
    --char-danger: #bc4b42;
    --char-shadow: 0 18px 44px rgba(2, 8, 18, 0.62);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    padding: 2.2rem 1.1rem 3.2rem;
    font-family: "Alegreya", "Georgia", "Times New Roman", serif;
    color: var(--char-text);
    background:
        radial-gradient(circle at 12% 10%, rgba(112, 225, 200, 0.12), transparent 28%),
        radial-gradient(circle at 88% 8%, rgba(212, 169, 77, 0.14), transparent 24%),
        linear-gradient(170deg, var(--char-bg-night), var(--char-bg-forest));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.07) 0 1px, transparent 2px),
        radial-gradient(circle at 70% 35%, rgba(255, 255, 255, 0.06) 0 1px, transparent 2px),
        radial-gradient(circle at 40% 70%, rgba(255, 255, 255, 0.05) 0 1px, transparent 2px);
    opacity: 0.5;
    z-index: -1;
}

.character-page {
    width: min(1080px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.pageTitle {
    margin: 0 0 0.35rem;
    text-align: center;
    font-family: "Cinzel Decorative", "Cinzel", "Times New Roman", serif;
    font-size: clamp(1.55rem, 2.9vw, 2.35rem);
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: #f7e8c1;
    text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}

.pageTitle::after {
    content: "";
    display: block;
    width: min(320px, 80%);
    margin: 0.52rem auto 0;
    border-bottom: 1px solid var(--char-border);
}

.character-page > p,
.character-page > div,
.character-page > form {
    width: min(980px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.character-page > p,
.character-page > div {
    margin-top: 0;
    margin-bottom: 0;
    color: var(--char-muted);
    font-size: 1.03rem;
}

.character-page > p:first-of-type {
    color: #f6ecd8;
    font-size: 1.13rem;
}

.character-page > p:nth-of-type(2) {
    margin-top: 0.2rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    border: 1px dashed var(--char-border-soft);
    background: rgba(15, 27, 46, 0.6);
    color: #e9dfc9;
}

.character-page a {
    color: var(--char-rune);
    text-decoration: none;
}

.character-page a:hover {
    text-decoration: underline;
}

form {
    margin-top: 0.4rem;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid var(--char-border-soft);
    background: linear-gradient(170deg, var(--char-surface), var(--char-surface-ink));
    box-shadow: var(--char-shadow);
    color: var(--char-text);
}

form input[type="text"],
form input[type="number"],
form input[type="date"],
form select,
form textarea {
    width: 100%;
    margin: 0.28rem 0 0.82rem;
    padding: 0.6rem 0.72rem;
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(112, 225, 200, 0.2);
    background: rgba(8, 17, 32, 0.78);
    color: var(--char-text);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.35;
}

form input[type="text"]::placeholder,
form input[type="number"]::placeholder,
form textarea::placeholder {
    color: rgba(184, 179, 159, 0.7);
}

form input[type="text"]:focus,
form input[type="number"]:focus,
form input[type="date"]:focus,
form select:focus,
form textarea:focus {
    outline: 2px solid rgba(112, 225, 200, 0.32);
    border-color: rgba(112, 225, 200, 0.52);
    box-shadow: 0 0 0 3px rgba(112, 225, 200, 0.16);
}

form input[type="radio"],
form input[type="checkbox"] {
    accent-color: var(--char-accent);
    width: 1.08rem;
    height: 1.08rem;
    margin-right: 0.35rem;
}

form input[type="radio"] + label,
form input[type="checkbox"] + label {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0.32rem 0.62rem;
    border-radius: 999px;
    margin: 0.16rem 0.3rem 0.16rem 0;
    border: 1px solid transparent;
    background: rgba(212, 169, 77, 0.09);
    color: #f3e7cc;
    font-size: 0.95rem;
}

form input[type="radio"]:checked + label,
form input[type="checkbox"]:checked + label {
    border-color: rgba(212, 169, 77, 0.52);
    background: var(--char-accent-soft);
}

input.nonValidRadio + label {
    text-decoration: line-through;
    opacity: 0.42;
}

form input[type="submit"],
button,
#scratchButton {
    margin-top: 0.55rem;
    padding: 0.56rem 1.22rem;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: linear-gradient(135deg, #cf9a3f, #2ea18c);
    color: #f9f7f1;
    font-family: "Cinzel", "Georgia", serif;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

form input[type="submit"]:hover,
button:hover,
#scratchButton:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(2, 8, 18, 0.48);
    filter: brightness(1.03);
}

#scratchButton {
    background: linear-gradient(135deg, #a93630, #cf5846);
}

.reqsRadios {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.16rem 0.5rem;
}

.spanTwoColumns {
    grid-column: 1 / -1;
    margin-bottom: 0.3rem;
    color: #f3e3bf;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.77rem;
}

.profTable {
    margin-top: 0.8rem;
    padding: 0.4rem;
    border-radius: 14px;
    border: 1px solid var(--char-border-soft);
    background: rgba(9, 18, 34, 0.8);
}

#slotTracker {
    position: sticky;
    top: 0.5rem;
    z-index: 50;
    margin: 0.75rem 0 0.45rem;
    padding: 0.52rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(112, 225, 200, 0.2);
    background: rgba(8, 20, 36, 0.95);
    color: #e8dfc8;
    text-align: center;
}

.characterDiv {
    margin-top: 0.35rem;
    background: linear-gradient(165deg, rgba(20, 35, 58, 0.92), rgba(8, 16, 31, 0.95));
    border-radius: 18px;
    border: 1px solid var(--char-border-soft);
    box-shadow: var(--char-shadow);
    color: #e8dfc8;
    overflow: hidden;
}

.basicInfoBlock,
.abilityScoresBlock,
.movementBlock,
.saveingThrowsBlock,
.hitDiceBlock,
.specialsBlock,
.xpBlock,
.raceSpecialsBlock,
.classSpecialsBlock,
.weaponProficienciesBlock,
.nonWeaponProficienciesBlock,
.equipmentBlock {
    padding: 0.8rem 0.85rem;
    border-bottom: 1px solid rgba(212, 169, 77, 0.16);
}

.basicInfoBlock .infoRow {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.22rem 0;
    border-bottom: 1px dashed rgba(212, 169, 77, 0.14);
}

.abilityScoreRow,
.blockRow {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
}

.blockRow {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    border-bottom: 1px solid rgba(212, 169, 77, 0.16);
}

.blockRow > div {
    min-width: 0;
    width: 100%;
    border-bottom: 0;
}

.blockRow > div:only-child {
    grid-column: 1 / -1;
}

.blockRow > div + div {
    border-left: 1px solid rgba(212, 169, 77, 0.14);
}

.abilityScore {
    min-width: 30%;
    white-space: nowrap;
}

.subAbilityScores span {
    margin-right: 0.62rem;
    white-space: nowrap;
}

.subAbilityScores span.allowBreak {
    white-space: normal;
}

.movementRow {
    margin: 0;
}

.addMargin {
    margin: 1rem 0;
}

.characterDiv .xpBlock br + br,
.characterDiv .saveingThrowsBlock br + br,
.characterDiv .weaponProficienciesBlock br + br,
.characterDiv .nonWeaponProficienciesBlock br + br,
.characterDiv .equipmentBlock br + br {
    display: none;
}

.pageTitle,
.mailto {
    text-align: center;
}

ul,
ol {
    margin: 0.55rem 0 0.25rem 1.2rem;
    padding: 0;
}

li {
    margin-bottom: 0.38rem;
}

.mailto {
    font-size: 0.9rem;
    color: var(--char-muted);
}

@media (max-width: 900px) {
    body {
        padding: 1.35rem 0.72rem 2.1rem;
    }

    .character-page {
        gap: 0.72rem;
    }

    .character-page > p,
    .character-page > div,
    .character-page > form {
        width: min(100%, 940px);
    }
}

@media (max-width: 720px) {
    body {
        padding: 1rem 0.45rem 1.5rem;
    }

    .pageTitle {
        font-size: clamp(1.18rem, 7vw, 1.55rem);
        letter-spacing: 0.08em;
    }

    .character-page > p,
    .character-page > div {
        font-size: 0.92rem;
    }

    form {
        padding: 0.72rem;
        border-radius: 12px;
    }

    .reqsRadios {
        grid-template-columns: minmax(0, 1fr);
    }

    .spanTwoColumns {
        grid-column: 1 / 2;
    }

    .basicInfoBlock .infoRow,
    .abilityScoreRow,
    .blockRow {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .abilityScore {
        min-width: 0;
        white-space: normal;
    }

    form input[type="submit"],
    button,
    #scratchButton {
        width: 100%;
        min-height: 42px;
    }
}

@media print {
    @page {
        size: letter;
        margin: 0.5in;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    body * {
        visibility: hidden;
    }

    #characterPreview,
    #characterPreview * {
        visibility: visible;
        color: #000000 !important;
    }

    #characterPreview {
        position: absolute;
        left: 0;
        top: 0;
        width: 8.5in;
        max-width: none;
        transform: none;
        background: none;
        padding: 0;
        box-shadow: none;
    }

    .characterDiv {
        border: 1px solid #000000;
        border-radius: 0;
        box-shadow: none;
        background: #ffffff;
        overflow: visible;
    }

    .basicInfoBlock,
    .abilityScoresBlock,
    .movementBlock,
    .saveingThrowsBlock,
    .hitDiceBlock,
    .specialsBlock,
    .xpBlock,
    .raceSpecialsBlock,
    .classSpecialsBlock,
    .weaponProficienciesBlock,
    .nonWeaponProficienciesBlock,
    .equipmentBlock {
        border: 0 !important;
        border-bottom: 1px solid #000000 !important;
        padding: 8px 10px;
        break-inside: avoid;
    }

    .characterDiv > *:last-child {
        border-bottom: 0 !important;
    }

    .blockRow {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        border-bottom: 1px solid #000000;
        break-inside: avoid;
    }

    .blockRow > div {
        border-right: 1px solid #000000;
        border-bottom: 0 !important;
        min-width: 0;
    }

    .blockRow > div:last-child {
        border-right: 0;
    }

    .infoRow {
        border-bottom: 1px dashed #999999 !important;
    }

    .characterDiv br {
        line-height: 1.35;
    }
}
