html,
/* ========= Layout ========= */

body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #020713;
    font-family: Arial, sans-serif;
    color: #c9c49a;
}

body {
    background: radial-gradient(circle at center, rgba(25, 60, 75, 0.25), rgba(0, 0, 0, 0.95)), #020713;
}

#app {
    box-sizing: border-box;
    width: 100vw;
    height: 100dvh;
    padding: 22px;
    display: flex;
    gap: 22px;
}

#leftColumn {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 22px;
    min-width: 0;
}

#rightColumn {
    width: min(420px, 36vw);
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
}

/* ========= Panels ========= */

.panel {
    box-sizing: border-box;
    position: relative;
    overflow: auto;
    background: linear-gradient(rgba(28, 54, 55, 0.82), rgba(18, 35, 34, 0.82)), #172b2b;
    border: 2px solid rgba(190, 190, 165, 0.55);
    border-radius: 8px;
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.65), 0 0 8px rgba(0, 0, 0, 0.75);
}

.main-text-panel {
    flex: 0 0 58%;
    padding: 34px 36px;
    font-size: 16px;
    line-height: 1.32;
    font-weight: 400;
    white-space: pre-wrap;
}

.choices-panel {
    flex: 1;
    padding: 24px 34px;
}

.picture-panel {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    flex: 0 0 auto;
}

.picture-panel img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.65s ease-in-out;
}

.picture-panel img.visible {
    opacity: 1;
}

.params-panel {
    flex: 1;
    min-height: 140px;
    overflow: auto;
    padding: 24px 20px;
    font-size: 15px;
    line-height: 1.45;
    background: linear-gradient(rgba(10, 22, 14, 0.92), rgba(8, 18, 12, 0.92)), #08120d;
}

/* ========= Buttons ========= */

button {
    display: block;
    width: 100%;
    min-height: 34px;
    margin: 0 0 8px 0;
    padding: 4px 14px;
    background: transparent;
    border: none;
    color: #c9c49a;
    text-align: left;
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
}

button::before {
    content: "▣";
    color: #ffb11b;
    margin-right: 12px;
    font-size: 13px;
}

button:hover {
    background: transparent;
}

body.play-mode button:hover {
    background: rgba(0, 0, 0, 0.35);
}

button.selected {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
}

button:disabled {
    color: rgba(201, 196, 154, 0.45);
    cursor: default;
}

button:disabled::before {
    opacity: 0.55;
}

button:disabled:hover {
    background: transparent;
}

.param {
    margin: 0 0 5px 0;
    color: #c9c49a;
    font-weight: 400;
}

body.menu-mode .main-text-panel {
    font-size: 15px;
}

body.menu-mode .params-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
}

.start-button {
    width: 60%;
    min-height: 34px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid rgba(201, 196, 154, 0.6);
    border-radius: 6px;
    text-align: center;
    font-size: clamp(14px, 1.6vw, 18px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.mobile-layout .start-button {
    width: 80%;
}

.start-button::before {
    content: "";
    margin: 0;
}

.panel::-webkit-scrollbar {
    width: 10px;
}

.panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
}

.panel::-webkit-scrollbar-thumb {
    background: rgba(201, 196, 154, 0.45);
    border-radius: 8px;
}

.panel::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 196, 154, 0.65);
}

body.keyboard-mode.play-mode button:hover {
    background: transparent;
}

body.play-mode.keyboard-mode #choices button:not(.selected):hover {
    background: transparent !important;
}

body.play-mode #choices button.selected,
body.play-mode #choices button.selected:hover,
body.play-mode.keyboard-mode #choices button.selected,
body.play-mode.keyboard-mode #choices button.selected:hover {
    background: rgba(0, 0, 0, 0.35) !important;
    border-radius: 8px;
}

/* ========= Quest List ========= */

#choices button {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto auto;
    align-items: center;
    column-gap: 12px;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}

.quest-name,
.quest-author,
.quest-lang {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#choices button::before {
    content: "";
    width: 14px;
    height: 14px;
    margin: 0;
    background-image: url("_Icons/question_mark.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.quest-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quest-author {
    opacity: 0.7;
    white-space: nowrap;
    font-size: 14px;
}

.quest-lang {
    opacity: 0.75;
    white-space: nowrap;
}

/* ========= Source Selector ========= */

.source-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 16px;
}

