/* Base styles */
:root {
    --tile-size: 35px;
    --keyboard-height: 200px;
    --key-bg-color: #818384;
    --key-text-color: #ffffff;
    --key-border-radius: 4px;
    --key-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: #121213;
    color: #ffffff;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    min-height: 100vh;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

.game-container {
    text-align: center;
    padding: 1rem;
    max-width: 600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 100vh;
    gap: 0.5rem;
}

h1 {
    font-size: 1.8rem;
    margin: 0.5rem 0;
    width: 100%;
}

#prompt {
    font-size: 1.1rem;
    margin: 1rem 0;
    color: #ccc;
    width: 100%;
    padding: 0 1rem;
}

/* Grid */
.grid {
    position: relative;
    width: 100%;
    height: auto;
    min-height: min-content;
    margin: 0.5rem 0;
    display: flex;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 1;
}

.carousel {
    position: relative;
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 800px;
    height: auto;
    min-height: min-content;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-y pinch-zoom;
    user-select: none;
}

.carousel.dragging {
    transition: none; /* Disable transition while dragging */
    cursor: grabbing;
}

.guess-container {
    position: relative;
    min-width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
    flex-shrink: 0;
    padding: 0.5rem 0;
}

.guess-container.previous {
    opacity: 0.3;
}

.guess-container.current {
    opacity: 1;
}

.guess-container.next {
    opacity: 0.3;
}

.grid-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 2px 0;
    flex-wrap: nowrap;
    min-height: 40px; /* Match tile height */
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    min-width: var(--tile-size);
    border: 2px solid #3a3a3c;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    font-weight: bold;
    font-size: calc(var(--tile-size) * 0.45);
    background-color: #121213;
    color: white;
    transition: all 0.3s ease;
}

.tile.correct {
    background-color: #538d4e;
    border-color: #538d4e;
}

.tile.present {
    background-color: #b59f3b;
    border-color: #b59f3b;
}

.tile.absent {
    background-color: #3a3a3c;
    border-color: #3a3a3c;
}

.space-tile {
    background-color: #3a3a3c !important;
    border: 2px solid #3a3a3c;
    pointer-events: none;
}

/* Animations */
@keyframes flip {
    0%   { transform: rotateY(0); }
    50%  { transform: rotateY(90deg); }
    100% { transform: rotateY(0); }
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.15s ease-in-out;
}

.bounce {
    animation: bounce 0.15s ease-in-out;
}  

/* Keyboard */
.keyboard {
    width: 100%;
    max-width: 600px;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-top: auto;
    background: transparent;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
    max-width: 584px;
}

.keyboard-row-indented {
    padding: 0 20px;
}

.key-spacer {
    flex: 0.5;
}

.key {
    background-color: var(--key-bg-color);
    color: var(--key-text-color);
    border: none;
    padding: 12px 8px;
    font-weight: bold;
    border-radius: var(--key-border-radius);
    cursor: pointer;
    font-size: 1.1rem;
    text-transform: uppercase;
    min-width: 32px;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    transition: all 0.1s ease;
}

.key:active {
    opacity: 0.9;
}

.key.correct {
    background-color: #538d4e;
}

.key.present {
    background-color: #b59f3b;
}

.key.absent {
    background-color: #3a3a3c;
}

.enter-key {
    flex: 1.5;
    font-size: 0.9rem;
}

.backspace-key {
    flex: 1.5;
}

.space-key {
    width: 50%;
    max-width: 200px;
    border-radius: 8px;
    height: 45px;
}

.space-row {
    margin-top: 4px;
}

.message {
    position: relative;
    z-index: 2;
    margin-top: 1rem;
    height: 1.5rem;
    color: #f87171;
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    :root {
        --tile-size: 28px;
    }

    .game-container {
        padding: 0.5rem;
        height: 100vh;
        justify-content: space-between;
        gap: 0.3rem;
    }

    h1 {
        font-size: 1.3rem;
        margin: 0.3rem 0;
    }

    #prompt {
        font-size: 0.95rem;
        margin: 0.3rem 0;
        padding: 0 0.5rem;
    }

    .grid {
        margin: 0.3rem 0;
        transform: scale(0.9);
        transform-origin: top center;
    }

    .guess-container {
        gap: 4px;
        padding: 0.3rem 0;
    }

    .keyboard {
        padding: 6px;
        gap: 6px;
    }

    .key {
        height: 42px;
        min-width: 28px;
        padding: 4px;
        font-size: 1.1rem;
    }

    .enter-key, .backspace-key {
        font-size: 0.9rem;
    }

    .space-key {
        height: 38px;
        font-size: 0.9rem;
    }
}

/* iPhone SE and other small devices */
@media (max-width: 380px) {
    :root {
        --tile-size: 24px;
    }

    .grid {
        transform: scale(0.85);
    }

    .key {
        height: 38px;
        min-width: 24px;
        padding: 3px;
        font-size: 1rem;
    }

    .enter-key, .backspace-key {
        font-size: 0.8rem;
    }

    .space-key {
        height: 34px;
        font-size: 0.8rem;
    }
}

/* Handle tall phones */
@media (min-height: 700px) and (max-width: 600px) {
    .game-container {
        justify-content: space-around;
    }

    .key {
        height: 52px;
    }
}

/* Landscape mode */
@media (max-height: 500px) {
    .game-container {
        padding: 0.3rem;
    }

    h1 {
        font-size: 1.2rem;
        margin: 0.2rem 0;
    }

    .grid {
        transform: scale(0.8);
    }

    .keyboard {
        gap: 3px;
    }

    .key {
        height: 38px;
        min-width: 32px;
        font-size: 0.9rem;
    }
}

/* Carousel Navigation */
.carousel-nav {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 1.5rem 0;
    z-index: 2;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3a3a3c;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.6;
}

.carousel-dot:hover {
    opacity: 0.8;
}

.carousel-dot.active {
    background-color: #ffffff;
    opacity: 1;
    transform: scale(1.2);
}

.carousel-dot.completed {
    background-color: #538d4e;
    opacity: 1;
}

/* Add Previous/Next buttons */
.carousel-controls {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    padding: 0 1rem;
    z-index: 3;
}

.carousel-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    pointer-events: auto; /* Re-enable clicking on buttons */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid:hover .carousel-button {
    opacity: 1;
}

.carousel-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.carousel-button:disabled {
    opacity: 0;
    cursor: default;
}

/* Hide buttons on touch devices */
@media (hover: none) and (pointer: coarse) {
    .carousel-button {
        display: none;
    }
}  
  