/*
 * In-game settings menu + error modal styling.
 * The DOM is built and driven by src/menu/GameMenuModule.ts and src/errors/ErrorModalModule.ts.
 */

/* width */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #888;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/*SLIDER CSS*/
.slider {
    -webkit-appearance: none;
    width: 50%;
    height: 25px;
    background: black;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 50px;
    height: 25px;
    background: white;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 50px;
    height: 25px;
    background: white;
    cursor: pointer;
}

/*SETTING UI CSS*/

#close-settings-ui-button {
    width: 40px;
    height: 40px;
    position: absolute;
    right: 10px;
    top: 10px;
    cursor: pointer;
}

#settings-ui-container {
    width: 100%;
    height: 100%;
    background: #222222;
    position: absolute;
    display: flex;
    flex-direction: row;
    top: 0;
    left: 0;
    z-index: 50;
    font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
    color: rgba(255, 255, 255, 0.87);
}

#settings-ui-navbar {
    box-sizing: border-box;
    height: 100%;
    width: 25%;
    background: #111111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    overflow: auto;
}

#settings-ui-navbar-info {
    width: 100%;
    padding: 12px 10%;
    text-align: center;
    font-weight: 700;
    font-size: 18px;
    text-transform: uppercase;
    box-sizing: border-box;
}

#settings-ui-navbar-info #settings-navbar-game-name {
    margin: 0 0 6px;
}

#settings-navbar-balance {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

#settings-navbar-balance-value {
    color: #FFCB30;
}

#settings-ui-navbar-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-items: center;
    align-items: center;
    row-gap: 20px;
    width: 100%;
    max-height: 100%;
    padding: 0 5%;
}

#settings-ui-navbar-wrapper p {
    text-transform: uppercase;
}

#settings-ui-navbar #settings-ui-navbar-wrapper div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 50%;
    height: 25%;
    text-align: center;
}

#settings-ui-navbar #settings-ui-navbar-wrapper div:hover {
    cursor: pointer;
    color: #FFCB30;
}

#settings-ui-navbar #settings-ui-navbar-wrapper div svg {
    height: 100%;
    width: 60%;
    min-height: 60%;
    min-width: 60%;
}

#settings-ui-navbar #settings-ui-navbar-wrapper div svg path {
    fill: white;
}

#settings-ui-navbar #settings-ui-navbar-wrapper div:hover svg path {
    fill: #FFCB30 !important;
}

#settings-ui-content {
    height: 100%;
    width: 75%;
    background: #222222;
    padding: 2%;
    padding-right: 45px;
    overflow-y: auto;
    position: relative;
}

.small_title {
    text-align: center;
    color: #FFCB30;
    text-transform: uppercase;
}

#settings-ui-content .title {
    width: 100%;
    text-align: center;
    font-size: 32px;
    color: #FFCB30;
    text-transform: uppercase;
}

.bottom-border {
    padding-bottom: 20px;
}

.bottom-border:after {
    content: "";
    display: block;
    margin-top: 10px;
    width: 100%;
    height: 4px;
    background: #1407f2;
    background: linear-gradient(90deg, transparent 0, #fff 50%, transparent 100%);
    border-radius: 50%;
}

#settings-ui-content .text-section {
    padding-top: 2%;
    font-size: 24px;
    line-height: 1.3;
}

#settings-ui-content .text-section .text-section-title {
    font-size: 33px;
    color: #FFCB30;
    text-transform: capitalize;
}

#table {
    width: 100%;
    border-collapse: collapse;
}

#table td, #table th {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;
    text-transform: capitalize;
}

#table td:first-child img {
    width: 50%;
}

#table tr td:first-child {
    display: table-cell;
    text-align: center;
}

.sounds-options-container {
    display: flex;
    align-items: center;
    padding-top: 20px;
    justify-content: space-around;
    padding-bottom: 40px;
    height: 30%;
    flex-wrap: wrap;
}

.sound-option-checkbox {
    height: 100%;
    fill: #FFCB30;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-transform: uppercase;
}

.sound-option-checkbox svg {
    width: 81px;
    height: 81px;
}

.sound-option-checkbox svg:hover path {
    fill: #FFCB30;
}

#settings-ui-content-settings {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.settings-ui-content-settings-wrapper {
    width: 100%;
}

#settings-ui-content-reality-check {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.settings-ui-content-reality-check-value-container {
    width: 33%;
    display: flex;
    flex-direction: column;
}

