
/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base Styles */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #f3f4f6;
    --secondary-hover: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --hint-bg: #fff7ed;
    --hint-text: #ea580c;
    --container-shadow: 0px 4px 20px rgba(0, 0, 0, 0.1);
    --input-border: #d1d5db;
    --container-bg: white;
    --body-bg: #f4f4f9;
}

body {
    font-family: 'Arial', sans-serif;
    text-align: center;
    background: var(--body-bg);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.5;
}

/* Container Styles */
.container {
    position: relative;
    align-items: center;
    max-width: 450px;
    width: 100%;
    background: var(--container-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--container-shadow);

}

/* Cancel Button (X) */
.cancel-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #dc2626;
    cursor: pointer;
    padding: 5px;
    z-index: 10;
}

.cancel-button:hover {
    color: #b91c1c;
}

/* Header Styles */
.header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Game Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 12px;
    background: var(--secondary-color);
    border-radius: 8px;
    font-weight: bold;
}

/* Word Display */
.word-display {
    margin: 20px 0;
}

#scrambled-word {
    font-size: 32px;
    font-weight: bold;
    color: var(--text-primary);
    background: var(--secondary-color);
    padding: 20px;
    border-radius: 8px;
    letter-spacing: 4px;
    margin: 15px 0;
    display: inline-block;
    min-width: 200px;
    
}

/* Input Styles */
#user-input {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    margin: 15px 0;
    transition: all 0.3s ease;
}

#user-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Button Styles */
.button-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 15px 0;
}

.button {
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.primary-button {
    background: var(--primary-color);
    color: white;
    grid-column: span 2;
}

.primary-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.secondary-button {
    background: var(--secondary-color);
    color: var(--text-primary);
}

.secondary-button:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
}

/* Feedback Styles */
.feedback {
    padding: 12px;
    border-radius: 8px;
    margin: 12px 0;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feedback.visible {
    opacity: 1;
}

.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* Hint Styles */
.hint-text {
    margin: 12px 0;
    padding: 10px;
    background: var(--hint-bg);
    color: var(--hint-text);
    border-radius: 6px;
    font-style: italic;
}

/* Timer Animation */
@keyframes timerPulse {
    0% { color: var(--text-primary); }
    50% { color: var(--error-text); }
    100% { color: var(--text-primary); }
}

.timer.low-time {
    animation: timerPulse 1s infinite;
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Media Queries */

/* Small phones */
@media screen and (max-width: 360px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 24px;
    }

    .subtitle {
        font-size: 13px;
    }

    #scrambled-word {
        font-size: 24px;
        padding: 15px;
        letter-spacing: 2px;
        min-width: 150px;
    }

    .button-container {
        grid-template-columns: 1fr;
    }

    .primary-button {
        grid-column: 1;
    }

    .button {
        padding: 10px;
        font-size: 14px;
    }
}

/* Regular phones */
@media screen and (min-width: 361px) and (max-width: 480px) {
    .container {
        padding: 20px;
    }

    #scrambled-word {
        font-size: 28px;
        padding: 15px;
    }

    .button {
        padding: 12px;
        font-size: 15px;
    }
}

/* Large phones and small tablets */
@media screen and (min-width: 481px) and (max-width: 768px) {
    .container {
        max-width: 500px;
    }

    #scrambled-word {
        font-size: 30px;
    }
}

/* Tablets and small laptops */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 600px;
    }

    #scrambled-word {
        font-size: 34px;
    }
}

/* Landscape mode */
@media screen and (max-height: 600px) and (orientation: landscape) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 22px;
        margin-bottom: 5px;
    }

    .subtitle {
        font-size: 12px;
        margin-bottom: 10px;
    }

    .game-header {
        margin: 10px 0;
        padding: 8px;
    }

    #scrambled-word {
        font-size: 24px;
        padding: 10px;
        margin: 8px 0;
    }

    .button-container {
        gap: 8px;
    }

    .button {
        padding: 8px;
    }
}

/* High-resolution displays */
@media screen and (min-resolution: 192dpi) {
    .container {
        box-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --container-bg: #1f2937;
        --body-bg: #111827;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --secondary-color: #374151;
        --secondary-hover: #4b5563;
        --input-border: #4b5563;
        --container-shadow: 0px 4px 20px rgba(0, 0, 0, 0.3);
    }

    #user-input {
        background: var(--secondary-color);
        color: var(--text-primary);
    }

    .button {
        border: 1px solid var(--input-border);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* Print styles */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        box-shadow: none;
        max-width: 100%;
    }

    .button-container,
    #user-input {
        display: none;
    }
}

/* Touch devices */
@media (hover: none) {
    .button:hover {
        transform: none;
    }
}

