:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --text-color: #333;
    --bg-color: #f4f4f4;
    --redacted-color: #bdc3c7;
    --revealed-color: #ecf0f1;
    --btn-giveup-color: #e74c3c;
    --btn-giveup-hover: #c0392b;
    --btn-newgame-color: #2ecc71;
    --btn-newgame-hover: #27ae60;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overscroll-behavior: none;
}

.container {
    width: 100%;
    max-width: 800px;
    background: white;
    padding: 2rem;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin: 2rem;
    border-radius: 8px;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

.puzzle-area {
    margin-bottom: 2rem;
}

.marc-field {
    margin-bottom: 1rem;
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.field-tag {
    font-weight: bold;
    color: #7f8c8d;
    margin-right: 0.5rem;
    /* Removed fixed width to allow longer labels */
    min-width: 40px;
    flex-shrink: 0;
}

.field-content {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    line-height: 1.6;
    flex-grow: 1;
}

@media (max-width: 600px) {
    .marc-field {
        flex-direction: column;
        align-items: flex-start;
    }

    .field-tag {
        margin-bottom: 0.2rem;
        color: var(--accent-color);
        /* Highlight label on mobile */
    }
}

.word {
    display: inline-block;
    margin-right: 0.5rem;
    white-space: nowrap;
}

.char {
    display: inline-block;
    min-width: 10px;
    border-bottom: 2px solid var(--redacted-color);
    text-align: center;
    margin: 0 1px;
    color: transparent;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.char.revealed {
    color: var(--text-color);
    border-bottom-color: transparent;
}

.char.space {
    border-bottom: none;
    width: 10px;
}

.char.punctuation {
    color: var(--text-color);
    /* Usually punctuation is visible or we can choose to hide it */
    border-bottom: none;
}

/* Specific styling for the target field (245) to make it stand out? 
   No, the requirement is "context fields present", implies equality in display but 245 is the win condition.
*/

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

.key {
    padding: 0.8rem 1.2rem;
    border: none;
    background-color: var(--primary-color);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    transition: background-color 0.2s;
}

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

.key:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-weight: bold;
    font-size: 1.2rem;
}

.game-actions {
    margin-top: 2rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.2s;
    text-transform: uppercase;
    color: white;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-giveup {
    background-color: var(--btn-giveup-color);
}

.btn-giveup:hover {
    background-color: var(--btn-giveup-hover);
}

.btn-newgame {
    background-color: var(--btn-newgame-color);
}

.btn-newgame:hover {
    background-color: var(--btn-newgame-hover);
}

.hidden {
    display: none !important;
}

/* Secret Book Club Styles */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    margin-bottom: 2rem;
}

.guess-block {
    background-color: #EDE7DC;
    /* Beige/Tan color matching the screenshot style */
    color: #000;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 700;
    text-align: center;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.guess-block.winner {
    background-color: #2ecc71;
    color: white;
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
}

.input-container {
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.helper-text {
    font-size: 0.9rem;
    color: #bdc3c7;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-align: center;
}

.game-input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
}

.game-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-guess {
    margin-top: 0.5rem;
    padding: 0.5rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
}

.btn-guess:hover {
    background-color: var(--accent-color);
}

/* Mastermind page specific button visibility tweaks */
.mastermind .btn {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.12);
}

.mastermind .btn:hover {
    background-color: #2573a8;
    /* slightly darker accent */
}

/* Keypad buttons in mastermind (class 'btn k') */
.mastermind .btn.k {
    background-color: var(--primary-color);
    color: white;
    width: 56px;
    height: 44px;
    border-radius: 10px;
    font-weight: 700;
}

.mastermind .btn.k:hover {
    background-color: var(--accent-color);
}

.message-area {
    text-align: center;
    min-height: 1.5rem;
    color: #e74c3c;
    font-weight: bold;
}

/* Navigation Styles */
.nav-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--primary-color);
    padding: 0.5rem 1rem;
    margin-bottom: 2rem;
    border-radius: 8px 8px 0 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    min-height: 60px;
}

.nav-links-main {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background-color: var(--accent-color);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

/* Dropdown Styles */
.nav-dropdown {
    display: none;
    /* Hidden by default, shown on mobile */
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-weight: 600;
    border-bottom: 1px solid #eee;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: #f1f1f1;
    color: var(--accent-color);
}

.dropdown-item.active {
    background-color: var(--accent-color);
    color: white;
}

@media (max-width: 768px) {
    .nav-bar {
        justify-content: space-between;
    }

    .nav-links-main {
        display: none;
        /* Hide all links on small screens */
    }

    /* Ensure the active link is visible next to the dropdown */
    .nav-links-main .nav-link.active {
        display: block;
    }

    .nav-dropdown {
        display: block;
    }
}

/* Special case: only show active link in its own container on mobile */
.active-link-mobile {
    display: none;
    color: white;
    font-weight: bold;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .active-link-mobile {
        display: block;
    }
}

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

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close-modal:hover {
    color: #000;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Small Title Guess Button */
.btn-title-guess {
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    cursor: pointer;
    vertical-align: middle;
}

.btn-title-guess:hover {
    background-color: #2980b9;
}

#hidden-input {
    position: fixed;
    top: 0;
    left: 0;
    opacity: 0;
    height: 1px;
    width: 1px;
    pointer-events: none;
}

/* Stats Modal Specifics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 1.5rem 0;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #666;
}

.next-puzzle-container {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

#countdown-timer {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-top: 0.5rem;
}

.header-actions {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--primary-color);
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.stats-history {
    margin-top: 1.5rem;
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.85rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px dashed #eee;
}