.settings-ui-content-reality-check-text {
    display: flex;
    justify-content: space-between;
}

.settings-ui-content-reality-check-wrapper {
    width: 100%;
}

.reality-check-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 800px;
    min-width: 260px;
    background-color: #000;
    border-radius: 4px;
    color: #fff;
    padding-top: 30px;
    padding-bottom: 30px;
    text-align: center;
    z-index: 120;
    font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
}

.reality-check-modal-btn {
    display: inline-block;
    border-radius: 4px;
    margin: 30px 15px 0;
    line-height: 22px;
    font-size: 18px;
    min-width: 80px;
    letter-spacing: 1.4px;
    padding: 6px 16px;
    transition: .2s all linear;
    cursor: pointer;
    text-transform: uppercase;
    border: 1px solid #fff;
}

.reality-check-modal-btn:hover {
    background: #fff;
    color: #000;
}

.reality-check-modal p {
    width: 100%;
    font-size: 20px;
    line-height: 24px;
    letter-spacing: 1.5px;
    padding: 28px 28px 0;
}

/* Question-mark bubble on top of error/reality modals */
.modal-question-mark {
    position: absolute;
    top: -30px;
    left: 50%;
    width: 60px;
    height: 60px;
    transform: translate(-50%, 0);
    background-color: #000;
    border-radius: 50%;
    border: 2px solid #fff;
}

.modal-question-mark img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    transform: translate(-50%, -50%);
}

.reality-check-range-input-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

/* Full-screen terminal overlay (exit / fatal) */
#terminal-overlay {
    position: fixed;
    inset: 0;
    background: #111;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
    color: #fff;
    font-size: clamp(20px, 3.5vw, 34px);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6%;
}

/* Paytable */
.payTableScatterContainer {
    background-color: rgba(0, 0, 0, .3);
    border-radius: 5%;
    padding: 2%;
    line-height: 1.5;
    text-align: center;
    font-size: 1.5em;
    width: 40%;
    word-break: break-all;
    height: 100%;
    word-wrap: break-word;
}

.payTableScatterContainer div span:first-child {
    color: #ffcb30;
}

.paytableInfoMainContainer {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
}

/* A symbol left alone on the last row goes to the middle column instead of hugging the
   left edge. Wilder Icy Fruits has 10 paytable entries in a 3-wide grid, so the tenth
   always lands alone; the selector only fires when the last item starts a row, so a
   game with a full last row is unaffected. */
.paytableInfoMainContainer > .payTableImageAndDataContainer:last-child:nth-child(3n + 1) {
    grid-column: 2;
}

.paytableInfoMainContainer img {
    width: 40%;
}

.payTableImageAndDataContainer {
    padding: 2%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100%;
}

.payTableDataContainer {
    background-color: rgba(0, 0, 0, .3);
    border-radius: 5%;
    margin-top: 10%;
    padding: 5% 10%;
    line-height: 1.5;
    font-size: 1.5em;
    width: 100%;
    text-align: center;
    word-break: break-all;
    height: 100%;
    word-wrap: break-word;
}

.payTableDataContainer div span:first-child {
    color: #ffcb30;
    word-break: break-all;
    display: block;
}

.payTableDataContainer div span:last-child {
    display: block;
    white-space: nowrap;
}

/* Paylines (LINES section at the bottom of the paytable) */
#paylines-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 26px 34px;
    padding: 10px 0 30px;
}

.payline-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.payline-grid {
    display: grid;
    gap: 3px;
    background: #000;
    border: 3px solid #000;
    border-radius: 4px;
}

.payline-cell {
    width: clamp(14px, 2.2vw, 24px);
    height: clamp(14px, 2.2vw, 24px);
    background: #fff;
    border-radius: 2px;
}

.payline-cell.is-on {
    background: #6fd9ff;
}

.payline-number {
    color: #6fd9ff;
    font-weight: 700;
    font-size: 20px;
}

/* History */
#settings-ui-content-history {
    display: flex;
    justify-items: center;
    align-items: center;
    flex-direction: column;
}

.historyLineContainer {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
}

.historyLineContainer div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.historyLineContainer div:last-child {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#history-win-lines {
    width: 100%;
}

.history-win-line-info {
    display: flex;
    align-items: flex-end;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
    width: 100%;
    gap: 20px;
    text-transform: uppercase;
}

.history-win-line-info img {
    height: 50px;
    width: 50px;
    object-fit: contain;
}

