/* Thai Wordle Game Styles */

/* Main Container */
.wordle-main {
    min-height: calc(100vh - 80px - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: #F9FAFB;
}

.wordle-container {
    width: 100%;
    max-width: 1000px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
}

/* Screen Management */
.screen {
    display: none;
    padding: 3rem 2rem;
    min-height: 500px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* Setup Screen */
.setup-content {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.game-title {
    font-size: 3rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.5rem;
}

.game-subtitle {
    font-size: 1.25rem;
    color: #666;
    margin-bottom: 2rem;
    font-weight: 500;
}

.instructions-panel {
    background: #f9fafb;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.instructions-panel h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
}

.instructions-panel p {
    color: #666;
    margin-bottom: 1rem;
}

.color-guide {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.color-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.color-box.green {
    background: #22C55E;
}

.color-box.yellow {
    background: #F59E0B;
}

.color-box.gray {
    background: #9CA3AF;
}

.guide-item span {
    font-size: 0.938rem;
    color: #333;
    font-weight: 500;
}

/* Mode Selection */
.mode-selection {
    margin-bottom: 2rem;
}

.mode-selection h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #333;
}

.mode-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.mode-btn {
    padding: 1.25rem 1rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    text-align: left;
}

.mode-btn:hover {
    border-color: #3B82F6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.mode-btn.active {
    background: #3B82F6;
    border-color: #3B82F6;
    color: white;
}

.mode-name {
    font-size: 1.0625rem;
    font-weight: 700;
}

.mode-desc {
    font-size: 0.813rem;
    opacity: 0.85;
}

/* Buttons */
.game-btn {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 56px;
    font-family: inherit;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

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

.game-btn-primary {
    background: #3B82F6;
    color: white;
}

.game-btn-primary:hover {
    background: #2563EB;
}

.game-btn-secondary {
    background: #f3f4f6;
    color: #333;
}

.game-btn-secondary:hover {
    background: #e5e7eb;
}

/* Playing Screen */
.playing-content {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    margin-bottom: 1.5rem;
    width: 100%;
}

.header-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-icon {
    font-size: 1.25rem;
}

.stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: #333;
}

.difficulty-badge {
    padding: 0.5rem 1rem;
    background: #3B82F6;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 700;
}

/* Toast message */
.toast {
    position: relative;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.toast.show {
    background: #111827;
    color: white;
    font-weight: 700;
    font-size: 0.938rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-flex;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Word Grid */
.word-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.word-row {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.tile {
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #111827;
    text-transform: none;
    user-select: none;
    box-sizing: border-box;
}

.tile.filled {
    border-color: #9ca3af;
    animation: tilePop 0.1s ease;
}

.tile.correct {
    background: #22C55E;
    border-color: #22C55E;
    color: white;
}

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

.tile.absent {
    background: #9CA3AF;
    border-color: #9CA3AF;
    color: white;
}

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

.word-row.shake {
    animation: shake 0.5s ease;
}

@keyframes tilePop {
    0% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* Keyboard */
.keyboard {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.keyboard-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #9ca3af;
    margin-top: 0.5rem;
    align-self: flex-start;
}

.keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    justify-content: center;
}

.key {
    min-width: 2.1rem;
    height: 2.75rem;
    padding: 0 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    color: #111827;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 0 rgba(17, 24, 39, 0.08);
}

.key:hover {
    background: #E5E7EB;
    border-color: #D1D5DB;
}

.key:active {
    transform: translateY(2px);
    box-shadow: none;
}

.key.correct {
    background: #22C55E;
    border-color: #16A34A;
    color: white;
    box-shadow: 0 2px 0 #15803D;
}

.key.present {
    background: #F59E0B;
    border-color: #D97706;
    color: white;
    box-shadow: 0 2px 0 #B45309;
}

.key.absent {
    background: #6b7280;
    border-color: #4B5563;
    color: white;
    box-shadow: 0 2px 0 #374151;
}

/* Confirm / backspace get their own row so they read as clear, prominent
   actions instead of being squeezed next to the tiny tone-mark keys. */
.keyboard-action-row {
    width: 100%;
    max-width: 420px;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.key.action {
    height: 2.9rem;
    font-size: 0.938rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border-radius: 10px;
}

.key.action-back {
    flex: 1;
    max-width: 130px;
    background: #FFFFFF;
    color: #374151;
    border: 1px solid #D1D5DB;
    box-shadow: 0 2px 0 rgba(17, 24, 39, 0.08);
}

.key.action-back:hover {
    background: #F9FAFB;
    border-color: #9CA3AF;
}

.key.action-enter {
    flex: 2;
    background: #3B82F6;
    color: #FFFFFF;
    border: 1px solid #2563EB;
    box-shadow: 0 2px 0 #1D4ED8;
}

.key.action-enter:hover {
    background: #2563EB;
}

/* End Screen */
.end-content {
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.end-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

.end-title.victory {
    color: #10B981;
}

.end-title.gameover {
    color: #ef4444;
}

.secret-reveal {
    margin-bottom: 1.5rem;
}

.secret-reveal h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #666;
}

.secret-display {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.secret-tile {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    font-weight: 700;
    background: #3B82F6;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    animation: popIn 0.4s ease backwards;
}

.secret-tile:nth-child(1) { animation-delay: 0s; }
.secret-tile:nth-child(2) { animation-delay: 0.08s; }
.secret-tile:nth-child(3) { animation-delay: 0.16s; }
.secret-tile:nth-child(4) { animation-delay: 0.24s; }
.secret-tile:nth-child(5) { animation-delay: 0.32s; }

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

.share-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    line-height: 1;
}

.share-grid .share-row {
    letter-spacing: 0.1em;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #f9fafb;
    padding: 1.25rem 1rem;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
}

.stat-card-label {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #111827;
}

.end-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wordle-main {
        padding: 1rem 0.5rem;
    }

    .screen {
        padding: 2rem 1.5rem;
        min-height: 400px;
    }

    .game-title {
        font-size: 2.5rem;
    }

    .mode-buttons {
        grid-template-columns: 1fr;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .wordle-main {
        padding: 0.5rem 0.25rem;
        min-height: calc(100vh - 70px - 150px);
    }

    .wordle-container {
        border-radius: 16px;
    }

    .screen {
        padding: 1.5rem 1rem;
        min-height: 350px;
    }

    .game-title {
        font-size: 2rem;
    }

    .game-subtitle {
        font-size: 1rem;
    }

    .instructions-panel {
        padding: 1rem;
    }

    .header-stats {
        gap: 1rem;
        padding: 0.75rem;
    }

    .tile {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
        border-width: 2px;
    }

    .key {
        min-width: 1.7rem;
        height: 2.25rem;
        font-size: 0.875rem;
    }

    .keyboard-action-row {
        max-width: 100%;
    }

    .key.action {
        height: 2.6rem;
        font-size: 0.8rem;
    }

    .key.action-back {
        max-width: 100px;
    }

    .secret-tile {
        width: 40px;
        height: 40px;
        font-size: 1.125rem;
    }

    .end-title {
        font-size: 2.25rem;
    }

    .end-buttons {
        width: 100%;
    }

    .game-btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        min-height: 48px;
    }
}

/* Accessibility */
.game-btn:focus,
.mode-btn:focus,
.key:focus {
    outline: 3px solid #3B82F6;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    .wordle-main {
        display: none;
    }
}
