/* ========================================
   WORDLE BLOUM - STYLES
   ======================================== */

/* Variables */
:root {
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --bg-light: #1a1a24;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    
    /* Aurora colors */
    --aurora-cyan: #00d9ff;
    --aurora-purple: #a855f7;
    --aurora-pink: #ec4899;
    --aurora-green: #10b981;
    
    /* Wordle colors */
    --correct: #10b981;
    --present: #eab308;
    --absent: #3f3f46;
    --tile-border: #3a3a4a;
    --tile-empty: #1a1a24;
    
    /* Keyboard */
    --key-bg: #2a2a3a;
    --key-hover: #3a3a4a;
    
    --font-main: 'Inter', sans-serif;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   BACKGROUND
   ======================================== */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image: 
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

.floating-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: var(--aurora-cyan);
    top: -100px;
    left: -100px;
    animation: float1 20s ease-in-out infinite;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: var(--aurora-purple);
    bottom: -50px;
    right: -50px;
    animation: float2 25s ease-in-out infinite;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: var(--aurora-pink);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: float3 15s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(100px, 100px); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-80px, -80px); }
}

@keyframes float3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.3); }
}

/* ========================================
   GAME WRAPPER
   ======================================== */
.game-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 500px;
    margin: 0 auto;
    padding: 10px;
}

/* ========================================
   HEADER
   ======================================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.back-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--aurora-cyan);
}

.game-logo {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: var(--transition);
}

.icon-btn:hover {
    transform: scale(1.1);
}

/* ========================================
   SCREENS
   ======================================== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

/* ========================================
   MENU SCREEN
   ======================================== */
.menu-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.menu-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.title-glow {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple), var(--aurora-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 0 40px rgba(0, 217, 255, 0.3);
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1rem;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.btn-primary, .btn-secondary {
    padding: 15px 30px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 217, 255, 0.3);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: var(--key-hover);
}

.btn-primary small, .btn-secondary small {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
}

.btn-glow {
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 217, 255, 0.3); }
    50% { box-shadow: 0 0 40px rgba(0, 217, 255, 0.5); }
}

/* Instructions */
.instructions {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    text-align: left;
}

.instructions h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--aurora-cyan);
}

.instruction-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.instruction .icon {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
}

/* Leaderboard */
.leaderboard-preview, .leaderboard-full {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: left;
}

.leaderboard-preview h3, .leaderboard-full h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: var(--aurora-purple);
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 0.9rem;
}

.leaderboard-item.highlight {
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid var(--aurora-cyan);
}

.leaderboard-rank {
    font-weight: 700;
    min-width: 25px;
    color: var(--aurora-cyan);
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-name {
    flex: 1;
    font-weight: 500;
}

.leaderboard-score {
    font-weight: 600;
    color: var(--correct);
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* ========================================
   GAME SCREEN
   ======================================== */
.game-screen {
    padding: 10px 0;
}

.game-mode-indicator {
    text-align: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    gap: 10px;
}

#modeLabel {
    color: var(--aurora-cyan);
    font-weight: 500;
}

#puzzleNumber {
    color: var(--aurora-purple);
    font-weight: 600;
}

/* Grid */
.grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 6px;
}

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

.tile {
    width: 58px;
    height: 58px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid var(--tile-border);
    background: var(--tile-empty);
    border-radius: 8px;
    transition: transform 0.1s ease;
    user-select: none;
}

.tile.filled {
    border-color: rgba(255, 255, 255, 0.3);
    animation: pop 0.1s ease;
}

.tile.correct {
    background: var(--correct);
    border-color: var(--correct);
    color: white;
}

.tile.present {
    background: var(--present);
    border-color: var(--present);
    color: white;
}

.tile.absent {
    background: var(--absent);
    border-color: var(--absent);
    color: white;
}

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

.tile.shake {
    animation: shake 0.5s ease;
}

