/* Wordle Unlimited - Classic Wordle Style CSS */

/* Import clean fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Clear+Sans:wght@400;700&display=swap');

/* Root Variables - Classic Wordle Colors */
:root {
    --wordle-correct: #6aaa64;
    --wordle-present: #c9b458;
    --wordle-absent: #787c7e;
    --wordle-dark: #121213;
    --wordle-light: #ffffff;
    --wordle-gray: #d3d6da;
    --wordle-key-bg: #d3d6da;
    --wordle-border: #d3d6da;
    --wordle-text: #121213;
}

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

body {
    font-family: 'Clear Sans', 'Helvetica Neue', Arial, sans-serif;
    background: var(--wordle-light);
    color: var(--wordle-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--wordle-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 1s ease-out;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-text {
    font-family: 'Clear Sans', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--wordle-text);
    margin-bottom: 20px;
    letter-spacing: 0.05em;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--wordle-gray);
    border-top: 4px solid var(--wordle-correct);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Welcome Container */
.welcome-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--wordle-light);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

.welcome-container.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-title {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.welcome-letter {
    width: 60px;
    height: 60px;
    border: 2px solid var(--wordle-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    animation: flipIn 0.6s ease-out forwards;
    opacity: 0;
}

@keyframes flipIn {
    0% {
        transform: rotateY(90deg);
        opacity: 0;
    }
    100% {
        transform: rotateY(0);
        opacity: 1;
    }
}

.welcome-subtitle {
    font-size: 1.5rem;
    color: var(--wordle-absent);
    opacity: 0;
    transition: opacity 0.5s ease-out;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

/* Game Container */
.game-container {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.game-header {
    border-bottom: 1px solid var(--wordle-border);
    padding: 10px 20px;
    background: var(--wordle-light);
}

.header-content {
    max-width: 500px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-title {
    font-family: 'Clear Sans', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--wordle-text);
}

.home-link {
    text-decoration: none;
    color: inherit;
}

.stats-section {
    display: flex;
    gap: 15px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--wordle-absent);
    display: block;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--wordle-text);
}

/* Game Content */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
    padding-top: 80px; /* Space for minimal header */
}

/* Stats Display */
.stats-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
    width: 100%;
}

.stats-display .stat-item {
    text-align: center;
}

.stats-display .stat-label {
    font-size: 0.7rem;
    color: var(--wordle-absent);
    display: block;
    margin-bottom: 5px;
}

.stats-display .stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--wordle-text);
}

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.new-puzzle-btn {
    background: var(--wordle-correct);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-family: 'Clear Sans', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.new-puzzle-btn:hover {
    background: #5a9a54;
    transform: scale(1.05);
}

.new-puzzle-btn.button-pressed {
    transform: scale(0.95);
}

.how-to-play-btn {
    background: var(--wordle-light);
    color: var(--wordle-text);
    border: 1px solid var(--wordle-border);
    border-radius: 4px;
    padding: 8px 16px;
    font-family: 'Clear Sans', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.how-to-play-btn:hover {
    background: var(--wordle-gray);
}

/* Board Container */
.board-container {
    margin: 20px 0;
}

.board-container.new-puzzle-flash {
    animation: flash 1.5s ease-out;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Game Board */
#gameBoard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 20px;
}

.board-row {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.tile {
    width: 62px;
    height: 62px;
    border: 2px solid var(--wordle-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    user-select: none;
    transition: all 0.2s ease;
}

.tile.filled {
    border-color: var(--wordle-absent);
    animation: pop 0.1s ease-out;
}

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

.tile.revealed {
    color: white;
    border-color: transparent;
}

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

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

.tile.correct,
.tile.revealed.correct {
    background: var(--wordle-correct) !important;
    color: white;
}

.tile.present,
.tile.revealed.present {
    background: var(--wordle-present) !important;
    color: white;
}

.tile.absent,
.tile.revealed.absent {
    background: var(--wordle-absent) !important;
    color: white;
}

/* Keyboard */
.keyboard-container {
    width: 100%;
    max-width: 500px;
    margin: 20px auto 0;
}

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

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

.key {
    min-width: 43px;
    height: 58px;
    border-radius: 4px;
    border: none;
    background: var(--wordle-key-bg);
    color: var(--wordle-text);
    font-family: 'Clear Sans', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.1s ease;
    user-select: none;
    text-transform: uppercase;
}

.key:hover {
    background: #a8a8a8;
}

.key:active {
    transform: scale(0.95);
}

.key.key-wide {
    min-width: 65px;
    font-size: 0.75rem;
}

.key.correct {
    background: var(--wordle-correct);
    color: white;
}

.key.present {
    background: var(--wordle-present);
    color: white;
}

.key.absent {
    background: var(--wordle-absent);
    color: white;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.sound-toggle input[type="checkbox"] {
    appearance: none;
    width: 50px;
    height: 26px;
    background: var(--wordle-gray);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.sound-toggle input[type="checkbox"]:checked {
    background: var(--wordle-correct);
}

.sound-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.sound-toggle input[type="checkbox"]:checked::before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--wordle-text);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    color: var(--wordle-text);
}

.modal-body {
    margin-bottom: 20px;
    line-height: 1.6;
    color: var(--wordle-text);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-family: 'Clear Sans', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.modal-btn.primary {
    background: var(--wordle-correct);
    color: white;
}

.modal-btn.primary:hover {
    background: #5a9a54;
}

.modal-btn.secondary {
    background: var(--wordle-gray);
    color: var(--wordle-text);
}

.modal-btn.secondary:hover {
    background: #a8a8a8;
}

/* Stats Display */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.stat-box {
    text-align: center;
    padding: 10px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--wordle-text);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--wordle-absent);
    margin-top: 5px;
}

/* Distribution Chart */
.distribution-chart {
    margin-top: 15px;
}

.distribution-row {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.distribution-label {
    width: 20px;
    font-weight: 700;
    text-align: right;
    margin-right: 10px;
}

.distribution-bar-container {
    flex: 1;
    background: var(--wordle-gray);
    border-radius: 2px;
    overflow: hidden;
}

.distribution-bar {
    background: var(--wordle-correct);
    color: white;
    padding: 5px;
    min-width: 30px;
    text-align: right;
    font-weight: 700;
    font-size: 0.85rem;
}

/* New Puzzle Message */
.new-puzzle-message {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--wordle-correct);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 9999;
}

.new-puzzle-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

    .key {
        min-width: 32px;
        height: 48px;
        font-size: 0.75rem;
    }

    .key.key-wide {
        min-width: 50px;
        font-size: 0.65rem;
    }

    .site-title {
        font-size: 1.4rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 400px) {
    .tile {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

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

    .key.key-wide {
        min-width: 45px;
        font-size: 0.6rem;
    }
}
