:root {
    --font-color-main: #F5F5F5;
    --font-color-muted: #AEAEAE;
    --green-main: #27B16A;
    --green-main-hover: #3AD384;
    --font-color-win: #00CF15;
    --font-color-win-muted: #1C8827;
    --font-color-win-dark: #00301B;
    --font-color-lose: #FF0000;
    --font-color-lose-muted: #88040E;
    --font-color-lose-dark: #380618;
    --background-dark: #06071E;
    --background-light: #10132D;
    --background-accent: #133F65;
    --button-background-main: #133F65;
    --button-background-light: #235F92;
    --border-muted-dark: #323964;
    --border-muted: #545F9C;
    --slider-color-under: #FF0000;
    --slider-color-over: #00CF15;
    --blur-backdrop-dark: rgb(6 7 30 / 80%);
    --background-page: #020113;
    --border-divider: #262D55;
    --hover-light-1: #AEB8EE;
    --thumb-gradient-top: #094399;
    --thumb-gradient-bottom: #3385FF;
    --thumb-glow: #0F6FFF;
    --menu-gradient-end: #191E47;
    --menu-border: #232C5F;
    --toggle-gradient-dark: #0E2D47;
    --toggle-gradient-light: #3C8BCF;
    --font-color-inactive: #7290AB;
    --play-green: #32E287;
    --play-gradient-bottom: #013D23;
    --play-gradient-hover: #1C8D53;
    --panel-gradient-end: #090B2F;
    --stats-gradient-end: #131738;
    --stats-border: #000000;
    --stop-red: #EF2A2C;
    --stop-gradient-dark: #310606;
    --stop-gradient-light: #9B1616;
    /* Game speed: bright = icon colour, dark = button fill, hover = hover gradient end / panel glow */
    --speed-slow: #32E287;
    --speed-slow-dark: #00301B;
    --speed-slow-hover: #1C8D53;
    --speed-medium: #EAC241;
    --speed-medium-dark: #2E2300;
    --speed-medium-hover: #8C6E1C;
    --speed-fast: #E82123;
    --speed-fast-dark: #310606;
    --speed-fast-hover: #9B1616;
}

@font-face {
    font-family: 'InterRegular';
    src: url(fonts/Inter-Regular.woff2) format('woff2');
    font-display: swap;
}

@font-face {
    font-family: 'InterBold';
    src: url(fonts/Inter-Bold.woff2) format('woff2');
    font-display: swap;
}

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
    box-sizing: border-box;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}

ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

button:disabled,
.bet-value-box:has(:disabled) {
    opacity: 0.3;
    pointer-events: none;
}

:focus-visible {
    outline: 2px solid var(--font-color-main);
    outline-offset: 2px;
}

body {
    font-family: 'InterRegular', sans-serif ;
    color: var(--font-color-main);
    font-size: 14px;
	line-height: 1;
    background: var(--background-page);
}

* {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

*::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.toggle-box {
    display: flex;
    justify-content: center;
    align-items: center;
}

.toggle-button {
    width: 40px;
    height: 24px;
    background-color: var(--button-background-main);
    border-radius: 200px;
    cursor: pointer;
    position: relative;
    padding: 2px;
    transition: 0.2s;
}

.toggle-button::before {
    position: absolute;
    content: '';
    background-color: var(--button-background-light);
    height: 20px;
    aspect-ratio: 1;
    border-radius: 200px;
    transition: 0.2s;
}

input:checked + .toggle-button::before {
    background-color: var(--green-main-hover);
    transform: translateX(16px);
}



/* HELP MODAL */
.help-modal-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: var(--blur-backdrop-dark);
    backdrop-filter: blur(2px);
    z-index: 100;
    padding: 24px;
}

.help-modal {
    flex: 1;
    display: flex;
    max-width: 600px;
    max-height: 100%;
    padding: 24px 8px 24px 24px; /* less on the right so the scrollbar sits near the edge */
    color: var(--font-color-main);
    background-color: var(--background-light);
    border-radius: 16px;
    border: 2px var(--border-muted) solid;
    position: relative;
}