/* Large desktop screens */
@media screen and (min-width: 1400px) {
    .container {
        max-width: 700px;
    }

    .header h1 {
        font-size: 32px;
    }

    #scrambled-word {
        font-size: 38px;
    }

    .button {
        padding: 15px 25px;
        font-size: 18px;
    }
}

/* Extra Small Devices (Small Phones) */
@media screen and (max-width: 320px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 12px;
        border-radius: 8px;
    }

    .header h1 {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .subtitle {
        font-size: 12px;
        margin-bottom: 12px;
    }

    .game-header {
        margin: 12px 0;
        padding: 8px;
        font-size: 14px;
    }

    #scrambled-word {
        font-size: 20px;
        padding: 12px;
        letter-spacing: 1px;
        min-width: auto;
        margin: 10px 0;
    }

    .word-display h2 {
        font-size: 14px;
    }

    #user-input {
        padding: 10px;
        font-size: 14px;
        margin: 10px 0;
    }

    .button {
        padding: 8px;
        font-size: 13px;
    }

    .hint-text {
        font-size: 12px;
        padding: 8px;
    }

    .feedback {
        padding: 8px;
        font-size: 13px;
    }

    .cancel-button {
        font-size: 18px;
        top: 8px;
        right: 8px;
    }
}

/* Narrow Screens */
@media screen and (max-width: 280px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 18px;
    }

    #scrambled-word {
        font-size: 18px;
        padding: 8px;
        letter-spacing: 0;
    }

    .button {
        padding: 6px;
        font-size: 12px;
    }
}

/* Medium-Large Phones in Landscape */
@media screen and (min-width: 481px) and (max-height: 480px) and (orientation: landscape) {
    .container {
        max-width: 90%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 15px;
        padding: 15px;
    }

    .header {
        grid-column: 1 / -1;
    }

    .game-header {
        grid-column: 1 / -1;
        margin: 10px 0;
    }

    .word-display {
        margin: 0;
    }

    .game-controls {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Tablets in Landscape */
@media screen and (min-width: 769px) and (max-height: 600px) and (orientation: landscape) {
    .container {
        max-width: 80%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 20px;
    }

    .header, .game-header {
        grid-column: 1 / -1;
    }

    #scrambled-word {
        font-size: 28px;
    }
}

/* Ultra Wide Screens */
@media screen and (min-width: 1920px) {
    .container {
        max-width: 800px;
        padding: 30px;
    }

    .header h1 {
        font-size: 36px;
    }

    .subtitle {
        font-size: 18px;
    }

    #scrambled-word {
        font-size: 42px;
        padding: 25px;
        letter-spacing: 6px;
    }

    .button {
        padding: 18px 30px;
        font-size: 20px;
    }

    #user-input {
        padding: 18px;
        font-size: 20px;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --primary-hover: #333333;
        --secondary-color: #ffffff;
        --secondary-hover: #eeeeee;
        --text-primary: #000000;
        --text-secondary: #333333;
        --success-bg: #ffffff;
        --success-text: #006600;
        --error-bg: #ffffff;
        --error-text: #cc0000;
        --hint-bg: #ffffff;
        --hint-text: #cc6600;
    }

    .container {
        border: 2px solid #000000;
    }

    #scrambled-word {
        border: 2px solid #000000;
    }

    .button {
        border: 2px solid #000000;
    }

    .secondary-button {
        color: #000000;
        background: #ffffff;
        border: 2px solid #000000;
    }

    .primary-button {
        color: #ffffff;
        background: #000000;
    }

    .game-header {
        border: 1px solid #000000;
    }
}

/* Tall Mobile Devices (iPhone X, etc.) */
@media screen and (min-height: 800px) and (max-width: 480px) {
    .container {
        max-height: 80vh;
    }

    .word-display {
        margin: 30px 0;
    }

    #scrambled-word {
        margin: 20px 0;
    }

    .button-container {
        margin: 20px 0;
    }
}

/* Foldable Devices - Folded State */
@media screen and (max-width: 320px) and (min-height: 600px) {
    .container {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Foldable Devices - Unfolded State */
@media screen and (min-width: 700px) and (max-width: 800px) and (min-height: 500px) and (max-height: 600px) {
    .container {
        max-width: 650px;
    }
}

/* Specific iPad Mini/Air in Portrait */
@media only screen and (min-width: 768px) and (max-width: 834px) and (min-height: 1024px) {
    .container {
        max-width: 600px;
    }

    #scrambled-word {
        font-size: 36px;
    }
}

/* Specific iPad Pro in Portrait */
@media only screen and (min-width: 1024px) and (max-width: 1024px) and (min-height: 1366px) {
    .container {
        max-width: 700px;
    }

    #scrambled-word {
        font-size: 40px;
    }
}