.tile.bounce {
    animation: bounce 0.5s ease;
}

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

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

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

@keyframes bounce {
    0%, 20% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    50% { transform: translateY(0); }
    60% { transform: translateY(-10px); }
    80% { transform: translateY(0); }
    90% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

/* Message */
.message {
    text-align: center;
    padding: 10px;
    margin: 0 20px 10px;
    border-radius: 8px;
    font-weight: 600;
    background: var(--bg-card);
    animation: fadeIn 0.3s ease;
}

.message.hidden {
    display: none;
}

.message.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.message.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--correct);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Keyboard */
.keyboard {
    padding: 0 5px;
}

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

.key {
    min-width: 30px;
    height: 50px;
    padding: 0 10px;
    background: var(--key-bg);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.key:hover {
    background: var(--key-hover);
}

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

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

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

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

.key.absent {
    background: var(--absent);
    color: var(--text-muted);
}

/* ========================================
   RESULT SCREEN
   ======================================== */
.result-screen {
    padding: 20px;
    overflow-y: auto;
}

.result-content {
    text-align: center;
}

.result-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-title.lose {
    background: linear-gradient(135deg, #ef4444, #f97316);
    -webkit-background-clip: text;
    background-clip: text;
}

.result-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.result-word {
    background: var(--bg-card);
    padding: 15px 25px;
    border-radius: var(--border-radius);
    display: inline-block;
    margin-bottom: 20px;
}

.result-word span {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.result-word strong {
    font-size: 1.5rem;
    letter-spacing: 5px;
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
}

.result-row {
    display: flex;
    gap: 4px;
}

.result-tile {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.result-tile.correct { background: var(--correct); }
.result-tile.present { background: var(--present); }
.result-tile.absent { background: var(--absent); }

/* Save Score Form */
.save-score-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 15px;
}

.pseudo-input {
    padding: 12px 15px;
    border: 2px solid var(--tile-border);
    border-radius: 8px;
    background: var(--bg-light);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 1rem;
    width: 150px;
    transition: var(--transition);
}

.pseudo-input:focus {
    outline: none;
    border-color: var(--aurora-cyan);
}

.save-score-form .btn-primary {
    padding: 12px 20px;
}

.save-status {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
    min-height: 20px;
}

.save-status.success { color: var(--correct); }
.save-status.error { color: #ef4444; }

.result-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.result-actions .btn-primary,
.result-actions .btn-secondary {
    padding: 12px 25px;
    flex-direction: row;
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal h2 {
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--aurora-cyan), var(--aurora-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal h3 {
    text-align: center;
    margin: 20px 0 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.stat-box {
    background: var(--bg-light);
    padding: 15px 10px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--aurora-cyan);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Distribution */
.distribution {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dist-label {
    min-width: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.dist-bar {
    height: 20px;
    min-width: 25px;
    background: var(--absent);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
}

.dist-bar.highlight {
    background: var(--correct);
}

/* Help Examples */
.example {
    margin-bottom: 20px;
}

.example h4 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.example-row {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.example-tile {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    border: 2px solid var(--tile-border);
    border-radius: 6px;
    background: var(--tile-empty);
}

.example-tile.correct {
    background: var(--correct);
    border-color: var(--correct);
}

.example-tile.present {
    background: var(--present);
    border-color: var(--present);
}

.example-tile.absent {
    background: var(--absent);
    border-color: var(--absent);
}

.example p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tip {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 10px;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 400px) {
    .tile {
        width: 52px;
        height: 52px;
        font-size: 1.8rem;
    }
    
    .key {
        min-width: 26px;
        height: 45px;
        font-size: 0.8rem;
    }
    
    .key-wide {
        min-width: 45px;
        font-size: 0.65rem;
    }
    
    .title-glow {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-height: 700px) {
    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }
    
    .key {
        height: 42px;
    }
    
    .grid-container {
        margin-bottom: 10px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--key-bg);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--key-hover);
}