/* Scrolls when the rules are taller than the game window; close button stays put */
.help-modal-layout {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.help-header-main {
    font-family: 'InterBold';
    font-size: 32px;
    line-height: 1;
    text-align: center;
    margin-bottom: 16px;
}

.help-header-small {
    font-family: 'InterBold';
    font-size: 16px;
    margin: 24px 0 8px;
}

.help-modal-layout p + p {
    margin-top: 8px;
}

.help-modal-layout strong {
    font-family: 'InterBold';
}

.help-list {
    padding-left: 20px;
}

ol.help-list {
    list-style: decimal;
}

ul.help-list {
    list-style: disc;
}

.help-list li + li {
    margin-top: 4px;
}

.help-example {
    margin-top: 8px;
    color: var(--font-color-muted);
}

.help-close-button {
    aspect-ratio: 1;
    width: 20px;
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 1;
    /* backing so scrolled text doesn't show through the icon */
    background-color: var(--background-light);
    box-shadow: 0 0 0 6px var(--background-light);
    border-radius: 2px;
    cursor: pointer;
    transition: 0.15s;
}

.autoplay-close-button {
    aspect-ratio: 1;
    width: 12px;
    position: absolute;
    top: 22px;
    right: 24px;
    cursor: pointer;
    transition: 0.15s;
}

.help-close-button:hover,
.autoplay-close-button:hover {
    opacity: 0.8;
}

.help-close-button > img,
.autoplay-close-button > img,
.toolbar-item > img {
    display: block;
    width: 100%;
}

@media (max-width: 600px) and (orientation: portrait) {
    .help-modal-backdrop {
        padding: 16px;
    }

    .help-modal {
        padding: 16px 4px 16px 16px;
    }

    .help-close-button {
        top: 16px;
        right: 16px;
    }

    .help-header-main {
        font-size: 20px;
    }

    .help-modal-layout {
        font-size: 13px;
        padding-right: 12px;
    }
}




/* MENU POP UP */
.menu-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: var(--blur-backdrop-dark);
    backdrop-filter: blur(2px);
    z-index: 100;
    padding: 24px;
}

.menu-layout {
    display: flex;
    flex-direction: column;
    width: 400px;
    padding: 24px;
    background-color: var(--background-light);
    border: 2px var(--border-muted) solid;
    border-radius: 16px;
    z-index: 100;
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--font-color-main);
}

@media (max-width: 600px) and (orientation: portrait) {
  .menu-layout {
    width: calc(100vw - 16px); /* only applies at 500px and below */
    top: 8px;
  }
}

.menu-layout div:last-of-type {
    margin-bottom: 0px;
}

.menu-header-container {
    display: flex;
    gap: 16px;
    justify-content: flex-start;
    align-items: end;
    width: stretch;
    padding-bottom: 24px;
}

.menu-header-container > *{
    user-select: none;
}

.menu-item-container--toggle {
    justify-content: space-between;
}

.menu-header {
    font-family: 'InterBold';
    font-size: 24px;
}

.menu-divider {
    height: 24px;
    border-top: 1px var(--border-muted) solid;
    width: stretch;
}

.menu-item-container {
    display: flex;
    gap: 16px;
    height: 16px;
    align-items: flex-end;
    margin-bottom: 16px;
    width: stretch;
    cursor: pointer;
}

.menu-item-container > * {
    user-select: none;
}




/* AUTOPLAY MENU POPUP */
.autoplay-menu-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: var(--blur-backdrop-dark);
    backdrop-filter: blur(2px);
    z-index: 100;
}

