/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Page ── */
body {
    background: #0d0d1a;
    color: #e0e0e0;
    font-family: 'Roboto', sans-serif;
    min-height: 100vh;
    padding: 24px 32px;
}

h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #c8aa6e;
    margin-bottom: 28px;
}

/* ── Layout ── */
.layout {
    display: flex;
    gap: 48px;
    align-items: flex-start;
    justify-content: center;
    max-width: 1000px;
    margin: 0 auto;
}

/* ── Form panel ── */
.form-panel {
    flex: 1;
    min-width: 240px;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toggle-checkbox {
    display: none;
}

.toggle-label {
    display: block;
    width: 100%;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    color: #7a7a9a;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.toggle-label:hover {
    border-color: #c8aa6e;
    color: #c8aa6e;
}

.toggle-checkbox:checked + .toggle-label {
    border-color: #c8aa6e;
    color: #c8aa6e;
    background: #1e1a0e;
}

/* ── Hi Res / Lo Res pill toggle ── */
.res-toggle-input { display: none; }

.res-toggle-label {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
    margin-top: 6px;
    transition: border-color 0.15s;
}

.res-toggle-label:hover { border-color: #c8aa6e; }

.res-opt {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    text-align: center;
    padding: 7px 4px;
    color: #7a7a9a;
    transition: color 0.15s, background 0.15s;
}

/* Unchecked = Hi Res active */
.res-toggle-input:not(:checked) + .res-toggle-label .res-left {
    color: #c8aa6e;
    background: #1e1a0e;
}

/* Checked = Lo Res active */
.res-toggle-input:checked + .res-toggle-label .res-right {
    color: #c8aa6e;
    background: #1e1a0e;
}

label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #7a7a9a;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    color: #e0e0e0;
    padding: 8px 12px;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

textarea {
    resize: none;
    line-height: 1.4;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #c8aa6e;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7a9a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

select option {
    background: #13132a;
}

input[type="file"] {
    display: none;
}

.file-label {
    display: block;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: #7a7a9a;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-label:hover {
    border-color: #c8aa6e;
    color: #c8aa6e;
}

.download-btn {
    width: 100%;
    background: #c8aa6e;
    color: #0a0a16;
    border: none;
    border-radius: 3px;
    padding: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 2px;
}

.download-btn:hover {
    background: #dbbe82;
}

.reset-btn {
    width: 100%;
    background: transparent;
    color: #7a7a9a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    padding: 9px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.reset-btn:hover {
    border-color: #c8aa6e;
    color: #c8aa6e;
}

/* ── Polarity picker ── */
.polarity-picker {
    position: relative;
}

.polarity-picker-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    color: #e0e0e0;
    padding: 8px 12px;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s;
    user-select: none;
}

.polarity-picker-trigger:hover {
    border-color: #c8aa6e;
}

.pp-trigger-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
}

.pp-trigger-icon[src=""] {
    display: none;
}

.pp-arrow {
    margin-left: auto;
    flex-shrink: 0;
}

.pp-options {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-top: none;
    border-radius: 0 0 3px 3px;
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
}

.pp-options.open {
    display: block;
}

.pp-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    color: #e0e0e0;
    transition: background 0.1s;
}

.pp-option:hover {
    background: #1c1c38;
    color: #c8aa6e;
}

.pp-option img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
}

.tab-btn {
    background: transparent;
    border: 1px solid #2a2a46;
    border-radius: 3px;
    color: #7a7a9a;
    padding: 7px 24px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.tab-btn:hover,
.tab-btn.active {
    border-color: #c8aa6e;
    color: #c8aa6e;
}

/* ── Preview panel ── */
.preview-panel {
    flex-shrink: 0;
}

.preview-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #7a7a9a;
    text-align: center;
    margin-bottom: 10px;
}

/* ── Mod card ── */
.card-container {
    position: relative;
    width: 380px;
    display: inline-block;
    user-select: none;
}

/* Sets card-container height in normal flow */
.card-bg {
    display: block;
    width: 100%;
    height: auto;
}

/* Shared base for all overlay layers */
.card-layer {
    position: absolute;
    height: auto;
    pointer-events: none;
}

/*
  All sizes are % of the 252px background canvas width.
  Vertical positions are % of the 374px canvas height.
*/

.card-exilus {             /* 20×15 px — Exilus indicator, top center */
    z-index: 6;
    width: 7.94%;
    top: 3.5%;
    left: 50%;
    transform: translateX(-50%);
    display: none;
}

.card-frame-top {          /* 281×117 px — wider than card, centered at top */
    z-index: 5;
    width: 111.5%;
    top: -1.5%;
    left: 50%;
    transform: translateX(-50%);
}