#history-prev-button {
    width: 0;
    height: 0;
    border-top: 28px solid transparent;
    border-bottom: 28px solid transparent;
    border-right: 44px solid #fff;
    cursor: pointer;
    user-select: none;
}

#history-prev-button:hover {
    border-right-color: #FFCB30;
}

#history-next-button {
    width: 0;
    height: 0;
    border-top: 28px solid transparent;
    border-bottom: 28px solid transparent;
    border-left: 44px solid #fff;
    cursor: pointer;
    user-select: none;
}

#history-next-button:hover {
    border-left-color: #FFCB30;
}

/* Settled result board (5 reels x 3 rows), flanked by the nav arrows */
#history-symbols-grid {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
    grid-template-columns: repeat(5, 1fr);
    background-image: url('assets/games/wilderIcyFruits/board.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
    flex: 1;
    min-width: 0;
    padding: 4% 5%;
    gap: 8px;
}

#history-symbols-grid img {
    width: 100%;
    height: 100%;
    max-width: 200px;
    max-height: 120px;
    object-fit: contain;
}

.history-symbol-dim {
    opacity: 0.32;
}

.history-symbol-win {
    opacity: 1;
    filter: drop-shadow(0 0 6px #FFCB30) drop-shadow(0 0 11px rgba(255, 203, 48, 0.6));
}

#history-game-board {
    width: 80%;
    position: relative;
    margin: 0 auto 28px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    max-width: 800px;
    gap: 10px;
}

/* Win-line paths drawn over the history boards (spans the whole cell grid) */
.history-line-overlay {
    grid-row: 1 / -1;
    grid-column: 1 / -1;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Per-win-line breakdown below the round details */
.history-lines-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 22px 26px;
    width: 100%;
    padding-top: 10px;
}

.history-line-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.history-line-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #FFCB30;
    padding: 0 4px;
}

.history-line-amount {
    color: #fff;
}

.history-line-grid {
    display: grid;
    background-image: url('assets/games/wilderIcyFruits/board.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;
    background-position: center;
    padding: 3% 4%;
    gap: 5px;
}

.history-line-grid img {
    width: 100%;
    height: 100%;
    max-width: 110px;
    max-height: 80px;
    object-fit: contain;
}

/* Loading spinner shown while a history page is fetched */
#history-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    pointer-events: none;
    z-index: 5;
}

#history-loading.is-active {
    display: flex;
}

#history-loading::after {
    content: "";
    box-sizing: border-box;
    width: clamp(28px, 7vw, 48px);
    height: clamp(28px, 7vw, 48px);
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #FFCB30;
    border-radius: 50%;
    animation: history-spin 0.8s linear infinite;
}

@keyframes history-spin {
    to { transform: rotate(360deg); }
}

/* Help table: buttons with a text overlay (e.g. the black-circle GAMBLE button) */
.image-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
    container-type: inline-size;
}

.overlay-text {
    position: absolute;
    top: 0;
    left: 25%;
    width: 50%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 8%;
    box-sizing: border-box;
    pointer-events: none;
    color: white;
    font-weight: bold;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    font-size: 10cqw;
}

@media screen and (max-width: 600px) {
    .history-win-line-info img {
        height: 36px;
        width: 36px;
    }

    #history-prev-button {
        border-top: 18px solid transparent;
        border-bottom: 18px solid transparent;
        border-right: 34px solid #fff;
    }

    #history-next-button {
        border-top: 18px solid transparent;
        border-bottom: 18px solid transparent;
        border-left: 34px solid #fff;
    }
}

@media screen and (max-width: 760px) {
    #history-game-board {
        width: 100%;
        position: relative;
        margin: 0 auto 24px;
    }

    #settings-ui-content .text-section {
        font-size: 12px;
        line-height: 1.3;
    }

    #settings-ui-content .text-section .text-section-title {
        font-size: 19px;
    }

    #settings-ui-content .title {
        font-size: 21.6px;
    }

    /* Below the navbar, top-right of the content pane; sticky so it stays there
       (and stays clickable) while the pane scrolls. */
    #close-settings-ui-button {
        position: sticky;
        top: 6px;
        display: block;
        margin: 0 2px 6px auto;
        width: 34px;
        height: 34px;
        z-index: 70;
    }

    #settings-ui-navbar-wrapper {
        padding-right: 0;
    }

    /* Keep the last nav icon clear of the pinned close button. */
    #settings-ui-navbar-wrapper {
        padding-right: 58px;
        box-sizing: border-box;
    }

    #settings-ui-container {
        flex-direction: column;
    }

    #settings-ui-navbar {
        width: 100%;
        height: auto;
        padding: 3% 0;
        overflow: hidden;
    }

    #settings-ui-navbar-wrapper {
        width: 100%;
        height: 100%;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: center;
    }

    #settings-ui-navbar #settings-ui-navbar-wrapper div {
        width: 14%;
        height: auto;
    }

    #settings-ui-navbar-wrapper p {
        display: none;
    }

    #settings-ui-navbar-info {
        order: 1;
        font-size: 14px;
        padding: 6px 5%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 12px;
    }

    #settings-ui-navbar-info #settings-navbar-game-name {
        margin: 0;
    }

    #settings-ui-content {
        width: 100%;
        padding-right: 2%;
    }
}