.autoplay-menu-layout {
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 8px;
    width: 300px;
    /* Subtle glow along the bottom in the selected speed's hover colour */
    background:
        radial-gradient(60% 30% at 50% 100%, color-mix(in srgb, var(--speed-hover) 35%, transparent), transparent),
        linear-gradient(to bottom, var(--background-light), var(--menu-gradient-end));
    border: 1px var(--menu-border) solid;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.autoplay-section {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 64px;
    gap: 8px;
}

.autoplay-section--flex-1 {
    flex: 1;
}

.autoplay-section-label {
    font-family: 'InterBold';
    color: var(--font-color-muted);
    font-size: 14px;
    user-select: none;
}

.autoplay-input-field {
    background: var(--menu-gradient-end);
    border: 1px var(--border-muted-dark) solid;
    border-radius: 4px;
    outline: none;
    color: var(--font-color-main);
    font-family: 'InterBold';
    font-size: 14px;
    user-select: none;
    padding: 0 16px;
    flex: 1;
}

.autoplay-input-field:hover,
.autoplay-input-field:focus {
    border-color: var(--border-muted);
}

.quick-picks-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 40px;
    gap: 8px;
}

.quick-picks-item {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color: var(--button-background-main);
    border-radius: 4px;
    font-family: 'InterBold';
    transition: 0.2s;
    cursor: pointer;
}

.quick-picks-item > * {
    user-select: none;
}

.quick-picks-item:hover {
    background-color: var(--button-background-light);
}

.quick-picks-item--active {
    background-color: var(--button-background-light);
    border: 1px var(--toggle-gradient-light) solid;
}

.autoplay-menu-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 42px;
    border-radius: 4px;
    background-color: var(--green-main);
    gap: 8px;
    font-family: 'InterBold';
    cursor: pointer;
    transition: 0.15s;
}

.autoplay-menu-btn:hover {
    background-color: var(--green-main-hover);
}

/* Game speed: traffic-light theme, colours taken from the speed icons */
.autoplay-menu-layout {
    --speed-color: var(--speed-slow);
    --speed-dark: var(--speed-slow-dark);
    --speed-hover: var(--speed-slow-hover);
}
.autoplay-menu-layout[data-speed="medium"] {
    --speed-color: var(--speed-medium);
    --speed-dark: var(--speed-medium-dark);
    --speed-hover: var(--speed-medium-hover);
}
.autoplay-menu-layout[data-speed="fast"] {
    --speed-color: var(--speed-fast);
    --speed-dark: var(--speed-fast-dark);
    --speed-hover: var(--speed-fast-hover);
}

.speed-label {
    color: var(--speed-color);
}

.speed-picks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.speed-pick {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    border: 1px solid transparent;
    border-radius: 4px;
    background-color: var(--button-background-main);
    transition: 0.15s;
}

.speed-pick:hover {
    background-color: var(--button-background-light);
}

.speed-pick[aria-pressed="true"] {
    background-color: var(--speed-dark);
    border-color: var(--speed-color);
}

/* Start Auto mirrors the Play button, in the selected speed's colours */
.autoplay-menu-layout .autoplay-menu-btn {
    margin-top: 8px;
    color: var(--speed-color);
    background: var(--speed-dark);
    border: 1px solid var(--speed-color);
}

.autoplay-menu-layout .autoplay-menu-btn:hover {
    background: linear-gradient(to bottom, var(--speed-dark), var(--speed-hover));
}

/* Play icon tinted to the text colour (Play button, Start Auto) */
.tinted-play-icon {
    width: 18px;
    height: 18px;
    background-color: currentColor;
    mask: url(assets/play-icon.svg) center / contain no-repeat;
}

.autoplay-btn--active .autoplay-btn-icon {
    display: none;
}




/* ROUND HISTORY POPUP */
.round-history-window {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: var(--blur-backdrop-dark);
    backdrop-filter: blur(2px);
    padding: 24px;
    z-index: 100;
}

.round-history-main {
    display: flex;
    flex-direction: column;
    padding: 24px;
    width: 100%;
    height: 100%;
    background-color: var(--background-light);
    border: 1px var(--border-muted) solid;
    border-radius: 16px;
    position: relative;
}

.round-history-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
}

.autoplay-close-button--default {
    top: 0px;
    right: 0px;
}

