@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
    --ink: #68482f;
    --muted: #9c876c;
    --paper-line: rgba(157, 112, 66, .42);
    --panel: rgba(255, 249, 229, .2);
    --purple: #a63ba7;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
    min-width: 320px;
    color: var(--ink);
    font-family: "Noto Sans Thai", Tahoma, sans-serif;
    background: #6b3b21 url("../images/BG.png") center top / cover fixed no-repeat;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }

.page-shell {
    width: min(100%, 1350px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 14px 0 0;
    position: relative;
}

.site-header {
    height: 78px;
    position: relative;
    z-index: 5;
}

.brand {
    position: absolute;
    left: 0;
    top: 2px;
    width: 220px;
}

.simulator-title {
    position: absolute;
    left: 50%;
    top: 0;
    width: 420px;
    transform: translateX(-50%);
}

.simulator-title img { width: 100%; }
.simulator-title h1 {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    color: white;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: .2px;
    line-height: 1;
    text-shadow: 0 2px 1px rgba(64, 18, 61, .28);
}

.simulator-title h1 span { font-size: 20px; }
.simulator-title h1 .title-text { font-size: inherit; }
html[lang="th"] .simulator-title h1 .title-text { font-size: 26px; }

.main-nav {
    position: absolute;
    left: 50%;
    top: 52px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 690px;
}

.nav-button {
    width: 132px;
    height: 40px;
    position: relative;
    color: white;
    text-decoration: none;
    filter: drop-shadow(0 1px 1px rgba(67, 38, 15, .3));
    transition: transform .18s ease, filter .18s ease;
}

.nav-button:hover { transform: translateY(-2px); filter: brightness(1.08) drop-shadow(0 2px 2px rgba(67, 38, 15, .35)); }
.nav-button img { width: 100%; height: 100%; }
.nav-button span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 20px;
    font-weight: 500;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(71, 40, 24, .45);
}
.nav-button.website {
    width: 145px;
    height: 40px;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 22px;
    background-color: #ff9e28;
    background-image:
        linear-gradient(30deg, rgba(255, 189, 70, .42) 12%, transparent 12.5%, transparent 87%, rgba(255, 189, 70, .42) 87.5%),
        linear-gradient(150deg, rgba(255, 189, 70, .42) 12%, transparent 12.5%, transparent 87%, rgba(255, 189, 70, .42) 87.5%);
    overflow: hidden;
}
.nav-button.website img { display: none; }
.nav-button.battle { width: 174px; height: 40px; }
.nav-button.active {
    transform: scale(1.04);
    border-radius: 24px;
}
.nav-button.active::after {
    content: "";
    position: absolute;
    inset: -1px;
    z-index: 2;
    border: 4px solid #fff;
    border-radius: inherit;
    box-shadow: 0 1px 3px rgba(76, 35, 52, .38);
    pointer-events: none;
}
.nav-button.active:hover { transform: scale(1.04) translateY(-2px); }

.language {
    position: absolute;
    right: 0;
    top: 1px;
    width: 31px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.book {
    width: 100%;
    aspect-ratio: 1.921 / 1;
    min-height: 0;
    margin: -20px auto 0;
    position: relative;
    display: grid;
    /* Keep the visible book centered; the source image has transparent quill space on the right. */
    grid-template-columns: 50% 46%;
    transform: translateX(4%);
    background: url("../images/bodybook.png") center / 100% 100% no-repeat;
    z-index: 2;
}

.book-page {
    min-width: 0;
    position: relative;
    padding-top: 62px;
    font-size: 14px;
}

.input-page { padding-top: 64px; padding-left: 66px; padding-right: 50px; transform: translateX(12px); }
.result-page { padding-top: 90px; padding-left: 22px; padding-right: 80px; }

.page-heading {
    height: 31px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 18px;
    font-weight: 700;
}
.page-heading img { width: 24px; height: auto; }
.heading-underline {
    width: 180px;
    height: auto;
    margin: 1px auto 0;
}

.panel {
    border: 1px solid var(--paper-line);
    border-radius: 8px;
    background: var(--panel);
}

fieldset { min-width: 0; margin: 0; }
fieldset legend {
    padding: 4px 10px 3px;
    border-radius: 2px;
    color: white;
    background: #745136;
    font-size: 16px;
    font-weight: 600;
}

label { cursor: default; }
input, select {
    min-width: 0;
    height: 23px;
    border: 0;
    border-radius: 2px;
    outline: 0;
    color: #695139;
    background: rgba(255, 248, 226, .68);
    font-size: 14px;
    padding: 1px 7px;
}
input:not(:disabled), select:not(:disabled) {
    border: 1px solid rgba(198, 133, 62, .82);
    background-color: rgba(255, 253, 239, .94);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .52);
}
input:not(:disabled) { cursor: text; }
select:not(:disabled) { cursor: pointer; }
input:not(:disabled):hover, select:not(:disabled):hover {
    border-color: #b66b2d;
    background-color: #fffdf3;
}
input:focus, select:focus {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px rgba(166, 59, 167, .2);
}
input:disabled {
    border: 1px solid rgba(157, 112, 66, .1);
    color: #9c866c;
    background-color: rgba(221, 207, 180, .25);
    -webkit-text-fill-color: #9c866c;
    cursor: not-allowed;
    opacity: 1;
}
input::placeholder { color: #ab9a84; opacity: 1; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.pet-intro {
    height: 167px;
    display: flex;
    align-items: center;
    margin-top: 23px;
}