.card-lower-tab {          /* 210×26 px — centered strip near bottom */
    z-index: 1;
    width: 83.3%;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
}

.card-side-light {         /* 16×256 px — thin strip on right edge */
    z-index: 3;
    width: 6.35%;
    top: 11%;
    right: 0;
}

.card-side-left {          /* mirror of right sidelight */
    right: auto;
    left: 0;
    transform: scaleX(-1);
}

.card-top-right-backer {   /* 45×26 px — small badge, top-right */
    z-index: 4;
    width: 18%;
    top: 4.3%;
    right: 2.2%;
    transform: scaleX(1.05) scaleY(1);
}

/* html2canvas honours overflow:hidden but not clip-path — use this wrapper to clip the icon */
.icon-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
}


.icon-fade {
    position: absolute;
    left: 2%;
    width: 96%;
    pointer-events: none;
    z-index: 3;
    opacity: 0.75;
}

/* JS sets top in px (33.5% of card height) after layout */
.icon {
    position: absolute;
    top: 33.5%;
    left: 50%;
    transform: translate(-50%, -50%) scaleX(1.02) scaleY(1.05);
    width: 94%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    pointer-events: none;
}

.icon[src=""] {
    visibility: hidden;
}

.card-cost {
    position: absolute;
    top: 7.9%;
    right: 10.5%;
    transform: translateY(-50%) scaleY(1);
    color: white;
    font-weight: 510;
    font-size: 26px;
    font-family: 'Roboto', sans-serif;
    z-index: 6;
}

.polarity {
    position: absolute;
    top: 7.8%;
    right: 3.5%;
    transform: translateY(-50%);
    width: 6.5%;
    z-index: 6;
    pointer-events: none;
    visibility: hidden;
}

.card-body-text {
    position: absolute;
    bottom: 18.5%;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 6;
}

.card-name {
    color: white;
    font-size: 34px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.5px;
    line-height: 1;
    width: 100%;
    word-wrap: break-word;
}

.card-effect {
    color: white;
    font-size: 26px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.3px;
    line-height: 1.2;
    width: 100%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.card-item-type {
    position: absolute;
    bottom: 10.8%;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: 700;
    font-size: 26px;
    font-family: 'Roboto', sans-serif;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    z-index: 6;
}

/* ── Rank ── */
.card-rank {
    position: absolute;
    bottom: 1.5%;
    left: 0;
    width: 100%;
    min-height: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    z-index: 6;
    pointer-events: none;
}

.rank-slots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    z-index: 1;
    height: 18px;  /* fixed height prevents layout shift at rank=0 */
}

.rank-slot-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Pulls line up to intersect icon centers: icons 18px tall, line ~12px tall → offset 15px */
.rank-line {
    width: 101.6%;
    height: auto;
    margin-top: -15px;
}

/* ── Arcane card ── */
.arcane-card {
    width: 300px;
    background: #100d07;
    border: 1px solid #3d2e14;
    font-family: 'Roboto', sans-serif;
    user-select: none;
    display: block;
    overflow: hidden;
    text-align: left;
}

.arcane-image-section {
    width: 100%;
    background: #100d07;
    line-height: 0;
}

