* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
    color: #424243;
    user-select: none;
}

body, html {
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    --moves-badge-display: flex;
    --moves-badge-counter: 0;

    --blow-color-badge-display: none;
    --blow-color-badge-counter: 0;
    --blow-color-bg-height: 0%;

    --blow-nearby-badge-display: none;
    --blow-nearby-badge-counter: 0;
    --blow-nearby-bg-height: 0%;

    --any-color-badge-display: none;
    --any-color-badge-counter: 0;
    --any-color-bg-height: 0%;
}

html, body {
    width: 100%;
    height: 100%;
}

p {
    margin: 12px 0;
}

p > svg {
    display: block;
    width: 24px;
    height: 24px;
    margin-right: 12px;
    float: left;
}

p > span {
    display: block;
}

h3 {
    margin: 16px 0;
}

.app {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    align-items: center;
    gap: 12px;
    padding: 12px 6px;
    transition: all 0.1s ease-in;
}

.app-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    align-items: center;
    gap: 12px;
    overflow: visible;
}

.timer {
    width: 100%;
    height: 8px;
    font-weight: 700;
    border-radius: 6px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.3);
}

.timer_filler {
    display: block;
    width: 100%;
    height: 100%;
    background-color: unset;
    border-radius: 1px;
    transition: all 1s linear;
}


.header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 12px;
    width: 100%;
    overflow: visible;
}

.score-counter-container, .score-counter, .best-score, .new-game-button-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-content: center;
    align-items: center;
    text-align: left;
    gap: 6px;
    transition: transform 0.1s ease-in;
    transform-origin: center center;
    transform: scale(1);
    font-size: 24px;
    font-weight: 700;
    padding: 0 12px;
    overflow: visible;
    color: #ffffff;
}

.best-score > span {
    color: #ffffff;
}

.score-counter__bounce {
    transform: scale(1.5);
    color: rgb(0, 119, 237);
}

.pulse {
    border-radius: 6px;
    animation-name: pulse-animation;
    animation-duration: 2s;
    animation-fill-mode: both;
    animation-direction: normal;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
    z-index: 1;
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}

@keyframes pulse-animation {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
        opacity: 1;
        transform: scale(1, 1);
    }
    50% {
        box-shadow: rgba(0, 0, 0, 0.2) 0 10px 16px 0, rgba(0, 119, 237, 0.1) 0 6px 20px 0;
        opacity: 1;
        transform: scale(1.02, 1.02);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
        opacity: 1;
        transform: scale(1, 1);
    }
}

.boosters {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 16px;
    overflow: visible;
}

.button {
    position: relative;
    background-color: rgb(255, 255, 255);
    border: 2px solid rgb(0, 119, 237);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    overflow: visible;
    transition: all 0.3s;
    z-index: 1;
}

.button:active {
    background-color: rgba(255, 78, 64, .06);
    border: 2px solid rgb(255, 78, 64);
}

.prinzip-button {
    background-color: white;
    border: none !important;
    border-radius: 8px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prinzip-button img {
    display: block;
}

.prinzip-button.pulse {
    animation: none;
}

.button:active > svg {
    fill: rgb(255, 78, 64);
}

.button:disabled {
    border: 2px solid rgb(204, 204, 204);
    cursor: default;
}

.button:disabled > svg {
    fill: rgb(204, 204, 204);
}

#booster-blow-color .button-badge,
#booster-show-move .button-badge,
#booster-blow-nearby .button-badge,
#booster-any-color .button-badge {
    display: none;
    content: unset;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    align-items: center;
    text-align: center;
    color: white;
    min-width: 2em;
    min-height: 2em;
    font-size: small;
    position: absolute;
    right: -0.75em;
    top: -0.75em;
    background-color: rgb(0, 119, 237);
    border-radius: 50%;
    border: 2px solid white;
}

#booster-blow-color .button-badge {
    content: var(--blow-color-badge-counter);
    display: var(--blow-color-badge-display);
}

#booster-show-move .button-badge {
    content: var(--moves-badge-counter);
    display: var(--moves-badge-display);
}

#booster-blow-nearby .button-badge {
    content: var(--blow-nearby-badge-counter);
    display: var(--blow-nearby-badge-display);
}

#booster-any-color .button-badge {
    content: var(--any-color-badge-counter);
    display: var(--any-color-badge-display);
}

#booster-blow-color:before, #booster-blow-nearby:before, #booster-any-color:before {
    position: absolute;
    content: '';
    display: block;
    box-sizing: border-box;
    width: 100%;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 119, 237, .1);
    z-index: -1;
    transition: height 0.3s;
}

#booster-blow-color:before {
    height: var(--blow-color-bg-height);
}