.round-history-header {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px;
    width: 100%;
}

.round-history-title {
    font-family: 'InterBold';
    font-size: 24px;
    user-select: none;
}

.round-history-log-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.round-history-log-header {
    display: grid;
    grid-template-columns: repeat(5,1fr);
    height: 40px;
    align-content: center;
    border-bottom: 1px var(--border-divider) solid;
}

.round-history-log-header-label {
    color: var(--font-color-muted);
    font-size: 12px;
}

.round-history-scroll-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.round-history-log-grid {
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
}

.round-history-item-entry {
    display: grid;
    grid-template-columns: repeat(5,1fr);
    height: 40px;
    align-content: center;
    font-size: 12px;
}

.round-history-item-value {
    align-self: center;
}

.round-history-item-value--win {
    color: var(--font-color-win);
}

.round-history-item-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.round-history-item-id-icon {
    display: flex;
}

@media (max-width: 600px) and (orientation: portrait) {
    .round-history-log-header {
        grid-template-columns: repeat(4, 1fr);
    }

    .round-history-log-header-label:nth-child(4) {
        display: none;
    }

    .round-history-item-entry {
        grid-template-columns: repeat(4, 1fr);
    }

    .round-history-item-entry .round-history-item-value:nth-child(4) {
        display: none;
    }

    .round-history-header {
        height: 40px;
    }

    .round-history-title {
        font-size: 20px;
    }

    .round-history-window {
        padding: 16px;
    }

    .round-history-main {
        padding: 16px;
    }

    .round-history-log-header {
        height: 32px;
    }
}

@media (max-width: 500px) and (orientation: portrait) {
    .round-history-item-flex > .round-history-item-value {
        width: 40px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}




/* HISTORY CARD */
.history-card-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: var(--blur-backdrop-dark);
    backdrop-filter: blur(2px);
    z-index: 105;
    padding: 24px;
}

.history-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    width: 400px;
    background-color: var(--background-light);
    border: 1px var(--border-muted) solid;
    border-radius: 16px;
    position: relative;
}

.history-card_header {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 48px;
}

.history-card_roundid {
    font-family: 'InterBold';
    font-size: 14px;
    text-align: center;
    color: var(--font-color-win);
}

.history-card_roundid::before {
    content: 'Round ID: ';
    font-family: 'InterRegular';
    color: var(--font-color-main);
}

.history-card_details-container {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
}

.history-card_item-container {
    display: flex;
}

.history-card_item-box {
    flex: 1;
    display: flex;
    align-items: center;
    height: 32px;
    font-size: 12px;
}

.history-card_label {
    color: var(--font-color-muted);
}

.history-card_value {
    font-family: 'InterBold';
}




/* MAIN GRID LAYOUT */
/* Landscape: largest 16:9 box that fits the window/iframe, centred, edge to edge.
   Below 960x540, fitToViewport() in script.js scales the whole game down uniformly. */
.main-game-template {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: auto 1fr;
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(100vw, 100vh * 16 / 9);
    aspect-ratio: 16 / 9;
    transform: translate(-50%, -50%);
    overflow: hidden;
}

@media (orientation: landscape) {
    html, body {
        overflow: hidden; /* the scaled-down layout box is larger than what's shown */
    }
}

@media (orientation: portrait) {
    .main-game-template {
        position: static;
        width: auto;
        height: 100vh;
        height: 100dvh; /* excludes mobile browser toolbars */
        aspect-ratio: auto;
        transform: none;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .main-game-template-header {
        grid-column: 1;
        order: 1;
    }

    .main-game-template-window {
        order: 2;
    }

    .main-game-template-aside {
        order: 3;
    }
}




/* HEADER */
.main-game-template-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 72px;
    padding: 0px 24px;
    background: linear-gradient(to right, var(--background-light), var(--panel-gradient-end));
    border-bottom: 1px solid var(--border-muted);
    grid-column: 1 / -1;
}

.title-layout {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
}

