* {
    margin:0;
    padding: 0;
}

:root {
    --default: #121213;
    --grey-tone-10: #d3d6da;
    --grey-tone-15: #d7dadc;
    --grey-tone-20: #aaa;
    --grey-tone-30: #818384;
    --grey-tone-90: #3a3a3c;
    /* --yellow: #b59f3b; */
    --yellow: #f0e373;
    --light-red: #ffabaf;
    /* --green: #538d4e; */
    --green: #aaed61;
    --dark-green: #538d4e;
    --black: #000;
    --white: #fff;
    --gainsboro: #dcdcdc;
    --light-dark: #121213;
    --icon-filter-grey: invert(88%) sepia(100%) saturate(10%) hue-rotate(27deg) brightness(60%) contrast(60%);

    /* defaults */
    --text-color: var(--gainsboro);
    --line-color : var(--grey-tone-90);
    --bg-color : var(--black);

    /* popup */
    --popup-button-color: var(--grey-tone-20);
    --popup-button-hover-color: var(--white);
    --popup-bg-color: var(--light-dark);

    /* notifications */
    --notif-text-color: var(--default);
    --notif-bg-color: var(--grey-tone-10);

    /* board */
    --tile-line-color: var(--grey-tone-90);
    --tile-yellow: var(--yellow);
    --tile-green: var(--green);
    --tile-red: var(--light-red);
    --tile-grey: var(--grey-tone-90);
    --tile-light-grey: var(--grey-tone-15);

    /* keyboard */
    --key-color : var(--grey-tone-15);
    --key-bg-color : var(--grey-tone-30);

}

html, body {
    height: 100%;
    font-family: 'IBM Plex Sans KR', 'Noto Sans', 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
}



#container {
    display: flex;
    height: 90%;
    align-items: center;
    flex-direction: column;
}





/*HEADER*/

header {
    border-bottom: 1px solid var(--line-color);

    display: flex;
    justify-content: space-between;
    align-items: center;
    /* background-color: #4CAF50; Green background */
    /* color: white; */
}

.menu {
    display: flex;
    color: white;
    align-items: center;
    margin: 10px 10%;
    gap: 50px;
}

.menu .item {
    display: block;
    
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    text-underline-offset: 6px;
    /* text-decoration: underline; */
}

a:link, a:visited, a:hover, a:active {
    color:white
}

.title {
    color: var(--text-color);
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0.4rem 0;
    text-align: center;
    font-family: 'IBM Plex Sans KR', 'Noto Sans', 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;

    /* OA */
    flex-grow: 1; /* This allows the title to take up available space */
    /* margin: 0; Remove default margin */
    position: absolute;
    left: 50%;
    transform: translateX(-50%); /* Center the title horizontally */
    margin: 0;

    line-height: 25px;
    padding-top: 10px;
}

#puzzle-number {
    font-size: 20px;
    margin-top: 10px;
}

#help-button {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    
    /*OA*/
    margin-left: auto; /* Push the button to the right */
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#stat-button {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    
    /*OA*/
    margin-right: auto; /* Push the button to the right */
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}


/*POPUP*/

.popup-background {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    background-color: rgba(0, 0, 0, 0.5); /* Black with opacity */

    overflow-y: auto; /* Enable vertical scrolling */

    color: var(--text-color)

}

.popup {
    background-color: var(--popup-bg-color);
    margin: 70px auto 15% ; /* 15% from the top and centered */
    padding: 20px 40px;
    /* border: 1px solid #888; */
    /* width: 80%; Could be more or less, depending on screen size */
    font-weight: 200;
}

.popup h1 {
    text-align: center;
    margin-bottom: 10px;
}

.popup h2 {
    margin-bottom: 10px;
    font-weight: 400;
    font-size: 28px;
    line-height: 30px;
    text-align: left;
}

.popup h3 {
    font-weight: 300;
    font-size: 20px;
    line-height: 24px;
}