.pet-information {
    width: 320px;
    height: 154px;
    padding: 5px 8px 7px;
}
.pet-information label {
    height: 24px;
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: center;
}
.pet-information label + label { margin-top: 3px; }
.pet-information label > span { white-space: nowrap; }
.pet-information input, .pet-information select { width: 100%; font-size: 12px; }

.pet-portrait {
    width: 120px;
    height: 120px;
    margin: 0 auto;
    flex: 0 0 120px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(116, 81, 54, .72);
    border-radius: 50%;
    background: rgba(255, 248, 226, .42);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .28);
    transform: translateY(8px);
    overflow: hidden;
}
.pet-portrait img {
    max-width: 115px;
    max-height: 105px;
    object-fit: contain;
    border-radius: 50%;
    mix-blend-mode: multiply;
}

.stat-editor {
    height: 161px;
    margin-right: 30px;
    padding: 8px 7px;
    display: grid;
    grid-template-rows: repeat(5, 1fr);
    row-gap: 5px;
}
.stat-editor label {
    display: grid;
    grid-template-columns: 130px 80px 1fr;
    gap: 7px;
    align-items: center;
}
.stat-label { display: flex; align-items: center; white-space: nowrap; }
.stat-icon {
    width: 18px;
    height: 18px;
    margin-right: 5px;
    flex: 0 0 18px;
    object-fit: contain;
}
.stat-editor input:last-child,
.result-grid input { font-size: 11px; }

.bonus-points {
    height: 130px;
    margin-top: 15px;
    margin-right: 30px;
    padding: 6px 8px 7px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: column;
    grid-template-rows: repeat(3, 1fr);
    column-gap: 20px;
    row-gap: 6px;
}
.bonus-points label {
    display: grid;
    grid-template-columns: 115px 1fr;
    align-items: center;
}
.bonus-points input { width: 100%; font-size: 12px; }

.action-button {
    position: absolute;
    bottom: 63px;
    width: 120px;
    height: 32px;
    border: 0;
    border-radius: 0;
    color: white;
    background: url("../images/PetStat_Button.png") center / 100% 100% no-repeat;
    box-shadow: none;
    font-size: 19px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: filter .18s ease, transform .18s ease;
}

/* Keep the Pet Stat heading clear of the bookmark above it. */
.input-page > .page-heading,
.input-page > .heading-underline { transform: translateY(4px); }

html[lang="th"] .simulator-title.swap-title { width: 600px; }
html[lang="th"] .simulator-title.swap-title h1 { white-space: nowrap; }
html[lang="th"] .site-header.swap-view .main-nav { top: 68px; }
.action-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.action-button:active { transform: translateY(1px); }
.reset-button { left: 50%; transform: translateX(-50%); }
.reset-button:hover { transform: translate(-50%, -1px); }
.simulate-button { left: 42%; transform: translateX(-50%); }
.simulate-button:hover { transform: translate(-50%, -1px); }

