/**
 * Word Guess Game Styles
 * A Wordle-like 5-letter word guessing game
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    background: var(--color-bg, #FFF9E6);
    color: var(--color-text, #333);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 1rem;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.game-container {
    width: 100%;
    max-width: 400px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Header with stats */
.header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border, #ddd);
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text, #333);
}

.stats {
    display: flex;
    gap: 0.5rem;
}

.stat-box {
    background: var(--color-card-bg, #fff);
    border: 1px solid var(--color-border, #ddd);
    border-radius: var(--radius-sm, 8px);
    padding: 0.3rem 0.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-box .label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--color-text-light, #666);
    text-transform: uppercase;
}

.stat-box .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text, #333);
}

.best-streak {
    color: #538d4e;
    font-size: 0.8rem;
    font-weight: 600;
    min-height: 1rem;
}

/* Game Board - 6 rows of 5 tiles */
.board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 5px;
    padding: 10px 0;
}

.row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
}

/* Individual letter tiles */
.tile {
    width: 52px;
    height: 52px;
    border: 2px solid var(--color-border, #ddd);
    background: var(--color-card-bg, #fff);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text, #333);
    text-transform: uppercase;
    transition: transform 0.1s;
}

.tile.filled {
    border-color: var(--color-text-light, #666);
    animation: pop 0.1s ease;
}

.tile.revealed {
    animation: flip 0.5s ease forwards;
}

/* Letter feedback states - matches Wordle colors */
.tile.correct {
    background: #538d4e; /* Green - correct position */
    border-color: #538d4e;
    color: #fff;
}

.tile.present {
    background: #b59f3b; /* Yellow - wrong position */
    border-color: #b59f3b;
    color: #fff;
}

.tile.absent {
    background: #787c7e; /* Gray - not in word */
    border-color: #787c7e;
    color: #fff;
}

@keyframes pop {
    50% { transform: scale(1.1); }
}

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

/* Status messages */
.message {
    color: var(--color-text, #333);
    font-size: 0.9rem;
    min-height: 1.25rem;
    font-weight: 600;
}

.message.error {
    color: var(--color-accent, #FF6B6B);
}

/* On-screen Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 350px;
}

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

.key {
    min-width: 30px;
    height: 50px;
    border: none;
    border-radius: 4px;
    background: #d3d6da; /* Default unused key color */
    color: var(--color-text, #333);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    transition: background 0.1s, color 0.1s;
    flex: 1;
    max-width: 40px;
}

.key.wide {
    min-width: 50px;
    max-width: 60px;
    font-size: 0.75rem;
}

.key:active {
    background: #bbbfc4;
}

.key:focus-visible {
    outline: 2px solid var(--color-primary, #FFD93D);
    outline-offset: 2px;
}

/* Keyboard feedback states - match tile colors */
.key.correct {
    background: #538d4e;
    color: #fff;
}

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

.key.absent {
    background: #787c7e;
    color: #fff;
}

/* Game Over Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: var(--color-card-bg, #fff);
    padding: 2rem;
    border-radius: var(--radius-md, 12px);
    text-align: center;
    border: 1px solid var(--color-border, #ddd);
    box-shadow: var(--shadow-card-hover, 0 8px 20px rgba(0, 0, 0, 0.15));
    max-width: 90%;
}

.overlay-content h2 {
    font-size: 1.5rem;
    color: var(--color-text, #333);
    margin-bottom: 0.5rem;
}

.overlay-content h2.win {
    color: #538d4e;
}

.overlay-content h2.lose {
    color: var(--color-accent, #FF6B6B);
}

.overlay-content p {
    font-size: 1rem;
    color: var(--color-text-light, #666);
    margin-bottom: 1.5rem;
}

/* Share container for sharing results */
.share-container {
    margin-bottom: 1rem;
}

.restart-btn {
    background: var(--color-primary, #FFD93D);
    color: var(--color-text, #333);
    border: none;
    border-radius: var(--radius-sm, 8px);
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.restart-btn:hover {
    background: var(--color-primary-dark, #E6A700);
    transform: translateY(-1px);
}

.restart-btn:active {
    transform: translateY(0);
}

.restart-btn:focus-visible {
    outline: 3px solid var(--color-primary, #FFD93D);
    outline-offset: 2px;
}

/* Home link - uses main.css styles */
.home-link {
    margin-top: 0.5rem;
    color: var(--color-text-light, #666);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.home-link:hover {
    color: var(--color-text, #333);
    text-decoration: underline;
}

.home-link:focus-visible {
    outline: 2px solid var(--color-primary, #FFD93D);
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 360px) {
    .tile {
        width: 46px;
        height: 46px;
        font-size: 1.5rem;
    }

    .key {
        height: 45px;
        font-size: 0.75rem;
    }
}

@media (min-height: 700px) {
    body {
        align-items: center;
        padding-top: 0;
    }
}