.arcane-frame {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

.arcane-content {
    padding: 14px 10px 16px;
}

.arc-card-name {
    font-size: 15px;
    font-weight: 700;
    color: #f0e6cc;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    line-height: 1.2;
    margin-bottom: 8px;
    word-wrap: break-word;
}

.arc-rank-dots {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
}

.arc-rank-dot {
    width: 9px;
    height: 9px;
    transform: rotate(45deg);
    background: transparent;
    border: 1px solid #5a4020;
    flex-shrink: 0;
}

.arc-rank-dot.filled {
    background: #c8aa6e;
    border-color: #c8aa6e;
}

.arc-item-type-display {
    color: #d4b87a;
    font-size: 13px;
    margin-bottom: 10px;
}

.arc-divider {
    height: 1px;
    background: #3d2e14;
    margin-bottom: 4px;
}

.arc-rank-effect {
    font-size: 13px;
    color: #d4c8a8;
    line-height: 1.4;
    word-wrap: break-word;
    text-align: left;
}

.arc-rank-label {
    display: block;
    font-weight: 700;
    color: #c8aa6e;
    margin-bottom: 0;
}

.arc-effect-text {
    display: block;
    white-space: pre-wrap;
}

.effect-icon {
    height: 1em;
    width: auto;
    vertical-align: middle;
    display: inline;
}

.effect-bar {
    display: inline-block;
    width: 45px;
    height: 10px;
    background: transparent;
    border: 1px solid white;
    vertical-align: middle;
}

/* ── Arcane theme ── */
body.theme-arcane {
    background: #1c1500;
}

body.theme-arcane h1 {
    color: #d4a84e;
}

body.theme-arcane input[type="text"],
body.theme-arcane input[type="number"],
body.theme-arcane select,
body.theme-arcane textarea {
    background: #231b05;
    border-color: #40320e;
    color: #e8dcc8;
}

body.theme-arcane input[type="text"]:focus,
body.theme-arcane input[type="number"]:focus,
body.theme-arcane select:focus,
body.theme-arcane textarea:focus {
    border-color: #d4a84e;
}

body.theme-arcane label {
    color: #8a7040;
}

body.theme-arcane .file-label {
    background: #231b05;
    border-color: #40320e;
    color: #8a7040;
}

body.theme-arcane .file-label:hover {
    border-color: #d4a84e;
    color: #d4a84e;
}

body.theme-arcane .tab-btn {
    border-color: #40320e;
    color: #8a7040;
}

body.theme-arcane .tab-btn:hover,
body.theme-arcane .tab-btn.active {
    border-color: #d4a84e;
    color: #d4a84e;
}

body.theme-arcane .download-btn {
    background: #7a4f1e;
    color: #f0e6cc;
}

body.theme-arcane .download-btn:hover {
    background: #8f6030;
}

/* ── How to Use ── */
.how-to-use {
    max-width: 1000px;
    margin: 60px auto 0;
    padding: 0 16px;
}

.how-to-use h2 {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #c8aa6e;
    margin-bottom: 32px;
}

.htu-columns {
    display: flex;
    gap: 40px;
    justify-content: center;
}

.htu-block {
    flex: 1;
    max-width: 420px;
    background: #13132a;
    border: 1px solid #2a2a46;
    border-radius: 4px;
    padding: 24px 28px;
}

.htu-block h3 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #c8aa6e;
    margin-bottom: 16px;
}

.htu-block ol {
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.htu-block li {
    font-size: 13px;
    color: #9090b0;
    line-height: 1.5;
}

.htu-block strong {
    color: #e0e0e0;
}

.htu-link {
    color: #c8aa6e;
    text-decoration: none;
    transition: color 0.15s;
}

.htu-link:hover {
    color: #dbbe82;
    text-decoration: underline;
}

.htu-tip {
    color: #c8aa6e;
    font-style: italic;
}

.icon-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.icon-table th {
    color: #c8aa6e;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 10px;
    border-bottom: 1px solid #2a2a46;
    text-align: left;
}

.icon-table td {
    padding: 8px 10px;
    color: #9090b0;
    border-bottom: 1px solid #1a1a36;
    vertical-align: middle;
}

.icon-table tr:last-child td {
    border-bottom: none;
}

.icon-table code {
    color: #e0e0e0;
    background: #0d0d1a;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

.tip-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

/* ── Footer ── */
footer {
    text-align: center;
    margin-top: 48px;
    padding: 16px;
    font-size: 13px;
    color: #4a4a6a;
}

.ign {
    color: #c8aa6e;
    font-weight: 700;
}

.footer-link {
    color: #4a4a6a;
    font-size: 12px;
    text-decoration: none;
    letter-spacing: 1px;
    text-transform: uppercase;
    transition: color 0.15s;
}

.footer-link:hover {
    color: #c8aa6e;
}

/* ── Mobile ── */
@media (max-width: 700px) {
    body {
        padding: 16px;
    }

    h1 {
        font-size: 18px;
        letter-spacing: 2px;
        margin-bottom: 16px;
    }

    .tabs {
        margin-bottom: 20px;
    }

    .tab-btn {
        flex: 1;
        padding: 8px 12px;
    }

    .layout {
        flex-direction: column;
        gap: 28px;
    }

    .form-panel {
        max-width: 100%;
        width: 100%;
    }

    .preview-panel {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .card-container {
        width: min(380px, 90vw);
    }

    .arcane-card {
        width: min(300px, 90vw);
    }

    .htu-columns {
        flex-direction: column;
        align-items: center;
    }

    .htu-block {
        max-width: 100%;
        width: 100%;
    }
}

body.theme-arcane .reset-btn {
    border-color: #40320e;
    color: #8a7040;
}

body.theme-arcane .reset-btn:hover {
    border-color: #d4a84e;
    color: #d4a84e;
}

body.theme-arcane .pp-options {
    background: #231b05;
    border-color: #40320e;
}

body.theme-arcane .polarity-picker-trigger {
    background: #231b05;
    border-color: #40320e;
    color: #e8dcc8;
}

body.theme-arcane .polarity-picker-trigger:hover {
    border-color: #d4a84e;
}

body.theme-arcane .pp-option:hover {
    background: #2e2208;
    color: #d4a84e;
}

body.theme-arcane .preview-label {
    color: #8a7040;
}