.popup-section {
    width: 100%;
    margin: 20px auto;
    padding-top: 20px;
    border-top: 1px solid white;
}

.popup-section .statistics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 4px;
}

.popup ul {
    font-size: 16px;
    line-height: 26px;
    font-weight: 200;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    margin-block-start: 1em;
    -webkit-margin-after: 1em;
    margin-block-end: 1em;
    -webkit-padding-start: 20px;
    padding-inline-start: 20px;
}

.popup ul li {
    margin-bottom: 6px;
}

.popup .board-container {
    justify-content: left;
}

.popup .board-container .board {
    padding: 10px 0px;
}

.popup section#stat-next {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.popup section .stat-popup-subtitle {
    font-size: 20px;
    /* border-top: 1px solid white; */
}

.popup .logo {
    width: 100%;
}

.popup .logo img {
    display:block; 
    margin: 0 auto 10px;
}

.popup .stat-item .stat-title {
    font-size: 1rem;
}

.copyright {
    font-size: small;
}


.close-popup {
    display: flex;
}

.close-popup-button {
    margin-left: auto;
    color: var(--popup-button-color);
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-popup-button:hover,
.close-popup-button:focus {
    color: var(--popup-button-hover-color);
    text-decoration: none;
    cursor: pointer;
}



/*ALERT NOTIFICATIONS*/
.notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s ease;
    background-color: var(--notif-bg-color);
    color:var(--notif-text-color);
}

/*GAME*/

.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
    min-height: 300px;
}

.board {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 300px;
    height: 300px;
    /* gap: 10px; */
    position: relative;
    margin: 0 auto;
}

.history {
    /* height: 100px; */
    margin: 60px auto 0;
    display: flex;
    gap: 50px;
}

.history:has(.miniboard:only-child) {
    justify-content: center;
}

.miniboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 50%;
    /* height: 100px; */
    gap: 0;
    position: relative;
    /* margin: 0 auto; */
}

.miniboard .cell {
   /* width: 30px; */
   /* height: 30px; */

   border: 1px dotted var(--tile-line-color);
   min-width: 30px;
   min-height: 30px;
   font-size: 1.2rem;
   font-weight: 500;
   color: var(--text-color);
   text-transform: uppercase;

   display: flex;
   justify-content: center;
   align-items: center;

   position: relative;
   color: var(--grey-tone-90);
   animation: reveal 0.8s ease-in-out;
}

.board-container .card {
   width: 80px;
   height: 80px;
   color: var(--grey-tone-90);

   border: 1px solid black;
   border-radius: 5px;
   line-height: 80px;
   font-size: 36px;
   font-weight: bold;
   user-select: none;
   /* transform: translate(0, 0); */
   transition: transform 0.2s ease, top 0.5s, left 0.5s ease;
   position: absolute;
   top: 110px; /* Centralized start position */
   left: 110px; /* Centralized start position */
   display: flex;
   justify-content: center;
   align-items: center;
   text-align: center;
}

.board-container .slot {
   width: 78px;
   height: 78px;
   background-color: black;
   border: 2px dashed grey;
   border-radius: 5px;
   text-align: center;
   line-height: 80px;
   font-size: 20px;
   font-weight: bold;
   user-select: none;
   position: absolute;
   display: flex;
   justify-content: center;
   align-items: center;
   text-align: center;
}

.card.dragging {
  position: absolute;
  z-index: 10;
  opacity: 0.8;
  pointer-events: none;
}

#info {
    height: 100px;
    width : 50%;
    margin: 0 auto;
    text-align: center;
    color: white;
}


.popup-section .board-container .board {
    scale:75%;
    margin: 0;
    transform-origin: 0 40px;
}

.board-container .info {
    width: 80px;
    height: 80px;
    color: var(--white);
    line-height: 80px;
    font-size: 20px;
    font-weight: 300;
    user-select: none;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
 }





