/* general */
:root {
    --background-light: #f9f9f9;
    --background-dark: #222;
    --text-light: #333;
    --text-dark: #eee;
}

html {
    height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    margin: 0;
    min-height: 100vh;
    background: #f0f2f5;
}

/* Dark theme styles */
body.dark-mode {
    background-color: #111;
    color: var(--text-dark);
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem 2rem;
    box-sizing: border-box;
}

/* intro panel */
#intro {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 0;
    text-align: center;
    opacity: 1;
    transition: opacity 0.35s ease;
}

#intro.fade-out {
    opacity: 0;
}

#intro #instructions {
    max-width: 720px;
    width: 100%;
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 24px 60px rgba(0,0,0,0.25);
    color: #111;
}

.dark-mode #intro #instructions {
    background: rgba(34,34,34,0.96);
    color: #eee;
}

#intro #canvas-container {
    display: flex;
    align-items: center;
}

/* help popup */
#help {
    background: rgba(249, 249, 249, 0.96);
    display: none;
    position: fixed;
    z-index: 1000; /* in front of current letter */
    top: 1.5rem;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 1.5em;
    overflow-y: auto;
    box-sizing: border-box;
    width: min(100%, 720px);
    max-height: calc(100vh - 3rem);
    border: 1px solid #ccc;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    backdrop-filter: blur(8px);
}

#help::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: -1;
}

.dark-mode #help {
    background: rgba(34, 34, 34, 0.96);
    border-color: #444;
}

#help {
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 120, 120, 0.7) rgba(40, 40, 40, 0.15);
}

#help::-webkit-scrollbar {
    width: 10px;
}

#help::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 999px;
}

#help::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 120, 0.6);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.dark-mode #help::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
}

.dark-mode #help::-webkit-scrollbar-thumb {
    background: rgba(180, 180, 180, 0.4);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 40px;
  }

.button {
    font-size: 18px;
    border-radius: 1.5em;
    padding: 10px 16px;
    margin: 0 10px 8px;
    min-width: 5em;
}

.button {
    color: black;
    background: white;
    border: 1px solid #333;
}

.dark-mode .button {
    color: white;
    background: black;
    border: 1px solid #777;
}

/* game play */
#content {
    display: none;
    text-align: center;
    width: 100%;
    background: rgba(255,255,255,0.96);
    border-radius: 20px;
    padding: 2rem;
    margin-top: 1.5rem;
    box-sizing: border-box;
    box-shadow: 0 20px 50px rgba(0,0,0,0.12);
}

.dark-mode #content {
    background: rgba(34,34,34,0.96);
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

@media (max-width: 520px) {
    .container {
        padding: 1rem 0.75rem 1rem;
    }

    #content {
        padding: 1.2rem;
        margin-top: 1rem;
    }

    #intro #instructions {
        padding: 1.2rem;
    }

    #header {
        font-size: 30px;
    }

    #header img {
        width: 26px;
        margin-left: 8px;
    }

    #belowBoard {
        margin-top: 0.75rem;
    }
}

@media (max-height: 720px) {
    body {
        min-height: 100vh;
    }

    #content {
        max-height: calc(100vh - 170px);
        overflow-y: auto;
    }
}

#header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    z-index: 2;
    margin: 0 0 1rem;
    font-family: 'Pacifico', cursive;
    font-size: 36px;
    font-weight: bold;
}

#header .title {
    flex-shrink: 0;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
}

#header img {
    width: 30px;
    height: auto;
    max-width: 32px;
    flex-shrink: 0;
    margin: 0 0 0 10px;
    cursor: pointer;
}

.board {
    display: grid;
    justify-content: center;
    position: relative;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(0,0,0,0.24);
    border-radius: 14px;
    box-sizing: border-box;
    padding: 4px;
    background-image: linear-gradient(
        to bottom,
        transparent 24.8%,
        rgba(0,0,0,0.22) 25%,
        rgba(0,0,0,0.22) 25.2%,
        transparent 25.2%,
        transparent 49.8%,
        rgba(0,0,0,0.22) 50%,
        rgba(0,0,0,0.22) 50.2%,
        transparent 50.2%,
        transparent 74.8%,
        rgba(0,0,0,0.22) 75%,
        rgba(0,0,0,0.22) 75.2%,
        transparent 75.2%,
        transparent 100%
    );
    background-repeat: no-repeat;
}

.dark-mode .board {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.28);
    background-image: linear-gradient(
        to bottom,
        transparent 24.8%,
        rgba(255,255,255,0.28) 25%,
        rgba(255,255,255,0.28) 25.2%,
        transparent 25.2%,
        transparent 49.8%,
        rgba(255,255,255,0.28) 50%,
        rgba(255,255,255,0.28) 50.2%,
        transparent 50.2%,
        transparent 74.8%,
        rgba(255,255,255,0.28) 75%,
        rgba(255,255,255,0.28) 75.2%,
        transparent 75.2%,
        transparent 100%
    );
    background-repeat: no-repeat;
}

.currentLetter {
    margin: 0 auto;
    font-weight: bold;
    text-align: center;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

.drop-animation {
    position: fixed;
    z-index: 9999;
    transition: left 0.28s ease-out, top 0.42s cubic-bezier(0.46,0.03,0.52,0.96), opacity 0.2s ease;
    pointer-events: none;
}

.dropAnimation {
    animation-name: drop;
    animation-duration: 1s;
}

@keyframes drop {
    50% {
        transform: translate(60px);
    }

    to {
        transform: translate(60px,140px);
    }
}

.tile {
    color: white;
    font-weight: bold;
    border: 1px solid gray;
    text-align: center;
    text-transform: uppercase;
    box-sizing: border-box; /* to prevent "available" from shifting the box */
    background: rgba(255,255,255,0.06);
}

.dark-mode .tile {
    background: rgba(255,255,255,0.04);
}

.currentTile {
    color: black;
}

.dark-mode .currentTile {
    color: white;
}

.available {
    border: 4px solid green;
}

.dark-mode .filled {
    background: #4a4a4a;
    border: 4px solid #4a4a4a;
}

.filled {
    background: #999;
    border: 4px solid #999;
}

.dark-mode .correct {
    background: #007700;
    border: 4px solid #007700;
}

.correct {
    background: #119911;
    border: 4px solid #119911;
}

.filled {
    animation-name: pulse;
    animation-duration: .25s;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }
    50% {
        transform: scale(1.25);
    }
    to {
        transform: scale(1);
    }
}

.theme-small {
    font-variant: small-caps; 
    font-size: 1em;
    left: 0; 
    right: 0; 
    margin-left: auto; 
    margin-right: auto; 
}

/* revealed theme at top */
#theme {
    position: absolute;
    left: 0; 
    right: 0; 
    margin-left: auto; 
    margin-right: auto; 
    font-variant: small-caps; 
    font-size: 1.5em;
}

/* various messages */
#tryAgainContent, #congratulationsContent, #theme, #timer, #belowBoard {
    display: none;
    padding: 10px;
}

#belowBoard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 0 10px 10px;
}

#belowBoard #timer {
    margin: 0;
}

#belowBoard .button {
    margin: 0;
}

#congratulationsContent span {
    font-weight: bold;
}