#booster-blow-nearby:before {
    height: var(--blow-nearby-bg-height);
}

#booster-any-color:before {
    height: var(--any-color-bg-height);
}

#booster-show-move[disabled=disabled]:before {
    position: absolute;
    content: '';
    display: block;
    width: 100%;
    height: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 119, 237, .1);
    z-index: -1;
    animation-name: height-rise;
    animation-duration: 5s;
    animation-delay: 0s;
    animation-iteration-count: 1;
    animation-timing-function: linear;
    transition: height 0.3s;
}

@keyframes height-rise {
    from {
        height: 0;
    }
    to {
        height: 100%;
    }
}

.game-field {
    border: 2px solid #ccc;
    border-radius: 6px;
    position: relative;
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
}

canvas {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.game-field-overlay {
    position: absolute;
    display: none;
    gap: 12px;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    align-items: center;
    z-index: 2;
    background-color: rgba(0,0,0,.6);
    padding: 12px;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
    height: 100%;
    backdrop-filter: blur(2px);
}

.game-field-overlay span {
    fill: white;
    color: white;
    text-shadow: 1px 1px 3px #000;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.times-up, .no-moves {
    display: none;
}

.overlay-times-up > .times-up {
    display: block;
}
.overlay-no-moves > .no-moves {
    display: block;
}


.controllers {
    width: 100%;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px 12px;
    overflow: visible;
}

/* Music toggle button */
.music-toggle {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.music-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.music-button svg {
    width: 28px;
    height: 28px;
}

.music-button.music-on {
    border-color: #38ef7d;
    background: linear-gradient(135deg, rgba(17, 153, 142, 0.6) 0%, rgba(56, 239, 125, 0.6) 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(56, 239, 125, 0.4);
}

.music-button:not(.music-on) {
    border-color: rgba(255, 100, 100, 0.6);
    background: rgba(255, 100, 100, 0.2);
}

.music-button:active {
    transform: scale(0.92);
}

.controllers-item {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.5s;
    position: relative;
    overflow: visible;
}

.controllers-item__enabled {
    background-color: rgba(0, 119, 237, 0.8);
    color: rgb(255, 255, 255);
    border: 2px solid rgb(0, 119, 237);
    cursor: pointer;
}


.controllers-item[data-role="checkbox"] {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.controllers-item__enabled.controllers-item[data-role="checkbox"] {
    border: 2px solid rgb(0, 119, 237);
}

.controllers-item[data-role="checkbox"]::before {
    content: '';
    position: absolute;
    left: 0.5em;
    display: block;
    width: 1em;
    height: 1em;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 3px;
    transition: all 0.25s ease-in-out;
}

.controllers-item__enabled.controllers-item[data-role="checkbox"]::before {
    content: '✅';
}

#show-move-button.controllers-item:after {
    display: var(--moves-badge-display);
    justify-content: center;
    align-content: center;
    align-items: center;
    text-align: center;
    color: white;
    min-width: 1.5em;
    min-height: 1.5em;
    font-size: small;
    content: var(--moves-badge-counter);
    position: absolute;
    right: -0.5em;
    top: -0.75em;
    background-color: rgb(0, 119, 237);
    border-radius: 50%;
    border: 2px solid white;
}

.statistics {
    width: 100%;
    height: 16px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-content: center;
    align-items: center;
    gap: 2px;
    transition: all 1s;
}

.statistics > div {
    width: 0;
    height: 16px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    transition: all 0.5s;
}

@media (orientation: landscape) {
    .app-container, .app-container > .game-field {
        width: 480px;
    }

    .controllers-item {
        font-size: 16px;
    }

    body, html {
        overflow-y: scroll;
        overflow-x: hidden;
    }
}

@media (orientation: portrait) {
    .app-container, .app-container > .game-field {
        width: 100%;
    }

    .controllers-item {
        font-size: 12px;
    }

    body, html {
        overflow: hidden;
    }
}

.header > *, .timer > *, .statistics > * {
    pointer-events: none;
}

/* The Modal - https://www.w3schools.com/howto/howto_css_modals.asp */
.faq-modal {
    display: none;
    align-content: center;
    justify-content: center;
    align-items: center;
    position: fixed; /* Stay in place */
    z-index: 100; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0, 0, 0); /* Fallback color */
    background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */
}

.faq-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: small;
    background-color: #fefefe;
    padding: 16px;
    border: 1px solid #888;
    width: 90%;
    max-width: 480px;
    height: 90%;
    box-shadow: rgba(0, 0, 0, 0.5) 0 2px 12px 0;
    box-sizing: border-box;
    border-radius: 6px;
}

.faq-modal-close-button {
    color: #aaa;
    float: right;
    font-size: 24px;
    font-weight: bold;
}

.faq-modal-close-button:hover > svg,
.faq-modal-close-button:focus > svg {
    fill: black;
    cursor: pointer;
}

.faq-header {
    display: flex;
    justify-content: space-between;
    align-content: center;
    align-items: center;
    border-bottom: 1px solid #ccc;
    padding-bottom: 6px;
}

.faq-content {
    display: block;
    width: 100%;
    height: 100%;
    overflow-y: scroll;
}

/* Snackbar (toast) - https://www.w3schools.com/howto/howto_js_snackbar.asp*/
#snackbar {
    visibility: hidden; /* Hidden by default. Visible on click */
    width: 90%; /* Set a default minimum width */
    max-width: 450px;
    background-color: rgb(66, 66, 67); /* Black background color */
    color: #fff;
    font-size: smaller;
    font-weight: normal;
    text-align: left; /* Centered text */
    border-radius: 2px; /* Rounded borders */
    padding: 12px; /* Padding */
    position: fixed; /* Sit on top of the screen */
    z-index: 1000; /* Add a z-index if needed */
    bottom: 16px; /* 30px from the bottom */
    box-shadow: rgba(0, 0, 0, 0.5) 0 2px 12px 0;
    box-sizing: border-box;
}