.character-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1px;
    height: 4px;

    /* grid-template-columns: repeat(5, 1fr); */
    /* grid-gap: 2px; */
    /* height: 10px; */
    /* grid-row-gap: 2px; */
    /* padding: 8px 4px 1px 4px; */
}

.character-hint div {
    border-radius:50%;
    height: 9px;
    width: 9px;

}

#game {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.guess-number {
    color: gainsboro;
    padding: 10px;
    font-size: 1em;
    font-weight: 300;
}

.square {
    border: 2px solid var(--tile-line-color);
    min-width: 80px;
    min-height: 80px;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-color);
    text-transform: uppercase;

    display: flex;
    justify-content: center;
    align-items: center;

    position: relative;
    /* display: inline-block; */
}

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

.cell.red {
    background-color: var(--tile-red);
}

.card.default {
    background-color: var(--grey-tone-15);
    cursor: grab;
    /* background-color: lightgrey; */
}

.card.green {
    background-color: var(--tile-green);
        -o-animation: fadeInGreen 0.3s ease-in-out, reveal 0.3s ease; 
            animation: fadeInGreen 0.3s ease-in-out, reveal 0.3s ease; 
    cursor: default;
}

.card.red {
    /* animation: fadeRed 300ms ease-in-out; */
    background-image:none !important; 
         -o-animation: fadeRed 1000ms ease-in-out, shake 0.3s ease; 
            animation: fadeRed 1000ms ease-in-out, shake 0.3s ease; 
    /* background-color: var(--tile-red); */
}

.card.yellow {
    background-color: var(--tile-yellow);
    cursor: default;
}

.card.revealed {
    transform: scale(110%);
    -o-animation: zoomIn 0.2s ease-in-out; 
       animation: zoomIn 0.2s ease-in-out; 
}

.square.partial-grey {
    border-color: var(--tile-grey);
}
  
.square.partial-yellow {
    border-color: var(--tile-yellow);
}

.square.partial-green {
    border-color: var(--tile-green);
}

.jamo-count {
    color: var(--grey-tone-90);
}

.hidden {
    display: none;
}

#keyboard-container {
    /* height:500px; */
    width: 70%;
    margin-right:auto;
    margin-left: auto;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    /* width: 90%; */
    margin: 0 auto 6px;
    touch-action: manipulation;
    gap:50px;
}

.keyboard-row button {
    font-family: inherit;
    font-weight: 500;
    font-size: 1.4rem;
    padding: 0;
    height: 76px;
    width: 76px;
    cursor: pointer;
    border: 2px solid var(--key-bg-color);
    background-color: black;
    /* background-color: rgb(129, 131, 132); */
    /* background-color: var(--key-bg-color); */
    /* color: rgb(215, 218, 220); */
    color: var(--key-color);
    flex-grow: 1;
    text-transform: uppercase;
    margin: 2px 5px;
    border-radius: 45px;
    user-select: none;
}

.keyboard-row button.wide-button {
    flex-grow: 1.5;
}

.spacer-half {
    flex-grow: .5;
}

#definitions {
    height: 210px;
    display: none;
    color: white;
    gap: 10px;
    flex-direction: column;
    text-underline-offset: 5px;
    align-items: center;
    padding-bottom: 100px;
}


.hide {
    opacity: 0;
    transition: opacity 0.5s linear;
    }


@media (max-height: 630px) {
    .history {
        min-height: 66px;
        margin-top: 18px;
    }
    .miniboard {
        max-height: 66px;
    }
    .miniboard .cell {
        min-width: 20px;
        min-height: 20px;
        font-size: 0.8rem;
    }
    #info {
        min-height: 30px;
    }
    #keyboard-container {
        min-height: 100px;
    }
    .keyboard-row button {
        height: 48px;
    }
    #container {
        height: 80%;
    }
}