.source-row button {
    display: flex;
    align-items: center;
    width: auto;
    margin: 0;
    padding: 4px 6px;
    border: none;
    font-size: 16px;
    text-align: left;
}

.source-row button::before {
    content: "";
    display: inline-block;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    margin-right: 8px;
    vertical-align: -4px;
    border: 1px solid rgba(201, 196, 154, 0.8);
}

.source-row button.selected-source::before {
    content: "\2713";
    line-height: 20px;
    text-align: center;
    color: #c9c49a;
}

.source-row button:disabled {
    opacity: 1;
    color: #c9c49a;
}

.source-row button:disabled::before {
    opacity: 1;
}

/* ========= Desktop Responsive ========= */

@media (max-width: 1100px) {
    #app {
        padding: 12px;
        gap: 12px;
    }

    #leftColumn {
        gap: 12px;
    }

    #rightColumn {
        width: 320px;
        min-width: 320px;
        gap: 12px;
    }

    .main-text-panel {
        padding: 24px 26px;
        font-size: 14px;
    }

    body.menu-mode .main-text-panel {
        font-size: 13px;
    }

    .choices-panel {
        padding: 18px 24px;
    }

    .params-panel {
        padding: 18px 16px;
        font-size: 14px;
    }

    button {
        font-size: 15px;
        padding: 4px 10px;
    }

    .source-row {
        gap: 8px;
        font-size: 17px;
    }

    .source-row button {
        font-size: 17px;
    }
}

/* ========= Mobile Layout ========= */

body.mobile-layout {
    overflow: hidden;
}

body.mobile-layout #app {
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 55fr 45fr;
    grid-template-rows: calc((100vw - 30px) * 0.55) minmax(0, 55fr) minmax(0, 45fr);
    width: 100vw;
    height: 100dvh;
    padding: 10px;
    gap: 10px;
}

body.mobile-layout #leftColumn,
body.mobile-layout #rightColumn {
    display: contents;
}

body.mobile-layout .picture-panel {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
}

body.mobile-layout .params-panel {
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
    font-size: clamp(9px, 2.7vw, 12px);
    line-height: 1.18;
}

.param {
    margin-bottom: 7px;
    padding: 5px 8px;
    border-radius: 6px;
    background: linear-gradient(to right, rgba(45, 77, 84, 0.215), rgba(20, 35, 39, 0.105));
}

body.mobile-layout .main-text-panel {
    grid-column: 1 / 3;
    grid-row: 2;
    min-height: 0;
    overflow: auto;
    padding: 18px;
    font-size: 14px;
    line-height: 1.42;
}

body.mobile-layout .choices-panel {
    grid-column: 1 / 3;
    grid-row: 3;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px;
}

body.mobile-layout .source-row {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    font-size: 13px;
}

body.mobile-layout .source-row button {
    width: 100%;
    min-height: 26px;
    height: 26px;
    padding: 2px 4px;
    font-size: 13px;
}

body.mobile-layout .source-row button::before {
    width: 16px;
    height: 16px;
    margin-right: 6px;
}

body.mobile-layout .source-row button.selected-source::before {
    line-height: 14px;
    font-size: 12px;
}

body.mobile-layout #choices button {
    min-height: 34px;
    height: auto;
    padding: 4px 10px;
    margin-bottom: 8px;
    column-gap: 8px;
    white-space: normal;
    overflow: visible;
    align-items: start;
}

body.mobile-layout #choices .quest-name {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

body.mobile-layout #choices button,
body.mobile-layout .quest-button {
    background: linear-gradient(to right, rgba(14, 30, 34, 0.52), rgba(16, 36, 42, 0.30));
    border-radius: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
}

/* ========= Start Quest Blocker ========= */

.start-quest-blocker {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.start-quest-blocker.hidden {
    display: none;
}

.start-quest-blocker-panel {
    box-sizing: border-box;
    min-width: 320px;
    padding: 26px 30px;
    border: 2px solid rgba(190, 190, 165, 0.75);
    border-radius: 8px;
    background: linear-gradient(rgba(28, 54, 55, 0.95), rgba(18, 35, 34, 0.95)), #172b2b;
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 0, 0, 0.85);
    color: #c9c49a;
    text-align: center;
}

.start-quest-blocker-title {
    margin-bottom: 20px;
    font-size: 22px;
}

