/* Text Adventure Game Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    background: #000;
    color: #e0e0e0;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Game title styling */
#game-title {
    color: #fff;
    font-size: 14px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
    padding: 10px 0;
    text-align: center;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: 'Courier New', monospace;
}

.loading-content {
    text-align: center;
}

.loading-text {
    font-size: 1rem;
    color: #ffffff;
    letter-spacing: 2px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

.game-container {
    width: 98%;
    max-width: 1400px;
    height: 97%;
    max-height: 100vh;
    background: #000;
    border: 1px solid #333;
    border-radius: 5px;
    box-shadow: 0 0 8px rgba(51, 51, 51, 0.8);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    overflow: hidden;
    margin-top: 1%;
}

/* Content area with image and game side by side */
.content-area {
    display: flex;
    gap: 15px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Image area on the left */
.image-area {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: #000;
    min-height: 0;
}

.room-image {
    width: 100%;
    height: 100%;
    min-height: 200px;
    background: #000;
    border: 1px solid #333;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    text-align: center;
    overflow: hidden;
}

.room-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Game area on the right */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

header {
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #4a4a4a;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header h1 {
    color: #ffd700;
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin: 0 0 10px 0;
}

/* Game selector styling */
.game-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    border: 1px solid #4a4a4a;
}

.game-selector label {
    color: #ccc;
    font-size: 14px;
    font-weight: bold;
}

.game-selector select {
    background: #222;
    color: #fff;
    border: 1px solid #4a4a4a;
    border-radius: 3px;
    padding: 4px 8px;
    font-size: 14px;
}

.game-selector button {
    background: #4a4a4a;
    color: #fff;
    border: 1px solid #666;
    border-radius: 3px;
    padding: 4px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.game-selector button:hover {
    background: #5a5a5a;
}

/* Remove the old .game-area margin since it's now in content-area */

#output {
    background: #000;
    border: 1px solid #333;
    border-radius: 5px;
    padding: 15px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

#output::-webkit-scrollbar {
    width: 8px;
}

#output::-webkit-scrollbar-track {
    background: #333;
    border-radius: 4px;
}

#output::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 4px;
}

#output::-webkit-scrollbar-thumb:hover {
    background: #888;
}

.input-area {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

#input {
    flex: 1;
    padding: 12px;
    background: #222;
    border: 1px solid #444;
    border-radius: 5px;
    color: #e0e0e0;
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    font-size: 14px;
}

#input:focus {
    outline: none;
    border-color: #888;
    box-shadow: 0 0 5px rgba(136, 136, 136, 0.3);
}

#submit, #settings {
    padding: 12px 20px;
    background: #4a4a4a;
    border: 1px solid #666;
    border-radius: 5px;
    color: #e0e0e0;
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#submit:hover, #settings:hover {
    background: #666;
    border-color: #888;
}

#submit:active, #settings:active {
    background: #333;
}

#narrate {
    padding: 12px 20px;
    background: #4a4a4a;
    border: 1px solid #666;
    border-radius: 5px;
    color: #e0e0e0;
    font-family: 'Source Code Pro', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#narrate:hover {
    background: #666;
    border-color: #888;
}

#narrate:active {
    background: #333;
}

#narrate:disabled {
    background: #3a3a3a;
    border-color: #3a3a3a;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

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

.settings-content {
    background: #2a2a2a;
    border: 2px solid #4a4a4a;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #4a4a4a;
}

.settings-header h2 {
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    margin: 0;
    font-size: 18px;
}

#close-settings {
    background: #4a4a4a;
    border: 1px solid #666;
    border-radius: 3px;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#close-settings:hover {
    background: #666;
    border-color: #888;
}

.settings-body {
    padding: 20px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group h3 {
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    margin: 0 0 15px 0;
    font-size: 14px;
    border-bottom: 1px solid #4a4a4a;
    padding-bottom: 5px;
}

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

.setting-item label {
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    min-width: 100px;
}

#voice-select {
    flex: 1;
    padding: 8px;
    background: #3a3a3a;
    border: 1px solid #666;
    border-radius: 3px;
    color: #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

#voice-select:focus {
    outline: none;
    border-color: #00ff00;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.3);
}

input[type="range"] {
    flex: 1;
    margin: 0 10px;
}

input[type="range"]::-webkit-slider-thumb {
    background: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    background: #00ff00;
    border: 1px solid #00ff00;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

#rate-value, #pitch-value {
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
}

footer {
    display: none;
}

/* ASCII Art Styling */
.ascii-art {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.2;
    color: #ffd700;
    text-align: center;
    margin: 10px 0;
}

/* Game text styling */
.game-text {
    margin: 5px 0;
}

/* Room separator */
.room-separator {
    color: #666;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    text-align: center;
    margin: 15px 0;
    border-top: 1px solid #444;
    padding-top: 10px;
}

/* Command echo styling */
.command-echo {
    color: #888;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
}

.progress-message {
    color: #aaa;
    font-weight: bold;
    font-style: italic;
}

.speech-pause {
    display: none;
}

/* Hide pause markers in room names */
.room-name {
    color: #ccc;
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 10px;
}

/* Hide the [PAUSE] text in room names */
.room-name::after {
    content: '';
    font-size: 0;
    color: transparent;
}


.room-description {
    color: #bbb;
    margin: 10px 0;
}

.item-list {
    color: #ddd;
    margin: 10px 0;
}

.exit-list {
    color: #999;
    margin: 10px 0;
}

.command-prompt {
    color: #777;
    font-weight: bold;
}

