/* ==================== */
/* BASE & RESET STYLES */
/* ==================== */

/* Root variables */
:root {
    --background: #0a1830;
    --white: #ffffff;
    --grey-dark: #13294a;
    --grey-light: #27446f;
    --green-dark: #559a3a;
    --green-light: #7bc65a;
    --yellow-dark: #b8921a;
    --yellow-light: #f0c93c;
    --key-light: #3f7f9e;
    --key-dark: #2c6079;
    --grey-shadow: #13294a;
    --text: #ffffff;
    --accent: #4aaebb;
    --accent-dark: #33808b;
}

/* Global styles */
* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1em;
    background-color: var(--background);
    color: var(--text);
    height: 100%;
}


/* Apply smaller font size when screen is less than 1000px */
@media (max-width: 1000px) {
  html {
    font-size: 1.8vw; /* Reduced font size */
  }
}

/* Apply smaller font size when screen is less than 600px */
@media (max-width: 600px) {
    html {
      font-size: 3.5vw; /* Reduced font size */
    }
  }
body {
    flex-flow: column;
    justify-content: top;
    align-items: center;
    max-width: 100vw;
    max-height: 100vh;
    height: 100%;
    display: flex;
    margin: 0;
}

/* Utility classes */
.no-copy {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ==================== */
/* LAYOUT COMPONENTS */
/* ==================== */

/* Navbar styles */
.navbar {
    border-bottom: .1rem solid var(--grey-dark);
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 4.5rem;
    padding: 0 1.5rem;
    display: flex;
}

.logo {
    justify-content: center;
    align-items: center;
    font-size: 2.3rem;
    line-height: 1em;
    display: flex;
}

/* Main game container */
.game {
    flex-flow: column;
    flex: 1;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 1.5rem 0;
    grid-row-gap: 1.5rem;
    display: flex;
}

/* ==================== */
/* GAME ELEMENTS */
/* ==================== */

/* Grid & Tiles */
.grid {
    grid-column-gap: .3rem;
    grid-row-gap: .3rem;
    grid-template-rows: repeat(6, 1fr);
    grid-template-columns: repeat(5, 1fr);
    justify-items: stretch;
    aspect-ratio: 5 / 6;
    display: grid;
}

.tile {
    aspect-ratio: 1 / 1;
    border: .15rem solid var(--grey-dark);
    background-color: var(--background);
    border-radius: .4rem;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    display: flex;
    width : 3.6rem;
    color: var(--text);
    transition: transform 0.1s ease, color 0.2s ease;
    transform: rotateY(0deg);
}

/* Tile states */
.tile.grey {
    color: var(--white);
    background-color: var(--grey-light);
}

.tile.yellow {
    color: var(--white);
    background-color: var(--yellow-light);
}

.tile.green {
    color: var(--white);
    background-color: var(--green-light);
}

.tile.current_row {
    cursor: pointer;
    transform-origin: center;
}

.tile.current_row:hover,
.tile.current_row.selected {
    border-color: var(--key-dark);
}

/* ==================== */
/* KEYBOARD STYLES */
/* ==================== */

.keyboard {
    grid-row-gap: .6rem;
    flex-flow: column;
    display: flex;
    max-width: 98vw;
}

.keyboard-row {
    max-width: 98vw;
    grid-column-gap: .3rem;
    grid-row-gap: .3rem;
    justify-content: center;
    align-items: center;
    display: flex;
}

.key {
    aspect-ratio: 5 / 6;
    background-color: var(--key-light);
    box-shadow: 0 .2rem 0 0 var(--key-dark);
    cursor: pointer;
    border-radius: .3rem;
    justify-content: center;
    align-items: center;
    max-width: 8vw;
    height: 2.6rem;
    font-size: 1.3rem;
    transition: all .1s;
    display: flex;
    transform: translate(0, -.2rem);
}

/* Key states and interactions */
.key:hover {
    filter: brightness(110%);
}

.key:active {
    box-shadow: 0 0 0 0 var(--key-dark);
    transform: translate(0);
    filter: brightness(110%);
}

.key.active {
    box-shadow: 0 0 0 0 var(--key-dark);
    transform: translate(0);
    filter: brightness(110%);
}

.key.special {
    aspect-ratio: auto;
    width: 100%;
    max-width: 13vw;
}

/* Key color variants */
.key.yellow {
    color: var(--white);
    background-color: var(--yellow-light);
    box-shadow: 0 .2rem 0 0 var(--yellow-dark);
}

.key.yellow:active {
    box-shadow: 0 0 0 0 var(--yellow-dark);
}

.key.yellow.active {
    box-shadow: 0 0 0 0 var(--yellow-dark);
}

.key.grey {
    color: var(--white);
    background-color: var(--grey-light);
    box-shadow: 0 .2rem 0 0 var(--grey-shadow);
}

.key.grey:active {
    box-shadow: 0 0 0 0 var(--grey-shadow);
}

.key.grey.active {
    box-shadow: 0 0 0 0 var(--grey-shadow);
}

.key.green {
    color: var(--white);
    background-color: var(--green-light);
    box-shadow: 0 .2rem 0 0 var(--green-dark);
}

.key.green:active {
    box-shadow: 0 0 0 0 var(--green-dark);
}

.key.green.active {
    box-shadow: 0 0 0 0 var(--green-dark);
}

/* ==================== */
/* POPUP STYLES */
/* ==================== */

.overlay {
    z-index: 20;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    display: none;
    position: fixed;
    inset: 0%;
    overflow: hidden;
}

.popup {
    z-index: 10;
    border: .3rem solid var(--grey-dark);
    background-color: var(--background);
    border-radius: .5rem;
    flex-flow: column;
    width: 30rem;
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    position: fixed;
}

.popup-section {
    grid-column-gap: 1.5rem;
    grid-row-gap: 1.5rem;
    border-top: .2rem solid var(--grey-dark);
    flex-flow: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 1.8rem 2rem;
    display: flex;
}

.popup-section.header {
    border-top-style: none;
}

/* ==================== */
/* TYPOGRAPHY */
/* ==================== */

.text-heading {
    font-size: 2.2rem;
    line-height: 1em;
}

.text {
    font-size: .9rem;
    font-weight: 400;
    line-height: 1.3em;
}

.text.no-wrap {
    white-space: nowrap;
}

.text.bold {
    font-size: 1.2rem;
    font-weight: 700;
}

.span-reveal {
    color: var(--green-light);
    font-weight: 700;
}

/* ==================== */
/* LAYOUT UTILITIES */
/* ==================== */

.space-between {
    grid-column-gap: 1rem;
    grid-row-gap: 1rem;
    justify-content: space-between;
    align-items: center;
    display: flex;
}

.space-between.fullwidth {
    width: 100%;
}

.content-center {
    grid-column-gap: .5rem;
    grid-row-gap: .5rem;
    text-align: center;
    flex-flow: column;
    justify-content: flex-start;
    align-items: center;
    display: flex;
}

/* ==================== */
/* DATA VISUALIZATION */
/* ==================== */

.bar-chart {
    background-color: var(--background);
    border-radius: .5rem;
    flex-flow: column;
    justify-content: space-around;
    align-items: stretch;
    width: 100%;
    height: 10rem;
    display: flex;
}

.bar-container {
    background-color: var(--grey-dark);
    border-radius: .3rem;
    flex-flow: column;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    height: 30%;
    display: flex;
}

.bar {
    background-color: var(--green-light);
    border-radius: .3rem;
    justify-content: center;
    align-items: flex-start;
    width: 33%;
    min-width: 2%;
    height: 100%;
    display: flex;
}

.average-wrapper {
    background-color: var(--grey-dark);
    border-radius: .3rem;
    justify-content: center;
    align-items: center;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
}

/* ==================== */
/* BUTTONS & CONTROLS */
/* ==================== */

/* Icon buttons */
.icon {
    height: 100%;
    width: 100%;
}

.icon_button {
    cursor: pointer;
    border-radius: .3rem;
    height: 3rem;
    width: 3rem;
    transition: all .1s;
    display: flex;
    align-content: center;
    justify-content: center;
    padding: .7rem;
}

.icon_button:hover {
    background-color: var(--grey-dark);
}

.icon_button:active {
    background-color: var(--grey-light);
    padding: .8rem;
}

/* Special buttons */
.key-reset {
    cursor: pointer;
    color: var(--white);
    background-color: var(--accent);
    border-radius: .3rem;
    justify-content: center;
    align-items: center;
    height: 2.5rem;
    padding-left: 0.8rem;
    padding-right: 0.8rem;
    font-size: 1.3rem;
    transition: all 0s linear;
    display: flex;
    transform: translate(0, -.3rem);
    box-shadow: 0 .3rem var(--accent-dark)
}

.key-reset:hover {
    filter: brightness(110%);
}

.key-reset:active {
    transform: translate(0);
    box-shadow: 0 0 var(--accent-dark)
}

/* ==================== */
/* ANIMATIONS */
/* ==================== */

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-0.3rem); }
    50% { transform: translateX(0.3rem); }
    75% { transform: translateX(-0.3rem); }
    100% { transform: translateX(0); }
}