.title-name {
    font-family: 'InterBold';
    font-size: 16px;
    user-select: none;
}

.time-box {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 20px;
    background-color: var(--button-background-main);
    padding: 0px 12px;
    border-radius: 4px;
}

.time-display {
    font-size: 12px;
    color: var(--font-color-muted);
    user-select: none;
}

.toolbar-layout {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.toolbar-item {
    aspect-ratio: 1;
    width: 26px;
    cursor: pointer;
    transition: 0.15s;
}

.toolbar-item:hover {
    opacity: 0.8;
}

@media (max-width: 600px) and (orientation: portrait) {
    .main-game-template-header {
        height: 64px;
        padding: 0px 16px;
    }
    .title-name {
        font-size: 14px;
    }
    .time-box {
        padding: 0px 8px;
    }
    .toolbar-layout {
        gap: 8px;
    }
    .toolbar-item {
        width: 22px;
    }
}




/* BET PANEL ASIDE */
.main-game-template-aside {
    background: linear-gradient(to bottom, var(--background-light), var(--panel-gradient-end));
    border-right: 1px solid var(--border-muted);
    padding: 24px;
}

.game-controls-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    gap: 24px;
}

.aside-section-container-top {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.aside-section {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 64px;
    gap: 8px;
}

.aside-section--large {
    height: auto;
}

.aside-label {
    color: var(--font-color-muted);
    user-select: none;
}

.aside-box {
    display: flex;
    align-items: center;
    border-radius: 4px;
    border: 1px var(--border-muted-dark) solid;
    padding: 0px 16px;
    height: 100%;
}

.aside-box-value {
    font-family: 'InterBold';
    user-select: none;
}

.aside-box-value::before {
    content: '$';
} 

.bet-value-controls {
    display: flex;
    justify-content: space-between;
    height: 42px;
    gap: 8px;
}

/* Shared button look: flat blue, gradient on hover */
.minus-bet-button,
.plus-bet-button,
.autoplay-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    background: var(--button-background-main);
}

.minus-bet-button:hover,
.plus-bet-button:hover,
.autoplay-btn:hover {
    background: linear-gradient(to bottom, var(--button-background-main), var(--button-background-light));
}

.minus-bet-button,
.plus-bet-button {
    aspect-ratio: 1;
    width: 42px;
}

.bet-value-box {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0; /* let the box shrink below the input's default width */
    padding: 0 12px 0 16px;
    background-color: var(--background-dark);
    border: 1px var(--border-muted-dark) solid;
    border-radius: 4px;
    font-family: 'InterBold';
    transition: border-color 0.15s;
}

.bet-value-box:hover,
.bet-value-box:focus-within {
    border-color: var(--border-muted);
}

.bet-value-input {
    flex: 1;
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    outline: none;
    color: var(--font-color-main);
    font: inherit;
}

.bet-dropdown-icon {
    width: 16px;
    transition: transform 0.15s;
}

.bet-dropdown-toggle {
    display: flex;
    flex-shrink: 0;
    padding: 4px;
    margin-right: -4px;
    border-radius: 4px;
}

.bet-dropdown-toggle[aria-expanded="true"] .bet-dropdown-icon {
    transform: rotate(180deg);
}

/* Bet presets: 5 rows visible, then scrolls. Fill and border match the bet box. */
.bet-options {
    --bet-option-height: 32px;
    position: absolute;
    top: calc(100% + 4px);
    left: -1px;
    right: -1px;
    z-index: 10;
    max-height: calc(5 * var(--bet-option-height) + 2px);
    overflow-y: auto;
    background-color: var(--background-dark);
    border: 1px solid var(--border-muted);
    border-radius: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--button-background-light) transparent;
}

.help-modal-layout {
    scrollbar-width: thin;
    scrollbar-color: var(--button-background-light) transparent;
}

/* Safari ignores scrollbar-color; re-enable and style its scrollbar (hidden globally) */
.bet-options::-webkit-scrollbar,
.help-modal-layout::-webkit-scrollbar {
    display: block;
    width: 6px;
}