/* Bold text styling for items */
.game-text strong {
    font-weight: bold;
}

/* Direction commands get special coloring */
.game-text .direction {
    color: #999;
    font-weight: bold;
}

/* Item names get special coloring */
.game-text .item {
    color: #bbb;
    font-weight: bold;
}

/* Responsive design */
@media (max-width: 900px) {
    .game-container {
        width: 98%;
        padding: 10px;
    }
    
    .content-area {
        flex-direction: column;
    }
    
    .image-area {
        flex: none;
        width: 100%;
        height: 250px;
        margin: 0 auto 20px auto;
    }
    
    .room-image {
        height: 100%;
    }
    
    header h1 {
        font-size: 1.5em;
    }
    
    #output {
        height: 400px;
        font-size: 12px;
    }
    
    .input-area {
        flex-direction: column;
    }
    
    #submit, #narrate, #settings {
        width: 100%;
    }
}

/* iPhone-specific media queries */
@media screen and (max-width: 768px), 
       screen and (max-width: 414px), 
       screen and (max-width: 375px), 
       screen and (max-width: 360px) {
    body {
        align-items: flex-start !important;
        padding-top: 5px !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
    }
    
    .game-container {
        padding: 10px !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 20px) !important;
        height: calc(100dvh - 20px) !important; /* Dynamic viewport height with buffer */
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    
    .content-area {
        flex-direction: column;
        gap: 0px;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .game-area {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        max-height: calc(100vh - 270px) !important; /* Account for image and input areas */
        overflow: hidden !important;
    }
    
    #output {
        flex: 1 !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding-bottom: 80px !important; /* Space for fixed input area */
    }
    
    .input-area {
        position: fixed !important;
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        background: inherit !important;
        z-index: 100 !important;
        padding: 10px !important;
        border-radius: 5px !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
    }
    
    .image-area {
        flex: 0 0 100px; /* Much shorter image area */
        order: 1;
    }
    
    .room-image {
        min-height: 80px;
        position: relative;
        cursor: pointer;
    }
    
    .room-image::after {
        content: "🔍 Tap to view fullscreen";
        position: absolute;
        bottom: 5px;
        right: 5px;
        background: rgba(0, 0, 0, 0.7);
        color: white;
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 8px;
        font-family: 'Press Start 2P', 'Courier New', monospace;
    }
    
    .game-area {
        order: 2;
        flex: 1;
    }
    
    #output {
        height: 300px;
        font-size: 10px;
    }
    
    .input-area {
        flex-direction: row;
        gap: 8px;
        align-items: stretch;
    }
    
    #input {
        font-size: 10px;
        padding: 10px;
        flex: 1;
    }
    
    #submit {
        font-size: 16px;
        padding: 10px 15px;
        min-width: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-indent: -9999px;
        overflow: hidden;
    }
    
    #submit::before {
        content: "▶";
        text-indent: 0;
        position: absolute;
    }
    
    #narrate, #settings {
        font-size: 8px;
        padding: 8px 12px;
    }
    
    #narrate {
        text-indent: -9999px !important;
        overflow: hidden !important;
        position: relative !important;
    }
    
    #narrate::before {
        content: "🔊" !important;
        text-indent: 0 !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        font-size: 12px !important;
    }
    
    #game-title {
        padding: 0 !important;
    }
    
    .game-container {
        border: none !important;
    }
    
    footer {
        display: none !important;
    }
}

/* Additional iPhone portrait media query */
@media screen and (max-width: 414px) and (orientation: portrait) {
    .image-area {
        flex: 0 0 150px !important;
        height: 150px !important;
    }
    
    .room-image {
        min-height: 150px !important;
        height: 150px !important;
        max-height: 150px !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Force mobile layout for all small screens */
@media screen and (max-width: 768px) {
    body {
        align-items: flex-start !important;
        padding-top: 5px !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
    }
    
    .game-container {
        padding: 10px !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100vh - 20px) !important;
        height: calc(100dvh - 20px) !important; /* Dynamic viewport height with buffer */
        max-height: calc(100vh - 20px) !important;
        max-height: calc(100dvh - 20px) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    
    .content-area {
        flex-direction: column !important;
        gap: 0px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .game-area {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        max-height: calc(100vh - 270px) !important; /* Account for image and input areas */
        overflow: hidden !important;
    }
    
    #output {
        flex: 1 !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        padding-bottom: 80px !important; /* Space for fixed input area */
    }
    
    .input-area {
        position: fixed !important;
        bottom: 10px !important;
        left: 10px !important;
        right: 10px !important;
        background: inherit !important;
        z-index: 100 !important;
        padding: 10px !important;
        border-radius: 5px !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3) !important;
    }
    
    .image-area {
        flex: 0 0 150px !important;
        height: 150px !important;
        order: 1 !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .room-image {
        min-height: 150px !important;
        height: 150px !important;
        max-height: 150px !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .game-area {
        order: 2 !important;
        flex: 1 !important;
    }
    
    .input-area {
        flex-direction: row !important;
        gap: 8px !important;
        align-items: stretch !important;
    }
    
    #input {
        flex: 1 !important;
    }
    
    #submit {
        font-size: 16px !important;
        padding: 10px 15px !important;
        min-width: 50px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-indent: -9999px !important;
        overflow: hidden !important;
    }
    
    #submit::before {
        content: "▶" !important;
        text-indent: 0 !important;
        position: absolute !important;
    }
}

/* Fullscreen image modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.image-modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 95%;
    height: 95%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-modal img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}


.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}
