:root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --primary-color: #64ffda;
    --error-color: #ff5252;
    --correct-color: #69f0ae;
    --subtle-color: #424242;
    --highlight-color: #2d2d2d;
    --font-family: 'Roboto Mono', monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

#settings-panel {
    background-color: var(--highlight-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#settings-panel.hidden {
    display: none;
}

.setting-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.time-options {
    display: flex;
    gap: 10px;
}

.time-btn {
    background-color: var(--subtle-color);
    border: 1px solid transparent;
    color: #888;
    padding: 5px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

.time-btn.active {
    background-color: var(--primary-color);
    color: #000;
    font-weight: bold;
}

.stats {
    display: flex;
    justify-content: space-around;
    background-color: var(--highlight-color);
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
}

.stat-box span {
    display: block;
    font-size: 0.8rem;
    color: #888;
}

.stat-box strong {
    font-size: 1.2rem;
    color: var(--primary-color);
}

#game-area {
    background-color: var(--subtle-color);
    padding: 20px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

#word-display {
    font-size: 1.5rem;
    line-height: 1.8;
    height: 150px;
    overflow: hidden;
    margin-bottom: 20px;
    color: #888;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    user-select: none;
    position: relative; /* Ensure offsetTop of children is relative to this container */
}

.word {
    padding: 2px 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.word.current {
    background-color: rgba(100, 255, 218, 0.2);
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
}

.word.correct {
    color: var(--correct-color);
}

.word.incorrect {
    color: var(--error-color);
    text-decoration: line-through;
}

/* The actual input the user types into */
#input-field {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    background-color: var(--bg-color);
    border: 2px solid var(--subtle-color);
    color: var(--text-color);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
}

#input-field:focus {
    border-color: var(--primary-color);
}

#restart-btn {
    align-self: center;
    background-color: var(--primary-color);
    color: #000;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 20px;
    display: none; /* Hidden during game usually, or shown to reset */
}


/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--highlight-color);
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    border: 1px solid #444;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.result-item {
    background-color: var(--subtle-color);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.result-item .label {
    font-size: 0.8rem;
    color: #aaa;
}

.result-item .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
}

#high-score-alert {
    background-color: rgba(255, 215, 0, 0.2);
    color: gold;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-weight: bold;
    border: 1px solid gold;
}
.best-score {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 20px;
}

/* Overlay for focus hint */
#focus-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 12px;
    z-index: 10;
}
#focus-overlay.hidden {
    display: none;
}