.bet-options::-webkit-scrollbar-thumb,
.help-modal-layout::-webkit-scrollbar-thumb {
    background-color: var(--button-background-light);
    border-radius: 3px;
}

.bet-option {
    width: 100%;
    height: var(--bet-option-height);
    padding: 0 15px;
    text-align: left;
}

.bet-option:hover {
    background-color: var(--button-background-main);
}

.bet-option--active {
    background-color: var(--button-background-light);
}

.bet-option:focus-visible {
    outline-offset: -2px; /* the list clips outlines drawn outside it */
}

/* Controls sit at the bottom of the screen on narrow layouts, so the list opens upwards */
@media (orientation: portrait) {
    .bet-options {
        top: auto;
        bottom: calc(100% + 4px);
    }
}

/* Selected side gets the light end of the gradient */
.over-under-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 42px;
    border-radius: 4px;
    font-family: 'InterBold';
    /* Roll Over selected (right-hand label) */
    background: linear-gradient(to left, var(--toggle-gradient-light) 0%, var(--button-background-light) 25%,
        var(--button-background-main) 50%, var(--toggle-gradient-dark) 100%);
}

.over-under-btn[aria-pressed="true"] {
    /* Roll Under selected (left-hand label) */
    background: linear-gradient(to right, var(--toggle-gradient-light) 0%, var(--button-background-light) 25%,
        var(--button-background-main) 50%, var(--toggle-gradient-dark) 100%);
}

.over-under-btn:hover {
    filter: brightness(1.1); /* ponytail: placeholder until a hover design exists */
}

.over-under-btn[aria-pressed="false"] #under-label,
.over-under-btn[aria-pressed="true"] #over-label {
    color: var(--font-color-inactive);
}

.over-under-btn-text {
    user-select: none;
}

.toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-input:focus-visible + .toggle-button {
    outline: 2px solid var(--font-color-main);
    outline-offset: 2px;
}

.play-buttons-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.play-btn,
.autoplay-btn {
    height: 42px;
    gap: 8px;
    font-family: 'InterBold';
}

.play-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    color: var(--play-green);
    border: 1px solid var(--play-green);
    background: linear-gradient(to bottom, var(--font-color-win-dark), var(--play-gradient-bottom));
}

.play-btn:hover {
    background: linear-gradient(to bottom, var(--font-color-win-dark), var(--play-gradient-hover));
}

.play-btn > *,
.autoplay-btn > * {
    user-select: none;
}

.autoplay-btn.autoplay-btn--active {
    color: var(--stop-red);
    border: 1px solid var(--stop-red);
    background: linear-gradient(to bottom, var(--stop-gradient-dark), var(--stop-gradient-light));
}

.autoplay-btn.autoplay-btn--active:hover {
    filter: brightness(1.15); /* ponytail: placeholder until a hover design exists */
}

/* Press feedback on bet panel buttons: instant press-in so rapid taps always register,
   then scale and brightness ease back together */
.main-game-template-aside button:not(.bet-option) {
    transition: transform 100ms ease-out, filter 100ms ease-out;
}

.main-game-template-aside button:not(.bet-option):active {
    transform: scale(0.97);
    filter: brightness(1.2);
    transition-duration: 0s;
}

@media (orientation: portrait) {
    /* Panel sits below the game here: divider on top instead of the right */
    .main-game-template-aside {
        border-right: 0;
        border-top: 1px solid var(--border-muted);
    }
    .aside-section-container-top {
        flex-direction: row;
    }
    .aside-section {
        flex: 1;
    }
    .play-buttons-wrap {
        flex-direction: row;
    }
    .play-btn,
    .autoplay-btn {
        flex: 1;
    }
}

