/* global styles */

* {
    box-sizing: border-box;
}

:root {
    --font-color: #dedede;
    --background-color: #2b2828;
    --tile-bottom-right-color: #cdcda6;
    --tile-top-left-color: #eef;
    --tile-hover-color: #fadbe3;// #e6a0ce; /*#ee7;*/
    --tile-alert-color: #f0ad4e; //#ff0;
    --tile-border-color: #373535; /*#555;*/
    --tile-back-color: #888;
    --link-color: #44954f;
    --button-color: #44954f;// rgb(80, 29, 161);
    --button-hover-color: #5bbc68; //rgb(113, 29, 161);
    --base-width: 1200px; /*1000px;*/
    --base-height: 800px; /*700px;*/
}

body {
    font-family: "Kedebideri", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 300;
    font-size: 18px;
    background-color: var(--background-color);
    color: var(--font-color);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* wrapper */

#wrapper {
    transform-origin: top center;
    width: 100%;
    max-width: 100vw;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;

    font-size: 16px;
    font-weight: 600;
}

/* header - HIDDEN */

header {
    padding: 2rem 0;
    max-width: var(--base-width);
    width: 100%;
}
/* Game info display */
#gameInfo {
    align-items: center;
    display: flex;
    gap: 1.5rem;
}

#timer {
    color: var(--tile-hover-color);
}

#tileCount {
    color: var(--tile-alert-color);
}

#statusText {
    float: left;
}

/*#controls {
    float: right;
}*/

.controls-wrapper {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin: 1rem 0;
    width: 100%;
}
#controls {
    display: flex;
    gap: .75rem;
}

/* main */

main {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* footer */

footer {
    padding-top: 15px;
    position: relative;
    width: 100%;
    max-width: 100vw;
}



/* buttons */

button {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: .75rem;
    font-weight: inherit;
    color: var(--font-color);
    background-color: var(--button-color);
    text-transform: uppercase;
    transition: background-color 100ms linear;

    padding: 10px 16px;
	border-radius: 8px;
	font-weight: bold;
}

button:hover {
    cursor: pointer;
    background-color: var(--button-hover-color);
}

#hintButton {
     background-color:#628081;
}
#hintButton:hover {
     background-color:#93acad;
}
#undoButton {
    background-color: #b38c17;
}
#undoButton:hover {
    background-color: #e4bd46;
}
#restartButton {
    background-color: #ea5c3b;//#c05239
}
#restartButton:hover {
    background-color: #845c3a;
    cursor: pointer;
}

/* game */

#game {
    height: var(--base-height);
    background: url("./img/background-small.jpg") no-repeat center center;
    background-size: 100% 100%;
    position: relative;
    border-radius: 5px;
    opacity: 0;
    width: 100%;
    max-width: var(--base-width);
    margin: 0 auto;
}

/* Center the tile container on mobile - compensate for TOTAL_OFFSET_LEFT */
@media (max-width: 875px) {
    #game {
        transform: translateX(-150px);
    }
}

@media (max-width: 620px) {
    #game {
        transform: translateX(-180px);
    }
}

@media (max-width: 520px) {
    #game {
        transform: translateX(-200px);
    }
}

@media (max-width: 480px) {
    #game {
        transform: translateX(-215px);
    }
}

@media (max-width: 435px) {
    #game {
        transform: translateX(-230px);
    }
}

@media (max-width: 390px) {
    #game {
        transform: translateX(-245px);
    }
}

/* tile */

.tile {
    position: absolute;
}

.tileFront {
    position: absolute;
    background-image: linear-gradient(
        to left top,
        var(--tile-bottom-right-color),
        var(--tile-top-left-color)
    );
    border: 1px solid var(--tile-border-color);
}

.tileFront img {
    object-fit: contain;
}

.playableTile:hover {
    cursor: pointer;
    background-image: linear-gradient(
        to left top,
        var(--tile-hover-color),
        var(--tile-hover-color)
    );
}

.selectedTile {
    background-image: linear-gradient(
        to left top,
        var(--tile-hover-color),
        var(--tile-hover-color)
    );
}

.alertTile {
    background-image: linear-gradient(
        to left top,
        var(--tile-alert-color),
        var(--tile-alert-color)
    );
}

.tileBack {
    position: absolute;
    background-color: var(--tile-back-color);
    	background: linear-gradient(to right bottom, #8d8585, #393939);
    border: 1px solid var(--tile-border-color);
}

/* media queries - Responsive scaling */

@media (min-width: 876px) and (max-width: 1010px) {
    .tile {
        transform: translateX(-65px);
    }
    :root {
        --base-width: 865px;
    }
}

@media (max-width: 875px) {
    #wrapper {
        transform: scale(0.95);
    }
    footer {
        padding: 20px 0px;
    }
    .tile {
        transform: translateX(0) !important;
    }
}

@media (max-width: 830px) {
    #wrapper {
        transform: scale(0.9);
    }
}

@media (max-width: 780px) {
    #wrapper {
        transform: scale(0.85);
    }
}

@media (max-width: 745px) {
    #wrapper {
        transform: scale(0.8);
    }
}

@media (max-width: 700px) {
    #wrapper {
        transform: scale(0.75);
    }
}

@media (max-width: 660px) {
    #wrapper {
        transform: scale(0.7);
    }
}

@media (max-width: 620px) {
    #wrapper {
        transform: scale(0.65);
    }
}

@media (max-width: 570px) {
    #wrapper {
        transform: scale(0.6);
    }
}

@media (max-width: 520px) {
    #wrapper {
        transform: scale(0.55);
    }
}

@media (max-width: 480px) {
    #wrapper {
        transform: scale(0.5);
    }
}

@media (max-width: 435px) {
    #wrapper {
        transform: scale(0.45);
    }
}

@media (max-width: 390px) {
    #wrapper {
        transform: scale(0.4);
    }
}

@media (max-width: 350px) {
    #wrapper {
        transform: scale(0.38);
    }
}


.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    z-index: 9999;
}

.modal {
    background: #2b2828;
    color: #fff;
    padding: 20px 28px;
    border-radius: 12px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    animation: popIn 0.3s ease;
}
@media screen and (min-width: 48em) {
    .modal {
        width: 680px;
    }
}

.modal h2 {
    margin-top: 0;
}

.modal input {
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    border-radius: 2px;
    border: 1px solid #ddd;
}

.modal-buttons {
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
}

.modal-buttons button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin: 0;
}

#save-highscore-btn {
    background: #4caf50;
    color: white;
}

.secondary {
    //background: #ddd;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}


#leaderboard-list {
    font-size: .75rem;
    max-height: 400px;
    overflow-y: scroll;
    margin-top: 10px;
    font-family: monospace;
    overflow-x: scroll;
    white-space: pre;
}
@media screen and (min-width: 48em) {
    #leaderboard-list {
        font-size: 1rem;
    }
}
.leaderboard-entry {
    display: grid;
    grid-template-columns: 2rem 1fr 20% 20%;
    align-items: center;
    font-weight: 400;
    justify-content: flex-start;
    padding: 4px 0;
}

.leaderboard-entry--head {
    font-weight: bold;
}

.medal {
    font-size: 18px;
    margin-right: 8px;
}

.medal.gold { color: gold; }
.medal.silver { color: silver; }
.medal.bronze { color: #cd7f32; } /* bronze color */


#sound-controls {
    display: flex;
    gap: .75rem;
}

.sound-btn {
    background: #222;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-btn .icon {
    width: 20px;
    height: 20px;
    fill: white;
}

.hidden {
    display: none;
}
