:root {
    --primary-red: #c00;
    --gold: #ffd700;
    --dark-blue: #000080;
    --light-blue: #0066cc;
}

body {
    margin: 0;
    background: linear-gradient(45deg, #1a1a1a, #2a2a2a);
    font-family: 'Roboto Condensed', sans-serif;
    color: white;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    width: 400px;
    margin: 20px 0;
}

h1 {
    color: var(--gold);
    font-family: 'Passion One', cursive;
    font-size: 2.5em;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.puzzle-board {
    background: var(--dark-blue);
    border: 8px solid var(--gold);
    border-radius: 15px;
    padding: 20px;
    margin: 20px auto;
    width: 90%;
    max-width: 800px;
    min-width: 300px;
    overflow-x: auto; 
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    box-sizing: border-box;
    position: relative; 
}

.puzzle-display {
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    justify-content: center;
    align-items: center; 
    padding: 10px;
    min-height: 120px; /* Ensure it has some height even when empty/loading */
    width: 100%;
    box-sizing: border-box;
}

.word-container {
    display: flex;
    flex-direction: column; 
    align-items: center; 
    gap: 15px; 
    width: 100%; 
}

.word-row {
    display: flex;
    justify-content: center; 
    gap: 5px; 
    flex-wrap: nowrap; 
}

.letter-tile {
    background: var(--dark-blue); 
    border: 2px solid var(--gold);
    border-radius: 5px;
    color: transparent; 
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    padding: 15px;
    min-width: 50px; 
    max-width: 50px; 
    height: 60px;    
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px;
    box-sizing: border-box;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    user-select: none; 
}

.letter-tile::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gold);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.letter-tile.revealed {
    color: white; 
    background: var(--light-blue); 
}

.letter-tile.revealed::after {
    opacity: 0.2;
    animation: flash 0.5s ease-out;
}

@keyframes flash {
    0% { opacity: 0.4; }
    50% { opacity: 0.2; }
    100% { opacity: 0; }
}

.space-tile {
    background: transparent !important;
    border-color: transparent !important;
    color: transparent !important;
}
.space-tile.revealed { 
    background: transparent !important;
    border-color: transparent !important;
    color: transparent !important;
}
.space-tile::after { 
    display: none !important;
}

.info-panel {
    background: rgba(0,0,0,0.7);
    border-radius: 10px;
    padding: 20px;
    margin: 30px auto;
    max-width: 600px;
}

.info-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
}

.info-label {
    color: var(--gold);
    font-weight: bold;
    font-size: 1.2em;
}

.info-value {
    color: white;
    font-size: 1.4em;
    font-weight: bold;
    font-family: 'Roboto Condensed', sans-serif;
}

#solution { /* This is the span holding the solution text, not the tiles */
    position: relative;
    display: inline-block;
    padding-right: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#solution:hover {
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255,215,0,0.5);
    transform: scale(1.02);
}

#solution::after {
    content: '📋';
    position: absolute;
    right: 0;
    top: 55%;
    transform: translateY(-50%);
    font-size: 0.7em;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

#solution:hover::after {
    opacity: 1;
}

.copy-feedback {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: var(--gold);
    padding: 15px 30px;
    border-radius: 30px;
    font-family: 'Passion One', cursive;
    font-size: 1.3em;
    letter-spacing: 1px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 10000;
    pointer-events: none;
    border: 2px solid var(--gold);
    animation: feedback-bounce 0.6s ease-out forwards;
}

@keyframes feedback-bounce {
    0% { transform: translate(-50%, 20px); opacity: 0; }
    40% { transform: translate(-50%, -10px); opacity: 1; }
    60% { transform: translate(-50%, 5px); }
    100% { transform: translate(-50%, 0); opacity: 1; }
}

.previous-solutions {
    margin: 40px auto;
    max-width: 800px;
}

.history-header {
    background: var(--dark-blue);
    border: 3px solid var(--gold);
    border-radius: 10px;
    padding: 15px 25px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
}

.history-header:hover {
    background: #000060; 
}

.history-header span {
    color: var(--gold);
    font-family: 'Passion One', cursive;
    font-size: 1.4em;
    letter-spacing: 1px;
    text-align: center;
}

.dropdown-arrow {
    width: 20px;
    height: 20px;
    border-right: 3px solid var(--gold);
    border-bottom: 3px solid var(--gold);
    transform: rotate(45deg);
    transition: transform 0.3s ease;
    position: absolute;
    right: 20px;
}

#history-content {
    display: none;
    margin-top: 15px;
    background: var(--dark-blue);
    border: 3px solid var(--gold);
    border-radius: 10px;
    padding: 20px;
}

#history-content.visible {
    display: block;
}

.history-solution-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: rgba(255,255,255,0.05);
    border-radius: 5px;
    cursor: pointer; 
    transition: background-color 0.2s ease-in-out; 
}

.history-solution-item:hover,
.history-solution-item:focus { 
    background: rgba(255,255,255,0.1); 
    outline: 2px solid var(--gold); /* Example focus style */
}


.history-date {
    color: var(--gold);
    font-family: 'Passion One', cursive;
    font-size: 1.4em;
    width: 45%; 
    border-bottom: 1px dotted rgba(255,255,255,0.3);
    transition: color 0.2s ease;
    pointer-events: none; 
}

.history-solution {
    color: white;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 1.4em;
    font-weight: bold;
    width: 55%; 
    text-align: right;
    pointer-events: none; 
}

.puzzle-timestamp {
    position: absolute;
    bottom: 10px;
    right: 15px;
    color: rgba(255,255,255,0.7);
    font-size: 0.9em;
    font-style: italic;
    z-index: 1; 
}

@media (max-width: 600px) {
    .logo {
        width: 250px;
    }
    
    .puzzle-board {
        max-width: 95%;
        padding: 10px;
    }
    
    .letter-tile {
        min-width: 30px; 
        max-width: 30px;
        height: auto; 
        font-size: 1.1em; /* Adjusted for better fit */
        padding: 6px;   /* Adjusted for better fit */
    }
    
    .history-header span {
        font-size: 1.2em;
        padding-right: 30px; 
    }
    
    .dropdown-arrow {
        right: 10px;
        width: 16px;
        height: 16px;
    }
    
    .history-date,
    .history-solution {
        font-size: 1.1em; /* Adjusted for consistency */
    }

    .puzzle-timestamp {
        font-size: 0.8em;
        right: 10px;
        bottom: 8px;
    }
}