#snackbar.snackbar-show {
    visibility: visible;
    animation: snackbar-fadein 0.5s, snackbar-fadeout 0.5s 2.5s;
}

@-webkit-keyframes snackbar-fadein {
    from {
        bottom: 0;
        opacity: 0;
    }
    to {
        bottom: 16px;
        opacity: 1;
    }
}

@keyframes snackbar-fadeout {
    from {
        bottom: 16px;
        opacity: 1;

    }
    to {
        bottom: 0;
        opacity: 0;
    }
}

.footer {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 12px;

    width: 100%;
    overflow: visible;
    margin-top: 32px;
    font-size: 12px;
    font-weight: 700;
    color: rgb(0, 119, 237);
}

.footer > div {
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
    color: rgb(0, 119, 237);
    cursor: pointer;
}

.footer > div > svg {
    display: block;
    width: 24px;
    height: 24px;
    margin-right: 5px;
    fill: rgba(66, 66, 67, .7);
}
.footer > div > span {
    color: rgba(66, 66, 67, .7);
}

.footer > div:hover > svg, .footer > div:hover > span {
    fill: rgba(66, 66, 67, 1);
    color: rgba(66, 66, 67, 1);
}



/* Main Menu */
.main-menu {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 20px;
}

.menu-container {
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.menu-title {
    font-size: 3rem;
    font-weight: 900;
    color: white;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
    margin-bottom: 50px;
    letter-spacing: 2px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-button {
    padding: 20px 40px;
    font-size: 1.4rem;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.play-button {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(17, 153, 142, 0.4);
}

.play-button:hover, .play-button:active {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(17, 153, 142, 0.5);
}

.leaderboard-button {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.4);
}

.leaderboard-button:hover, .leaderboard-button:active {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(245, 87, 108, 0.5);
}

.back-button {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(79, 172, 254, 0.4);
    margin-top: 20px;
}

/* Leaderboard Modal */
.leaderboard-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 1000;
    overflow-y: auto;
}

.leaderboard-content {
    max-width: 500px;
    margin: 20px auto;
    padding: 20px;
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.leaderboard-header h2 {
    color: white;
    font-size: 1.5rem;
    margin: 0;
}

.close-button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaderboard-list {
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    gap: 15px;
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: 700;
    width: 35px;
    text-align: center;
}

.leaderboard-rank.gold { color: #FFD700; }
.leaderboard-rank.silver { color: #C0C0C0; }
.leaderboard-rank.bronze { color: #CD7F32; }

.leaderboard-name {
    flex: 1;
    font-weight: 600;
    color: #333;
}

.leaderboard-score {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1rem;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Game Over Modal */
.game-over-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.game-over-content {
    text-align: center;
    padding: 30px;
    max-width: 400px;
    width: 90%;
}

.game-over-content h2 {
    color: white;
    font-size: 2rem;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-over-score,
.game-over-rank,
.game-over-best {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-over-score span,
.game-over-rank span,
.game-over-best span {
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
}

.game-over-score strong,
.game-over-rank strong,
.game-over-best strong {
    color: white;
    font-size: 1.5rem;
}

.game-over-score strong {
    color: #38ef7d;
}

.game-over-rank strong {
    color: #ffd700;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
}

.game-over-buttons .menu-button {
    padding: 15px 30px;
    font-size: 1.2rem;
}