@media (max-width: 600px) and (orientation: portrait) {
    .main-game-template-aside {
        padding: 16px;
    }
    .game-controls-layout {
        gap: 16px;
    }
    .aside-section-container-top {
        gap: 8px;
    }
    .aside-section {
        height: 56px;
    }
    .aside-label {
        font-size: 12px;
    }
    .bet-value-controls {
        height: 36px;
    }
    .minus-bet-button,
    .plus-bet-button {
        width: 36px;
    }
}




/* MAIN GAME WINDOW */
.main-game-template-window {
    display: flex;
    flex-direction: column;
    background-color: var(--background-dark);
    padding: 24px;
    position: relative;
}

/* Short notices from the game, e.g. a failed bet */
.game-message {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 8px 16px;
    border: 1px solid var(--font-color-lose-muted);
    border-radius: 8px;
    background: var(--font-color-lose-dark);
    color: var(--font-color-main);
    font-size: 14px;
    white-space: nowrap;
}

.round-history-container {
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.round-history-grid {
    display: grid;
    grid-template-columns: repeat(6, 62px);
    grid-template-rows: 1fr;
    max-width: 420px;
    gap: 8px;
    overflow: hidden;
}

.round-history-grid > * {
    user-select: none;
}

.history-ticker-item {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 62px;
    height: 28px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px var(--font-color-win-muted) solid;
    background-color: var(--font-color-win-dark);
    color: var(--font-color-win);
    font-family: 'InterBold';
    transition: filter 0.15s;
}

.history-ticker-item:hover {
    filter: brightness(1.3);
}

/* Chips stay readable (not dimmed) while locked during autoplay */
.round-history-grid[inert] .history-ticker-item {
    cursor: default;
}

.history-ticker-item--lose {
    border: 1px var(--font-color-lose-muted) solid;
    background-color: var(--font-color-lose-dark);
    color: var(--font-color-lose);
}

.stats-display-container {
    display: flex;
    justify-content: space-between;
    height: 96px;
    background: linear-gradient(to bottom, var(--background-light), var(--stats-gradient-end));
    border: 1px solid var(--stats-border);
    border-radius: 8px;
    padding: 24px;
}

.stats-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
}

.stats-section > * {
    user-select: none;
}

.stats-label {
    color: var(--font-color-muted);
}

.stats-value {
    font-family: 'InterBold';
    font-size: 16px;
}

@media (max-width: 600px) and (orientation: portrait) {
    .round-history-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 44px));
        max-width: 320px;
        gap: 4px;
    }
    .history-ticker-item {
        font-size: 10px;
        width: 44px;
        height: 24px;
    }
    .main-game-template-window {
        padding: 16px;
    }
    .slider-top-labels-container {
        font-size: 12px;
    }
    .stats-display-container {
        padding: 16px;
        height: 72px;
    }
    .stats-label {
        font-size: 12px;
    }
}




/* DICE SLIDER */
.slider-main-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.slider-layout {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100px;
    width: 100%;
    max-width: 540px;
    position: relative;
}

.slider-top-labels-container {
    flex: 1;
    display: block;
    position: relative;
}

.slider-top-labels-container > * {
    user-select: none;
}

.slider-top-label {
    font-family: 'InterBold';
    color: var(--font-color-muted);
    position: absolute;
    top: 0;
    left: 0;
}

#label-25 {
    left: 25%;
    transform: translateX(-50%);
}

#label-50 {
    left: 50%;
    transform: translateX(-50%);
}

#label-75 {
    left: 75%;
    transform: translateX(-50%);
}

#label-100 {
    left: 100%;
    transform: translateX(-100%);
}

#range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
}
 
/* Chrome & Safari thumb */
#range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 20px;
    height: 35px;
    border-radius: 4px;
    border: 1px solid var(--hover-light-1);
    cursor: grab;
    background: linear-gradient(to bottom, var(--thumb-gradient-top), var(--thumb-gradient-bottom));
}
 
/* Firefox thumb */
#range-slider::-moz-range-thumb {
    box-sizing: border-box;
    width: 20px;
    height: 35px;
    border-radius: 4px;
    border: 1px solid var(--hover-light-1);
    cursor: grab;
    background: linear-gradient(to bottom, var(--thumb-gradient-top), var(--thumb-gradient-bottom));
}

