@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');

:root {
    --bg-color: #121213;
    --text-color: #ffffff;
    --header-bg: #ff7547;
    
    --key-bg: #9e9e9e; 
    --key-eval-correct: #00a550; 
    --key-eval-correct-light: #66c996;
    --key-eval-present: #ffc700; 
    --key-eval-absent: #3c3c3c; 
    
    --board-empty-border: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', arial, helvetica, sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    margin: 0 auto;
    position: relative;
}

header {
    width: 100%;
    height: 40px;
    background-color: var(--header-bg);
    color: white;
    text-align: center;
    padding-top: 2px;
    font-size: 26px;
    position: relative;
    z-index: 4;
}

#help-btn-header {
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#guess-counter {
    position: absolute;
    right: 5px;
    top: 0;
    color: white;
    font-size: 26px;
}

#board-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start; 
    overflow-y: auto;
    padding-top: 10px;
}

#board {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    max-width: 924px;
    padding: 0 5px;
    align-items: center;
}

.row {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
    position: relative;
    z-index: 10;
}

.row.slide-in {
    animation: slideDownRow 0.3s ease-out forwards;
    z-index: 0;
}

@keyframes slideDownRow {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}
.tile {
    width: 15vw;
    max-width: 150px;
    aspect-ratio: 150 / 126;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 9vw;
    text-transform: uppercase;
    border: 1px solid var(--board-empty-border);
    background-color: var(--key-eval-absent);
}

@media (min-width: 1000px) {
    .tile {
        font-size: 85px;
    }
}

.tile[data-state="tbd"] {
    background-color: transparent;
}

.tile[data-state="correct"] {
    background-color: var(--key-eval-correct);
    border-color: var(--board-empty-border);
}

.tile[data-state="present"] {
    background-color: var(--key-eval-present);
    border-color: var(--board-empty-border);
}

.tile[data-state="absent"] {
    background-color: var(--key-eval-absent);
    border-color: var(--board-empty-border);
}

/* Animations */
.tile.pop {
    animation: pop 0.1s linear 1;
}

@keyframes pop {
    from { transform: scale(0.8); opacity: 0; }
    40% { transform: scale(1.1); opacity: 1; }
}

.tile.flip {
    animation: flip 0.5s ease-in;
}

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0); }
}

.row.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Keyboard */
#keyboard-container {
    padding: 0 5px 0px;
    user-select: none;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

#keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.key {
    background-color: var(--key-bg);
    color: white;
    border: 1px solid white;
    border-radius: 12px;
    font-size: 6vw;
    cursor: pointer;
    text-transform: uppercase;
    flex: 0 1 9%;
    height: 13vw;
    max-height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (min-width: 900px) {
    .key {
        font-size: 55px;
        height: 90px;
    }
}

.key.large {
    flex: 0 1 13.5%;
    font-size: 4vw;
}

@media (min-width: 900px) {
    .key.large {
        font-size: 35px;
    }
}

.key.large[data-key="Backspace"] {
    background-color: #ff595e; 
}
.key.large[data-key="Enter"] {
    background-color: #8b9dc3;
}

.key[data-state="correct"] {
    background-color: var(--key-eval-correct);
}

.key[data-state="present"] {
    background-color: var(--key-eval-present);
}

.key[data-state="absent"] {
    background-color: var(--key-eval-absent);
}

/* Modals */
#message-toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background-color: red;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-size: 24px;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.3s;
}

#message-toast.hidden {
    opacity: 0;
}

#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: black;
    padding: 20px;
    border-radius: 8px;
    width: 95%;
    max-width: 400px;
    z-index: 101;
    display: flex;
    flex-direction: column;
    align-items: center;
    
    animation: ShareFrameAni 1.8s ease-in-out;
}

@keyframes ShareFrameAni {
    0%  {
        opacity: 0.0;
        top: 100%;
        left: 50%;
        transform: translate(-50%, 0%);
    }
    100%  {
        opacity: 1.0;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}

.modal.hidden, #modal-overlay.hidden {
    display: none;
}

.close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

#stats-word-container {
    display: flex;
    gap: 4px;
    margin-bottom: 15px;
    margin-top: 25px;
}
#stats-word-container .tile {
    width: 48px;
    height: 62px;
    font-size: 2.2rem;
    border: none;
    background-color: var(--key-eval-correct);
    color: white;
}

.share-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}
.share-actions button {
    background: #8b9dc3;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
}

#stats-graph {
    width: 100%;
    margin-bottom: 10px;
    position: relative;
}
.bar-container {
    height: 100px;
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    align-items: flex-end;
}
.bar-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    height: 100%;
    cursor: pointer;
}
.bar {
    width: 100%;
    max-width: none;
    background: var(--key-eval-correct);
    transition: height 0.3s ease;
}
.guess-labels {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    text-align: center;
    background: black;
    color: white;
    padding: 3px 0;
    margin-top: 0;
    font-size: 18px;
}
.guess-labels span {
    cursor: pointer;
}
.line {
    height: 2px;
    background: var(--key-eval-correct);
    width: 100%;
}

.stats-text {
    font-size: 1rem;
    margin-bottom: 15px;
    text-align: center;
}
.next-game-text {
    font-size: 1.2rem;
}

.bouncy {
    animation: bouncy 7s infinite linear;
    position: relative;
}
@keyframes bouncy {
    0%{top:0em}
    40%{top:0em}
    43%{top:-0.9em}
    46%{top:0em}
    48%{top:-0.4em}
    50%{top:0em}
    100%{top:0em;}
}

.bouncy-word-container {
    display: flex;
    gap: 2px;
    margin-bottom: 25px;
    margin-top: 10px;
}
.bouncy-word-container .tile {
    width: 25px;
    height: 25px;
    line-height: 25px;
    font-size: 1.2rem;
    border: none;
    background-color: var(--key-eval-correct);
    color: white;
}

#update-uuid-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

#close-history-btn, #close-help-btn {
    background: #eeeeee;
    border: 1px solid #666;
    padding: 10px 24px;
    border-radius: 2px;
    color: black;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 15px;
}
