:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #f093fb;
    --success: #4caf50;
    --error: #f44336;
    --dark: #1a1a1a;
    --light: #f5f5f5;
    --border: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: var(--dark);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

.logo {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Main Menu */
.main-menu {
    animation: fadeIn 0.5s ease-in;
}

.menu-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.menu-content h2 {
    text-align: center;
    font-size: 2em;
    margin-bottom: 30px;
    color: var(--dark);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.game-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
}

.game-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.game-card h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

.game-card p {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Game Screen */
.game-screen {
    animation: fadeIn 0.5s ease-in;
}

.game-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.game-header h2,
.game-header h3 {
    margin: 0;
    flex: 1;
}

.game-stats {
    display: flex;
    gap: 30px;
    align-items: center;
}

.game-stats span {
    font-weight: bold;
    color: var(--primary);
}

.game-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-height: 400px;
}

/* Game Layouts */
.unscramble-container,
.findwords-container,
.wordladder-container {
    text-align: center;
}

.scrambled-word {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary);
    margin: 20px 0;
    letter-spacing: 5px;
}

.hint {
    background: var(--light);
    padding: 15px;
    border-left: 4px solid var(--primary);
    text-align: left;
    margin: 20px 0;
    border-radius: 5px;
}

.input-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

input[type="text"] {
    padding: 12px 15px;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: 8px;
    width: 300px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Match Pairs Layout */
.match-pairs-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.pairs-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pair-item {
    padding: 12px 20px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    flex: 1;
    min-width: 150px;
    font: inherit;
    color: inherit;
    text-align: left;
    touch-action: manipulation;
}

.pair-item:hover {
    border-color: var(--primary);
    background: #f0f4ff;
}

.pair-item.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pair-item.matched {
    border-color: var(--success);
    background: #e8f5e9;
    color: var(--success);
    cursor: default;
}

/* Grid Layout */
.letter-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 20px 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* Columns and max-width are set per puzzle in script.js; cells scale to fit */
.letter-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--dark);
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.letter-cell:hover {
    background: #f0f4ff;
}

.letter-cell.selected {
    background: var(--primary);
    color: white;
}

.letter-cell.found {
    border-color: var(--success);
    background: #e8f5e9;
    color: var(--success);
    cursor: default;
}

/* Feedback Messages */
.feedback {
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    font-weight: bold;
    animation: slideIn 0.3s ease;
}

.feedback.success {
    background: #e8f5e9;
    color: var(--success);
    border-left: 4px solid var(--success);
}

.feedback.error {
    background: #ffebee;
    color: var(--error);
    border-left: 4px solid var(--error);
}

/* Word Ladder */
.ladder-container {
    max-width: 400px;
    margin: 0 auto;
}

.ladder-step {
    display: flex;
    gap: 5px;
    margin: 15px 0;
    justify-content: center;
}

.ladder-letter {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2em;
    background: white;
}

.ladder-letter input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    text-transform: uppercase;
}

.ladder-letter input:focus {
    outline: none;
    background: #f0f4ff;
}

.ladder-letter:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--accent);
}

.ladder-letter input {
    touch-action: manipulation;
}

.ladder-letter input.correct {
    background: #e8f5e9;
    color: var(--success);
}

.ladder-letter input.incorrect {
    background: #ffebee;
    color: var(--error);
}

/* Short in-game instructions and the saved-progress status line */
.game-instructions {
    text-align: center;
    color: #555;
    margin: 0 0 15px;
}

.progress-status {
    background: #f0f4ff;
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 20px;
    line-height: 1.5;
}

.progress-status.warning {
    background: #fff8e1;
    border-left-color: #f9a825;
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
    box-shadow: none;
}

/* Results Screen */
.results-container {
    text-align: center;
}

.results-score {
    font-size: 3em;
    color: var(--primary);
    margin: 20px 0;
    font-weight: bold;
}

.results-message {
    font-size: 1.5em;
    margin: 20px 0;
    color: var(--dark);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 2em;
    }

    .games-grid {
        grid-template-columns: 1fr;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
    }

    .game-stats {
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    .match-pairs-container {
        flex-direction: column;
        gap: 20px;
    }

    input[type="text"] {
        width: 100%;
        max-width: 300px;
    }

    .input-group {
        flex-wrap: wrap;
    }
}

/* ============================================================
   Site-wide layout: header, nav, footer, breadcrumbs, content
   ============================================================ */

html {
    box-sizing: border-box;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
}

/* Accessible "visually hidden" text for screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link */
.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--dark);
    color: white;
    padding: 10px 16px;
    border-radius: 0 0 8px 0;
    z-index: 1000;
}