/* Glows: one blurred ellipse under the thumb and under the result marker.
   Kept as real elements so they can get their own transitions later. */
.slider-glow {
    --glow-color: var(--thumb-glow);
    position: absolute;
    top: calc(50% + 27px);
    width: 78px;
    height: 12px;
    border-radius: 50%;
    background: radial-gradient(closest-side, var(--glow-color),
        color-mix(in srgb, var(--glow-color) 45%, transparent) 45%, transparent);
    filter: blur(6px);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Thumb centre: the native thumb is inset by half its width (10px) at each end */
.thumb-glow {
    left: calc(10px + (100% - 20px) * var(--pct, 50) / 100);
}

.roll-result-indicator .slider-glow {
    --glow-color: var(--font-color-lose);
    left: 50%;
}

.roll-result-indicator--win .slider-glow {
    --glow-color: var(--font-color-win);
}

.roll-result-indicator {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: left 0.35s ease, opacity 0.25s ease;
}

@keyframes indicator-pop {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0.5; }
    40%  { transform: translate(-50%, -50%) scale(0.7); opacity: 0.5; }
    70%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* Number pumps past the marker's edges, then settles (7-frame timeline from Figma) */
@keyframes value-pump {
    0%   { opacity: 0; transform: scale(0.3); }
    17%  { opacity: 1; transform: scale(0.65); }
    33%  { transform: scale(0.85); }
    50%  { transform: scale(1.3); }
    67%  { transform: scale(1.55); }
    83%  { transform: scale(1.3); }
    100% { opacity: 1; transform: scale(1); }
}

.roll-result-indicator {
    --marker-pop-duration: 0.35s; /* marker and number share one timing */
}

.roll-result-indicator.animating {
    opacity: 1;
    animation: indicator-pop var(--marker-pop-duration) ease-out forwards;
}

.roll-result-indicator.animating .roll-result-value {
    animation: value-pump var(--marker-pop-duration) ease-in-out forwards;
}

/* Reveal in reverse: small swell, then shrink to nothing; fades only at the very end */
@keyframes indicator-shrink {
    0%   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
    30%  { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0);   opacity: 0; }
}

.roll-result-indicator.hiding {
    animation: indicator-shrink var(--marker-pop-duration) ease-in forwards;
}

/* "Disable Animations" setting (and fast autoplay): result appears and disappears in place, colour still applies */
.no-animations .roll-result-indicator,
.no-animations .roll-result-indicator.animating,
.no-animations .roll-result-indicator.animating .roll-result-value,
.fast-autoplay .roll-result-indicator,
.fast-autoplay .roll-result-indicator.animating,
.fast-autoplay .roll-result-indicator.animating .roll-result-value,
.no-animations .roll-result-indicator.hiding,
.fast-autoplay .roll-result-indicator.hiding {
    transition: none;
    animation: none;
}

.roll-result-svg {
    fill: var(--font-color-lose);
    stroke: var(--font-color-lose);
    stroke-width: 8;
    stroke-linejoin: round;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.roll-result-indicator--win .roll-result-svg {
    fill: var(--font-color-win);
    stroke: var(--font-color-win);
}

.roll-result-value {
    position: relative;
    font-family: 'InterBold';
    font-size: 12px;
    user-select: none;
    z-index: 1;
}

.slider-bottom-labels-container {
    flex: 1;
    display: block;
    font-size: 12px;
    position: relative;
}

.slider-bottom-labels-container > * {
    user-select: none;
}

.slider-bottom-label {
    font-family: 'InterBold';
    position: absolute;
    bottom: 0;
}

#bottom-label-over {
    color: var(--slider-color-over);
    right: 0;
}

#bottom-label-under {
    color: var(--slider-color-under);
    left: 0;
}

@media (max-width: 600px) and (orientation: portrait) {
    .slider-bottom-labels-container {
        font-size: 12px;
    }
}