.result-section > h2 {
    width: max-content;
    min-width: 110px;
    height: 29px;
    margin: 3px auto 13px;
    padding: 2px 13px;
    color: white;
    background: #745136;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.result-grid {
    padding: 10px 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
}
.result-grid label {
    display: grid;
    grid-template-columns: 115px 1fr;
    align-items: center;
}
.result-grid label > span {
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.result-grid input { width: 100%; }
.five-stats {
    height: 101px;
    grid-template-rows: repeat(3, 1fr);
    grid-auto-flow: column;
    row-gap: 5px;
}

.status-section { margin-top: 13px; }
.status-section > h2 { margin-bottom: 13px; }
.status-grid {
    height: 129px;
    grid-template-rows: repeat(4, 1fr);
    grid-auto-flow: column;
    row-gap: 5px;
}
.status-grid label { grid-template-columns: 100px 1fr; }

.instruction {
    margin: 16px 0 0;
    color: #9a5c27;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.swap-input-page {
    padding: 82px 70px 90px 92px;
}
.swap-input-page .page-heading { justify-content: center; padding-left: 0; }
.swap-input-page .heading-underline { margin-left: auto; margin-right: auto; }
.swap-score-panel {
    width: 100%;
    min-height: 180px;
    margin-top: 50px;
    padding: 20px 18px;
    display: grid;
    align-content: center;
    row-gap: 24px;
}
.swap-score-panel label {
    display: grid;
    row-gap: 7px;
    font-weight: 600;
}
.swap-score-panel input { width: 100%; height: 30px; }

.swap-result-page {
    padding: 102px 105px 90px 35px;
}
.swap-rate-section > h2 {
    width: max-content;
    min-width: 150px;
    min-height: 38px;
    margin: 0 auto 20px;
    padding: 6px 16px;
    color: white;
    background: #745136;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}
.swap-rate-grid {
    min-height: 230px;
    padding: 18px 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, 1fr);
    grid-auto-flow: column;
    column-gap: 18px;
    row-gap: 14px;
}
.swap-rate-grid label {
    min-width: 0;
    display: grid;
    align-content: center;
    row-gap: 7px;
    font-size: 13px;
    font-weight: 600;
}
.swap-rate-grid label > span { white-space: nowrap; }
.swap-rate-grid input { width: 100%; height: 30px; font-size: 11px; }
.swap-note {
    margin: 22px 0 0;
    color: #9a5c27;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}
.swap-query-button { left: 44%; bottom: 75px; transform: translateX(-50%); }
.swap-query-button:hover { transform: translate(-50%, -1px); }

.sr-only {
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    position: absolute !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.battle-book {
    width: 100%;
    aspect-ratio: 1725 / 926;
    margin: 24px auto 0;
    position: relative;
    color: #704b30;
    background: url("../images/BG_paper.png") center / 100% 100% no-repeat;
    transform: translateX(4%);
    z-index: 2;
}
.battle-book.is-advanced {
    aspect-ratio: 1531 / 1280;
    background-image: url("../images/Layer_2_1.png");
}
.battle-book.is-advanced .battle-content {
    height: auto;
    min-height: 96%;
}
.battle-content {
    width: 100%;
    height: 96%;
    padding: 28px 50px 40px;
    display: flex;
    flex-direction: column;
    position: relative;
}
.battle-selectors {
    order: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 275px));
    justify-content: space-between;
    gap: 0;
    padding: 0 105px;
}
.battle-selectors select { width: 100%; text-align: center; }
.battle-state {
    order: 2;
    margin-top: 36px;
}
.battle-state-title {
    width: 190px;
    min-width: 0;
    height: 32px;
    margin: 2px auto 5px;
    padding: 5px 18px;
    border-radius: 0;
    color: white;
    background: url("../images/bgHeaer.png") center / 100% 100% no-repeat;
    font-size: 22px;
    line-height: 24px;
    text-align: center;
}
.battle-side-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 70px;
    margin-top: 40px;
}
.battle-panel {
    min-width: 0;
    margin: 0;
    padding: 10px 13px 12px;
    border: 1px solid rgba(208, 118, 44, .78);
    border-radius: 10px;
    background: rgba(255, 244, 210, .52);
    position: relative;
}
.battle-panel legend {
    position: absolute;
    top: -45px;
    left: 50%;
    margin: 0;
    padding: 0;
    color: #6f4d32;
    background: transparent;
    font-size: 19px;
    font-weight: 700;
    text-align: center;
    display: flex;
    width: max-content;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transform: translateX(-50%);
    z-index: 1;
}
.battle-panel legend::before,
.battle-panel legend::after {
    width: 52px;
    height: 37px;
    content: "";
    background: center / contain no-repeat;
}
.battle-panel legend::before { background-image: url("../images/Line_L.png"); }
.battle-panel legend::after { background-image: url("../images/Line_R.png"); }
.battle-role-icon {
    width: 22px;
    height: 22px;
    margin: 0 5px 0 0;
    flex: 0 0 auto;
    object-fit: contain;
}
.battle-panel label {
    min-width: 0;
    min-height: 28px;
    display: grid;
    grid-template-columns: 165px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
    font-size: 14px;
    font-weight: 400;
}
.battle-panel label > span:first-child { white-space: nowrap; }
.battle-panel input,
.battle-panel select { width: 100%; }
.battle-value { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 18px; align-items: center; }
.battle-value b { text-align: center; font-weight: 700; }
.battle-elements { min-width: 0; display: grid; grid-template-columns: 1.15fr .85fr 1.15fr .85fr; gap: 5px; }
.battle-elements select { padding-inline: 3px; }
.battle-advanced-toggle {
    order: 3;
    width: 238px;
    height: 40px;
    margin: 24px auto 0;
    border: 0;
    border-radius: 0;
    color: white;
    background: url("../images/bgHeaer.png") center / 100% 100% no-repeat;
    font: 600 22px/1 "Noto Sans Thai", Tahoma, sans-serif;
    cursor: pointer;
}
.battle-advanced-toggle .battle-arrow { display: inline-block; margin-left: 7px; transition: transform .2s ease; }
.battle-advanced-toggle[aria-expanded="true"] .battle-arrow { transform: rotate(180deg); }
.battle-hint {
    order: 4;
    margin: 7px 0 10px;
    color: #e3221c;
    font-size: 13px;
    text-align: center;
}
.battle-advanced-state { order: 5; }
.battle-advanced-state .battle-panel { min-height: 246px; padding-top: 12px; }
.battle-book.is-advanced .battle-advanced-state { margin-top: 4px; }
.battle-book.is-advanced .battle-result-row { margin-top: 40px; }
.battle-result-row {
    order: 6;
    margin-top: auto;
    padding: 0 110px 8px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 190px;
    gap: 14px;
    align-items: center;
}
.battle-result-row h2 { margin: 0; font-size: 23px; }
.battle-result-panel {
    min-width: 0;
    padding: 7px 10px;
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 10px;
    align-items: center;
    border: 1px solid rgba(208, 118, 44, .78);
    border-radius: 9px;
    background: rgba(255, 244, 210, .6);
    font-size: 12px;
}
.battle-result-panel strong {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.battle-result-icon { width: 20px; height: 20px; object-fit: contain; }
.battle-result-panel input { width: 100%; height: 23px; font-size: 11px; text-align: center; }
.battle-simulate {
    height: 42px;
    border: 0;
    border-radius: 0;
    color: white;
    background: url("../images/PetStat_Button.png") center / 100% 100% no-repeat;
    font: 600 24px/1 "Noto Sans Thai", Tahoma, sans-serif;
    cursor: pointer;
}
.battle-simulate:hover,
.battle-advanced-toggle:hover { filter: brightness(1.08); }

@media (min-width: 901px) {
    .result-page .result-section,
    .result-page .instruction {
        transform: translateX(-35px);
    }
    .swap-result-page .swap-rate-section,
    .swap-result-page .swap-note {
        transform: translateX(-25px);
    }

    html[lang="en"] .result-grid,
    html[lang="en"] .bonus-points,
    html[lang="en"] .pet-information {
        font-size: 11px;
    }
}

.download-bar {
    height: 106px;
    margin-top: -16px;
    padding: 0 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    position: relative;
    z-index: 3;
}
.download-bar a { flex: 0 1 145px; }
.download-bar .app-icon { flex-basis: 74px; }
.download-bar .top-up { flex-basis: 290px; margin-left: 0; }

@media (max-width: 900px) {
    body { background-size: auto 100vh; background-attachment: scroll; }

    .page-shell { width: 100%; padding: 8px 7px 0; }
    .site-header { height: 147px; }
    .brand { left: 4px; top: 1px; width: 103px; }
    .simulator-title { top: 45px; width: min(90vw, 340px); }
    .simulator-title h1 { gap: 7px; font-size: clamp(20px, 6.3vw, 27px); }
    .simulator-title h1 span { font-size: 12px; }
    html[lang="th"] .simulator-title h1 .title-text { font-size: clamp(15px, 4.8vw, 20px); }
    html[lang="th"] .simulator-title.swap-title { width: min(90vw, 340px); }
    html[lang="th"] .simulator-title.swap-title h1 { white-space: normal; }
    .language { right: 1px; top: 3px; width: 24px; }

    .main-nav {
        top: 92px;
        width: 100%;
        gap: 3px;
    }
    html[lang="th"] .site-header.swap-view .main-nav { top: 92px; }
    .nav-button, .nav-button.website, .nav-button.battle {
        width: 23%;
        height: clamp(22px, 6.8vw, 30px);
        aspect-ratio: auto;
    }
    .nav-button.website { width: 25%; }
    .nav-button.battle { width: 29%; }
    .nav-button span { font-size: clamp(8px, 2.7vw, 12px); }

    .book {
        width: min(95%, 430px);
        min-height: 0;
        aspect-ratio: auto;
        margin: 0 auto;
        display: block;
        transform: none;
        background: none;
    }
    .book-page {
        width: 100%;
        aspect-ratio: 1028 / 1826;
        padding: 30px 47px 68px;
        background: url("../images/bookmobile.png") center / 100% 100% no-repeat;
        font-size: clamp(7px, 2.2vw, 10px);
    }
    .input-page { transform: none; }
    .book-page + .book-page { margin-top: 16px; }

    .page-heading { height: 23px; font-size: clamp(10px, 3vw, 13px); }
    .page-heading img { width: 18px; }
    .heading-underline { width: 110px; margin-top: 1px; }
    fieldset legend {
        margin-inline: auto;
        padding: 2px 7px;
        font-size: clamp(7px, 2vw, 9px);
    }
    input, select { height: 18px; padding: 1px 4px; font-size: clamp(6px, 1.8vw, 8px); }

    .pet-intro { height: 195px; margin-top: 4px; display: block; position: relative; }
    .pet-information { width: 100%; height: 120px; padding: 5px 7px; position: absolute; bottom: 0; }
    .pet-information label + label { margin-top: 0; }
    .pet-information label { height: 22px; grid-template-columns: 43% 1fr; }
    .pet-portrait {
        width: 78px;
        height: 78px;
        position: absolute;
        left: 50%;
        top: -4px;
        z-index: 1;
        transform: translateX(-50%);
        border: 1px solid var(--paper-line);
        border-radius: 50%;
        background: rgba(255, 248, 226, .5);
        pointer-events: none;
    }
    .pet-portrait img { max-width: 70px; max-height: 60px; }

    .stat-editor { height: 122px; margin-top: 7px; margin-right: 0; padding: 7px 6px; row-gap: 0; }
    .stat-editor label { grid-template-columns: 39% 22% 1fr; gap: 4px; }
    .stat-icon {
        width: 13px;
        height: 13px;
        margin-right: 3px;
        flex-basis: 13px;
    }
    .pet-information input,
    .pet-information select,
    .bonus-points input,
    .stat-editor input:last-child,
    .result-grid input { font-size: clamp(6px, 1.8vw, 8px); }

    .bonus-points {
        height: 140px;
        margin-top: 7px;
        margin-right: 0;
        padding: 7px 6px;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
        grid-auto-flow: row;
        gap: 0;
    }
    .bonus-points label { grid-template-columns: 43% 1fr; }

    .action-button {
        bottom: 40px;
        width: 86px;
        height: 31px;
        font-size: 15px;
    }
    .simulate-button { left: 50%; }

    .result-page { padding-top: 45px; }
    .result-section > h2 {
        min-width: 83px;
        height: 24px;
        margin: 0 auto 12px;
        font-size: 12px;
        line-height: 20px;
    }
    .result-grid { padding: 8px 7px; grid-template-columns: 1fr; grid-auto-flow: row; gap: 0; }
    .result-grid label { grid-template-columns: 44% 1fr; }
    .five-stats { height: 126px; grid-template-rows: repeat(5, 1fr); }
    .status-section { margin-top: 25px; }
    .status-grid { height: 181px; grid-template-rows: repeat(8, 1fr); }
    .status-grid label { grid-template-columns: 44% 1fr; }
    .instruction { margin: 20px 3px 0; font-size: clamp(8px, 2.2vw, 10px); line-height: 1.5; }

    .swap-input-page .page-heading { justify-content: center; padding-left: 0; }
    .swap-input-page .heading-underline { margin-left: auto; }
    .swap-score-panel {
        min-height: 190px;
        margin-top: 35px;
        padding: 16px 12px;
        row-gap: 20px;
    }
    .swap-score-panel input { height: 25px; }
    .swap-result-page { padding-top: 48px; }
    .swap-rate-section > h2 {
        min-width: 105px;
        min-height: 30px;
        margin-bottom: 18px;
        padding: 4px 10px;
        font-size: 13px;
    }
    .swap-rate-grid {
        min-height: 300px;
        padding: 14px 10px;
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, 1fr);
        grid-auto-flow: row;
        gap: 8px;
    }
    .swap-rate-grid label { font-size: clamp(8px, 2.2vw, 10px); }
    .swap-rate-grid input { height: 24px; font-size: clamp(6px, 1.8vw, 8px); }
    .swap-note { margin-top: 20px; font-size: clamp(8px, 2.2vw, 10px); line-height: 1.5; }
    .swap-query-button { left: 50%; }

    .battle-book {
        width: min(95%, 430px);
        min-height: 0;
        aspect-ratio: 1036 / 1929;
        margin: 0 auto;
        background-image: url("../images/mobile_2.png");
        transform: none;
    }
    .battle-book.is-advanced {
        min-height: min(264vw, 1135px);
        aspect-ratio: auto;
        background-image: url("../images/mobile_2.png");
    }
    .battle-book.is-advanced .battle-content { min-height: 100%; }
    .battle-content {
        width: 100%;
        height: 100%;
        padding: 40px 42px 52px;
    }
    .battle-selectors {
        width: 52%;
        margin: 0 auto;
        padding: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
    }
    .battle-selectors select { height: 22px; font-size: clamp(7px, 2.4vw, 10px); }
    .battle-state-title {
        width: 120px;
        min-width: 0;
        height: 27px;
        margin-top: 7px;
        padding: 1px 10px;
        font-size: 13px;
        line-height: 20px;
    }
    .battle-state { margin-top: 10px; }
    .battle-side-grid { grid-template-columns: 1fr; gap: 10px; }
    .battle-panel { padding: 7px 8px 8px; border-radius: 7px; }
    .battle-panel legend { top: -29px; padding: 0; font-size: 13px; }
    .battle-panel legend::before,
    .battle-panel legend::after { width: 32px; height: 23px; }
    .battle-role-icon { width: 15px; height: 15px; margin: 0 3px -3px 0; }
    .battle-panel label {
        min-height: 19px;
        grid-template-columns: 38% minmax(0, 1fr);
        gap: 4px;
        font-size: clamp(7px, 2.25vw, 9px);
    }
    .battle-panel input,
    .battle-panel select { height: 16px; padding: 0 3px; font-size: clamp(6px, 1.9vw, 8px); }
    .battle-value { grid-template-columns: minmax(0, 1fr) 12px; }
    .battle-elements { gap: 2px; }
    .battle-advanced-toggle {
        width: 128px;
        height: 26px;
        margin-top: 9px;
        font-size: 14px;
    }
    .battle-hint { margin: 3px 0 7px; font-size: clamp(7px, 2.25vw, 9px); }
    .battle-advanced-state .battle-panel { min-height: 0; padding-top: 9px; }
    .battle-advanced-state .battle-side-grid { gap: 7px; }
    .battle-book.is-advanced .battle-result-row { margin-top: 16px; }
    .battle-result-row {
        padding: 0 24px 3px;
        grid-template-columns: 1fr;
        gap: 5px;
        justify-items: center;
    }
    .battle-result-row h2 { font-size: 14px; }
    .battle-result-panel {
        width: 100%;
        padding: 5px 6px;
        gap: 5px;
        font-size: clamp(6px, 1.8vw, 8px);
    }
    .battle-result-panel input { height: 17px; font-size: clamp(5px, 1.6vw, 7px); }
    .battle-result-icon { width: 13px; height: 13px; }
    .battle-simulate { width: 105px; height: 29px; font-size: 15px; }

    .download-bar {
        height: 102px;
        margin-top: 0;
        padding: 5px 7px 13px;
        display: grid;
        grid-template-columns: 34px repeat(3, 1fr);
        grid-template-rows: 32px 48px;
        gap: 4px;
    }
    .download-bar a, .download-bar .app-icon { width: auto; }
    .download-bar .top-up { grid-column: 1 / -1; width: 184px; justify-self: center; }
}

@media (min-width: 901px) and (max-width: 1000px) {
    .page-shell { transform-origin: top center; }
    .brand { width: 17vw; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; }
}