/* Specific iPad Pro in Landscape */
@media only screen and (min-width: 1366px) and (max-width: 1366px) and (min-height: 1024px) {
    .container {
        max-width: 900px;
    }
}

/* Specific Surface Pro in Portrait */
@media only screen and (min-width: 912px) and (max-width: 912px) and (min-height: 1368px) {
    .container {
        max-width: 700px;
    }
}

/* Specific Galaxy Fold - Folded */
@media only screen and (min-width: 280px) and (max-width: 280px) and (min-height: 653px) {
    .container {
        max-width: 260px;
    }

    #scrambled-word {
        font-size: 18px;
        letter-spacing: 1px;
    }
}

/* Specific Galaxy Fold - Unfolded */
@media only screen and (min-width: 717px) and (max-width: 717px) and (min-height: 512px) {
    .container {
        max-width: 600px;
    }
}

/* Specific iPhone SE */
@media only screen and (min-width: 375px) and (max-width: 375px) and (min-height: 667px) {
    .container {
        max-width: 350px;
    }
}

/* Specific iPhone 12/13 Pro Max */
@media only screen and (min-width: 428px) and (max-width: 428px) and (min-height: 926px) {
    .container {
        max-width: 400px;
    }
}

/* Specific Galaxy S21 Ultra */
@media only screen and (min-width: 412px) and (max-width: 412px) and (min-height: 915px) {
    .container {
        max-width: 380px;
    }
}

/* Specific Pixel 6 */
@media only screen and (min-width: 393px) and (max-width: 393px) and (min-height: 851px) {
    .container {
        max-width: 370px;
    }
}

/* Specific Surface Duo */
@media only screen and (min-width: 540px) and (max-width: 540px) and (min-height: 720px) {
    .container {
        max-width: 500px;
    }
}

/* Specific Nest Hub */
@media only screen and (min-width: 1024px) and (max-width: 1024px) and (min-height: 600px) {
    .container {
        max-width: 800px;
    }
}

/* Specific Nest Hub Max */
@media only screen and (min-width: 1280px) and (max-width: 1280px) and (min-height: 800px) {
    .container {
        max-width: 900px;
    }
}

/* Specific TV/Large Display */
@media screen and (min-width: 2560px) {
    .container {
        max-width: 1000px;
    }

    .header h1 {
        font-size: 48px;
    }

    .subtitle {
        font-size: 24px;
    }

    #scrambled-word {
        font-size: 56px;
        padding: 30px;
        letter-spacing: 8px;
    }

    .button {
        padding: 24px 36px;
        font-size: 24px;
    }

    #user-input {
        padding: 24px;
        font-size: 24px;
    }
}

/* Specific Projector/Presentation Mode */
@media screen and (min-width: 1400px) and (min-height: 900px) {
    body {
        font-size: 18px;
    }

    .container {
        max-width: 1000px;
    }

    #scrambled-word {
        font-size: 48px;
    }
}

/* Specific Accessibility - Large Text */
@media screen and (prefers-reduced-transparency: reduce) {
    .container {
        box-shadow: none;
        border: 1px solid var(--input-border);
    }
}

/* Specific Accessibility - Reduce Transparency */
@media screen and (prefers-reduced-transparency: reduce) {
    .container {
        opacity: 1;
        background: var(--container-bg);
    }
}

/* Specific Accessibility - Reduce Motion */
@media screen and (prefers-reduced-motion: reduce) {
    .button:hover, .button:focus {
        transform: none;
    }
}

/* Specific Accessibility - Increase Contrast */
@media screen and (prefers-contrast: more) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --container-bg: #ffffff;
        --body-bg: #f0f0f0;
    }
}

/* Specific Accessibility - Reduce Data */
@media screen and (prefers-reduced-data: reduce) {
    body {
        background: #ffffff;
    }

    .container {
        box-shadow: none;
    }
}

/* Specific Accessibility - Inverted Colors */
@media screen and (inverted-colors: inverted) {
    :root {
        --container-bg: #000000;
        --body-bg: #ffffff;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
}

/* Specific Accessibility - Forced Colors */
@media screen and (forced-colors: active) {
    :root {
        --primary-color: ButtonText;
        --primary-hover: Highlight;
        --secondary-color: Canvas;
        --secondary-hover: ButtonFace;
        --text-primary: ButtonText;
        --text-secondary: GrayText;
        --container-bg: Canvas;
        --body-bg: Canvas;
        --input-border: ButtonText;
    }

    .container {
        border: 1px solid ButtonText;
    }

    .button {
        border: 1px solid ButtonText;
    }

    #user-input {
        border: 1px solid ButtonText;
    }
}