.start-quest-cancel-button {
    display: block;
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    margin: 0 auto;
    padding: 8px 18px;
    border: 1px solid rgba(201, 196, 154, 0.6);
    background: transparent;
    color: #c9c49a;
    text-align: center;
    font-size: 20px;
}

.start-quest-cancel-button::before {
    content: "";
    margin: 0;
}

body.mobile-layout button.selected,
body.mobile-layout button.selected:hover,
body.mobile-layout #choices button.selected,
body.mobile-layout #choices button.selected:hover {
    background: linear-gradient(to right, rgba(14, 30, 34, 0.52), rgba(16, 36, 42, 0.30)) !important;
}

button,
#choices button,
.quest-button {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    outline: none;
}

button:focus,
button:active {
    outline: none;
}

body.mobile-layout.menu-mode #choices button::before {
    content: "";
    width: 18px;
    height: 18px;
    background: none;
}

body.mobile-layout.menu-mode #choices button.selected::before {
    background-image: url("_Icons/question_mark.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.rich-size {
    line-height: 1.1;
    white-space: pre-wrap;
    font-family: inherit;
}

body.layout-pending #app {
    visibility: hidden;
}

/* ========= Settings ========= */

.settings-button {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9000;
    width: 26px;
    height: 26px;
    padding: 0;
    margin: 0;
    border: none;
    outline: none;
    box-shadow: none;
    background: transparent url("_Icons/settings.png") center / contain no-repeat !important;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.settings-button::before {
    content: none;
}

.settings-button:hover,
body.play-mode .settings-button:hover,
body.menu-mode .settings-button:hover {
    background: transparent url("_Icons/settings.png") center / contain no-repeat !important;
    opacity: 1;
    transform: scale(1.06);
}

.settings-button:focus,
.settings-button:active {
    border: none;
    outline: none;
    background: transparent url("_Icons/settings.png") center / contain no-repeat !important;
}

body.mobile-layout .settings-button {
    right: 7px;
    bottom: 4px;
    width: 24px;
    height: 24px;
}

.settings-panel {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
}

.settings-panel.hidden {
    display: none;
}

.settings-window {
    box-sizing: border-box;
    width: min(420px, calc(100vw - 32px));
    padding: 26px 30px;
    border: 2px solid rgba(190, 190, 165, 0.75);
    border-radius: 8px;
    background: linear-gradient(rgba(28, 54, 55, 0.95), rgba(18, 35, 34, 0.95)), #172b2b;
    box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 0, 0, 0.85);
    color: #c9c49a;
    text-align: center;
}

.settings-title {
    margin-bottom: 22px;
    font-size: 22px;
}

.settings-close-button {
    width: 100px;
    margin: 0 auto;
    padding: 8px 18px;
    border: 1px solid rgba(201, 196, 154, 0.6);
    background: transparent;
    color: #c9c49a;
    text-align: center;
    font-size: 18px;
    margin-top: 24px;
    border-radius: 6px;
}

.settings-close-button::before {
    content: "";
    margin: 0;
}

.settings-section {
    margin-bottom: 34px;
}

.settings-section-title {
    margin-bottom: 14px;
    font-size: 18px;
    text-align: left;
    opacity: 0.9;
}

.settings-action-button {
    display: block;
    width: 50%;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(201, 196, 154, 0.4);
    border-radius: 6px;
    background: linear-gradient(rgba(24, 48, 49, 0.72), rgba(16, 32, 31, 0.72));
    color: #c9c49a;
    text-align: center;
    font-size: 16px;
}

.settings-action-button::before {
    content: none;
}

.settings-action-button:hover {
    background: linear-gradient(rgba(32, 58, 60, 0.82), rgba(18, 36, 35, 0.82));
}

.hidden {
    display: none !important;
}

#installAppButton {
    margin-top: 24px;
}

#abandonQuestButton {
    margin-top: 24px;
}

/* ========= Settings About ========= */

.settings-link {
    display: inline-block;
    margin-bottom: 18px;
    color: #c9c49a;
    text-decoration: none;
    opacity: 0.88;
}

.settings-link:hover {
    opacity: 1;
    text-decoration: underline;
}

#aboutButton {
    margin-top: 24px;
}

#createQuestsButton {
    width: 70%;
    margin-bottom: 24px;
}

.settings-version {
    margin-bottom: 24px;
}