@media (min-height: 631px) {
    .history {
        min-height: 66px;
        margin-top: 18px;
    }
    .miniboard {
        max-height: 66px;
    }
    .miniboard .cell {
        min-width: 20px;
        min-height: 20px;
        font-size: 0.8rem;
    }
    .board-container {
        min-height: 340px;
        max-height: 500px;
    }
    #info {
        min-height: 30px;
    }
    #keyboard-container {
        min-height: 100px;
    }
    .keyboard-row button {
        height: 48px;
    }
    #container {
        height: 80%;
    }
}

@media (min-height: 721px) {
    .history {
        min-height: 100px;
        margin-top: 38px;
    }
}

@media (min-height: 841px) {
    .history {
        margin-top: 60px;
    }
    .miniboard .cell {
        min-width: 24px;
        min-height: 24px;
        font-size: 1rem;
    }
    #keyboard-container {
        min-height: 160px;
    }
    #container {
        height:90%;
    }
}

@media (min-height: 981px) {
    .history {
        margin-top: 100px;
    }
    .miniboard .cell {
        min-width: 28px;
        min-height: 28px;
        font-size: 1.2rem;
    }
    #keyboard-container {
        height: 210px;
    }
}

@media (min-width: 570px) {
    .popup {
        width:60%;
    }
}

@media (max-width: 420px) {
    .history {
        gap: 20px;
    }

    .popup-section .statistics {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 380px) {
    .popup-section .board-container .board{
        scale: 0.7;
    }

    .popup-section .statistics {
        grid-template-columns: repeat(2, 1fr);
    }
    /* .popup .stat-item .stat-title {
        font-size: 0.7rem;
    } */
    
}

@media (max-width: 350px) {
    .popup-section .board-container .board{
        scale: 0.6;
    }
    .miniboard {
        height: 60px;
    }
    .miniboard .cell {
        min-width:20px;
        min-height:20px;
        font-size: 1rem;
    }
}

@media (max-width: 310px) {
    .popup-section .board-container .board{
        scale: 0.5;
    }
}

@keyframes fold {
    0% {
        transform: scaleX(1);
    }

    100% {
        transform: scaleX(0);
    }
}

@keyframes reveal {
    0% {
        transform: scaleX(0);
    }

    100% {
        transform: scaleX(1);
    }
}

@keyframes fadeInGreen {
    0% { background-color: var(--tile-light-grey); }
    100% { background-color: var(--tile-green); }
}

@keyframes fadeRed {
    0% { background-color: var(--tile-light-grey); }
    1% { background-color: var(--tile-red); }
    100% { background-color: var(--tile-light-grey); }
}

@keyframes zoomIn {
    0% { transform: scale(1); }
    60% { transform: scale(130%); }
    100% { transform: scale(110%); }
}

.foldIt {
    animation: fold 200ms ease-in;
    transform: scaleX(0);
}

.revealIt {
    animation: reveal 300ms ease-out;
    transform: scaleX(1);
}

@keyframes shake {
    0% { transform: translateX(0) }
    20% { transform: translateX(5px) }
    40% { transform: translateX(-5px) }
    60% { transform: translateX(5px) }
    80% { transform: translateX(-5px) }
    100% { transform: translateX(0) }
}

.shakeIt {
    animation: shake 0.3s ease;
}

@keyframes beat {
    0% { transform: scale(1.1) }
    100% { transform: scale(1) }
}

.beatIt {
    animation: beat .2s ease;
}

.icon {
    filter: var(--icon-filter-grey);
}

/* .header-button:hover {
    background-color: #ddd; 
} */


/* Basic button style for the link */
a.button-link {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--popup-button-color);
    color: var(--popup-button-color);
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s ease;
    margin-top: 20px auto;
}

a.button-link#share-button {
    background-color: var(--dark-green);
    color: var(--white);
    border: none;
}

/* Hover effect for the button */
a.button-link:hover {
    border-color: var(--popup-button-hover-color);
    color: var(--popup-button-hover-color);
    transform: scale(1.05);       /* Slightly increase the size on hover */
}