.skip-link:focus {
    left: 0;
}

/* Focus states */
a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
.nav-toggle-label:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Site header / nav */
.site-header {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    margin-bottom: 30px;
}

.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    position: relative;
}

.site-logo {
    color: white;
    font-size: 1.6em;
    font-weight: bold;
    text-decoration: none;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
}

.site-logo img {
    height: 48px;
    width: auto;
    display: block;
}

.site-nav {
    display: flex;
    align-items: center;
}

.nav-toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

.nav-toggle-label {
    display: none;
    color: white;
    font-size: 1.6em;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    line-height: 1;
}

.nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-list a {
    display: inline-block;
    color: white;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .nav-toggle-label {
        display: inline-block;
    }

    .nav-list {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 20px;
        left: 20px;
        background: var(--secondary);
        border-radius: 12px;
        padding: 10px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        z-index: 10;
    }

    .nav-toggle-input:checked ~ .nav-list {
        display: flex;
    }

    .nav-list a {
        padding: 12px 14px;
    }
}

/* Breadcrumbs */
.breadcrumbs {
    margin: 0 0 20px;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
    color: white;
    font-size: 0.9em;
}

.breadcrumbs a {
    color: white;
    text-decoration: underline;
}

.breadcrumbs li:not(:last-child)::after {
    content: "›";
    margin-left: 6px;
}

.breadcrumbs li[aria-current="page"] {
    opacity: 0.85;
}

/* Article / content sections on game & content pages */
.page-article {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin-bottom: 40px;
}

.page-article h1 {
    font-size: 2.2em;
    margin-bottom: 12px;
    color: var(--dark);
}

.intro-text {
    font-size: 1.1em;
    color: #444;
    max-width: 760px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.content-section {
    margin-top: 50px;
}

.content-section h2 {
    font-size: 1.6em;
    color: var(--dark);
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
    padding-left: 12px;
}

.content-section p,
.content-section li {
    line-height: 1.7;
    color: #333;
}

.content-section ul,
.content-section ol {
    padding-left: 22px;
    margin-bottom: 12px;
}

.content-section ul li,
.content-section ol li {
    margin-bottom: 8px;
}

/* FAQ */
.faq-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.faq-item summary {
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 600;
    color: var(--dark);
    background: var(--light);
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::before {
    content: "+";
    display: inline-block;
    width: 1em;
    margin-right: 10px;
    color: var(--primary);
    font-weight: bold;
}

.faq-item[open] summary::before {
    content: "−";
}

.faq-item p {
    padding: 4px 20px 18px;
    margin: 0;
}

/* Related games */
.related-games ul {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.related-games a {
    display: block;
    background: var(--light);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--dark);
    font-weight: 600;
    transition: all 0.2s ease;
}

.related-games a:hover {
    border-color: var(--primary);
    background: #f0f4ff;
    transform: translateY(-2px);
}

.related-games a.btn-primary {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    color: white;
}

.related-games a.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* Homepage game-type explainer grid */
.game-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.game-type-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.game-type-card h3 {
    margin-bottom: 8px;
    color: var(--primary);
}

.game-type-card a {
    color: var(--secondary);
    font-weight: 700;
    text-decoration: none;
}

.game-type-card a:hover {
    text-decoration: underline;
}

/* Game card links (homepage / hub) */
.game-card-link {
    display: block;
    text-decoration: none;
}

.game-card-link:focus-visible .game-card {
    outline: 3px solid white;
    outline-offset: 3px;
}

/* Game screen "restart" control label reused from Back button */
.game-stats a.btn-secondary {
    text-decoration: none;
}

/* Footer */
.site-footer {
    color: white;
    text-align: center;
    padding: 30px 20px 10px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
}

.footer-nav a {
    color: white;
    text-decoration: underline;
}

.site-footer p {
    opacity: 0.85;
    font-size: 0.9em;
}

/* Simple content-page layout (about/contact/privacy) */
.simple-page dl {
    margin: 10px 0 20px;
}

.simple-page dt {
    font-weight: 700;
    margin-top: 10px;
}

/* Phones: give the game board more of the screen width */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .page-article {
        padding: 24px 16px;
    }

    .game-header {
        padding: 15px;
    }

    .game-content {
        padding: 20px 12px;
    }

    .scrambled-word {
        font-size: 2em;
        letter-spacing: 3px;
        overflow-wrap: anywhere;
    }

    .letter-grid {
        gap: 6px;
    }

    .letter-cell {
        font-size: 1.25em;
    }

    .ladder-letter {
        width: 44px;
        height: 44px;
    }
}
