/* === Reset and Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background-color: #000000;
    color: #FFFFFF;
    font-family: 'Arial', 'Helvetica Neue', sans-serif;
    font-size: 16px;
    line-height: 1.4;
    user-select: none;
    -webkit-user-select: none;
}

/* === Skip Link === */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: #FFFF00;
    color: #000000;
    padding: 8px 16px;
    font-size: 18px;
    z-index: 1000;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* === Main Layout === */
.app-container {
    display: grid;
    grid-template-columns: 65fr 35fr;
    height: calc(100vh - 50px);
    width: 100vw;
}

/* === Typing Panel === */
.typing-panel {
    display: flex;
    align-items: flex-end;
    padding: 40px;
    padding-bottom: 20px;
    overflow: hidden;
}

.text-display {
    width: 100%;
    font-size: 60px;
    font-weight: bold;
    font-family: 'Arial', sans-serif;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-height: calc(100vh - 110px);
    overflow: hidden;
    outline: none;
}

.text-display:focus {
    outline: none;
}

.completed-line {
    opacity: 0.6;
}

/* Blinking cursor */
.cursor {
    color: #FFFF00;
    animation: blink 1s step-end infinite;
    font-weight: normal;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* === Image Panel === */
.image-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    border-left: 2px solid #222222;
}

.image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 100%;
    text-align: center;
}

.word-image {
    max-width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border: 3px solid #FFFFFF;
    border-radius: 8px;
}

.image-label {
    font-size: 48px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #FFFFFF;
}

.image-label.has-image {
    color: #00FF00;
}

.image-label.loading {
    color: #FFFF00;
    font-size: 32px;
}

.image-attribution {
    font-size: 12px;
    color: #666666;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Status Bar === */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #111111;
    color: #00FF00;
    padding: 10px 24px;
    font-size: 22px;
    font-weight: bold;
    border-top: 1px solid #333333;
    z-index: 10;
    height: 50px;
    display: flex;
    align-items: center;
}

/* === Instructions Overlay === */
.overlay {
    position: fixed;
    inset: 0;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    max-width: 700px;
    padding: 40px;
}

.overlay-content h1 {
    font-size: 64px;
    margin-bottom: 40px;
    color: #FFFF00;
}

.overlay-content p {
    font-size: 28px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.overlay-content strong {
    color: #FFFF00;
}

.start-button {
    font-size: 36px;
    padding: 20px 60px;
    background-color: #FFFF00;
    color: #000000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 30px;
}

.start-button:hover {
    background-color: #FFEE00;
}

.start-button:focus {
    outline: 4px solid #FFFFFF;
    outline-offset: 4px;
}

/* === Settings Panel === */
.settings-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #333333;
    color: #FFFFFF;
    border: 2px solid #666666;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    z-index: 50;
    transition: background-color 0.2s;
}

.settings-toggle:hover {
    background-color: #444444;
}

.settings-toggle:focus {
    outline: 3px solid #FFFF00;
    outline-offset: 2px;
}

.settings-panel {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    overflow-y: auto;
}

.settings-panel.visible {
    display: flex;
}

.settings-content {
    background-color: #1a1a1a;
    border: 2px solid #444444;
    border-radius: 12px;
    padding: 40px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.settings-content h2 {
    font-size: 48px;
    color: #FFFF00;
    margin-bottom: 30px;
    text-align: center;
}

.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #222222;
    border-radius: 8px;
}

.settings-section h3 {
    font-size: 28px;
    color: #00FF00;
    margin-bottom: 20px;
}

.setting-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
}

.setting-row.full-width {
    flex-direction: column;
    align-items: stretch;
}

.setting-row label {
    font-size: 18px;
    color: #FFFFFF;
    min-width: 220px;
}

.setting-row.full-width label {
    min-width: auto;
    margin-bottom: 8px;
}

.setting-row select,
.setting-row input[type="color"] {
    font-size: 16px;
    padding: 8px 12px;
    background-color: #333333;
    color: #FFFFFF;
    border: 1px solid #666666;
    border-radius: 4px;
    cursor: pointer;
}

.setting-row input[type="range"] {
    flex: 1;
    max-width: 300px;
}

.setting-row input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.setting-row textarea {
    width: 100%;
    padding: 12px;
    background-color: #333333;
    color: #FFFFFF;
    border: 1px solid #666666;
    border-radius: 4px;
    font-size: 16px;
    font-family: 'Arial', sans-serif;
    resize: vertical;
}

.setting-row span {
    font-size: 18px;
    color: #FFFF00;
    min-width: 80px;
    font-weight: bold;
}

.settings-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.settings-button {
    font-size: 20px;
    padding: 12px 30px;
    background-color: #333333;
    color: #FFFFFF;
    border: 2px solid #666666;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.settings-button:hover {
    background-color: #444444;
}

.settings-button.primary {
    background-color: #FFFF00;
    color: #000000;
    border-color: #FFFF00;
}

.settings-button.primary:hover {
    background-color: #FFEE00;
}

.settings-button:focus {
    outline: 3px solid #FFFFFF;
    outline-offset: 2px;
}

/* === Settings Note === */
.setting-note {
    font-size: 14px;
    color: #999999;
    margin-top: 5px;
    padding: 0 4px;
    line-height: 1.4;
}

/* === Image Processing State === */
.word-image.processing {
    opacity: 0.5;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.3; }
}

/* === Bubble Letters Style === */
.text-display.bubble-letters {
    text-shadow:
        -1px -1px 0 var(--bubble-color, #FFFF00),
         1px -1px 0 var(--bubble-color, #FFFF00),
        -1px  1px 0 var(--bubble-color, #FFFF00),
         1px  1px 0 var(--bubble-color, #FFFF00);
}

/* === Responsive === */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 55fr 45fr;
    }

    .text-display {
        font-size: 36px;
    }

    .typing-panel {
        padding: 20px;
    }

    .image-panel {
        border-left: none;
        border-top: 2px solid #222222;
        padding: 20px;
    }

    .image-label {
        font-size: 32px;
    }

    .word-image {
        max-height: 30vh;
    }

    .overlay-content h1 {
        font-size: 40px;
    }

    .overlay-content p {
        font-size: 20px;
    }

    .start-button {
        font-size: 28px;
        padding: 16px 40px;
    }

    .status-bar {
        font-size: 18px;
    }

    .settings-content {
        padding: 20px;
        width: 95%;
    }

    .settings-content h2 {
        font-size: 32px;
    }

    .settings-section h3 {
        font-size: 22px;
    }

    .setting-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .setting-row label {
        min-width: auto;
    }

    .settings-buttons {
        flex-direction: column;
    }

    .settings-button {
        width: 100%;
    }
}