@media screen and (max-height: 500px) {
    /* Top-right of the content pane, sticky against scrolling (as on portrait). */
    #close-settings-ui-button {
        position: sticky;
        top: 4px;
        display: block;
        margin: 0 2px 4px auto;
        width: 30px;
        height: 30px;
        z-index: 70;
    }

    #settings-ui-navbar {
        overflow: visible;
    }

    #settings-ui-navbar-info {
        font-size: 11px;
        padding: 2px 5%;
    }

    #settings-ui-content-settings,
    #settings-ui-content-reality-check {
        height: auto;
        min-height: 100%;
        justify-content: flex-start;
    }

    .sounds-options-container {
        padding-top: 10px;
        padding-bottom: 10px;
        height: auto;
    }

    .sound-option-checkbox {
        height: auto;
    }

    .sound-option-checkbox svg {
        width: 60px;
        height: 60px;
    }
}

/* Gamble session breakdown in history (replaces per-line blocks for gambled rounds) */
.history-gamble-block {
    max-width: 460px;
    margin: 10px auto 30px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-gamble-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px 14px;
}

.history-gamble-no {
    opacity: 0.7;
    min-width: 22px;
}

.history-gamble-chip {
    text-transform: uppercase;
    font-weight: 700;
    padding: 2px 12px;
    border-radius: 4px;
}

.history-gamble-chip.red {
    background: #a11212;
    color: #fff;
}

.history-gamble-chip.black {
    background: #111;
    color: #fff;
    border: 1px solid #555;
}

.history-gamble-result {
    font-weight: 700;
    text-transform: uppercase;
}

.history-gamble-result.won { color: #3ddc5a; }
.history-gamble-result.lost { color: #ff5252; }

.history-gamble-amount {
    margin-left: auto;
    font-weight: 700;
}

.history-gamble-base { opacity: 0.85; text-transform: uppercase; }

.history-gamble-final {
    border-color: #FFCB30;
    text-transform: uppercase;
    font-weight: 700;
}

.history-gamble-final.won { color: #3ddc5a; }
.history-gamble-final.lost { color: #ff5252; }

/* Playing card shown for a gamble transaction in history */
.history-playing-card {
    background: #fff;
    border-radius: 14px;
    width: min(180px, 40%);
    aspect-ratio: 2 / 3;
    margin: 12px auto;
    position: relative;
    color: #111;
    font-family: "Roboto Condensed", "Arial Narrow", sans-serif;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
    justify-self: center;
    align-self: center;
}

.history-playing-card.red { color: #c0182b; }

.history-playing-card .corner {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 34px;
    font-weight: 700;
    line-height: 0.9;
}

.history-playing-card .corner em { font-style: normal; font-size: 26px; }
.history-playing-card .corner.top { top: 10px; left: 12px; }
.history-playing-card .corner.bottom { bottom: 10px; right: 12px; transform: rotate(180deg); }

.history-playing-card .pip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 64px;
}

/* Gamble transaction: the grid holds only the card - no board frame behind it */
#history-symbols-grid.history-grid-gamble {
    background-image: none;
    padding: 0;
}

/* Weight distribution matching the gates-of-olympia menu: page/section titles are
   REGULAR weight; bold is reserved for nav labels, checkbox titles, values and buttons. */
#settings-ui-content .title,
#settings-ui-content .text-section-title,
.small_title {
    font-weight: 400;
}

.sound-option-checkbox,
.reality-check-modal-btn,
#settings-navbar-balance-value,
.history-line-amount {
    font-weight: 700;
}

#settings-ui-content .text-section {
    font-weight: 400;
}
