/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #2c3e50;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header Styles */
.game-header {
    text-align: center;
    margin-bottom: 40px;
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.game-header p {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-weight: 300;
}

/* Setup Form Styles */
.setup-form {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e8ecef;
}

.setup-section {
    margin-bottom: 30px;
}

.setup-section h3 {
    font-size: 1.2rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Role Selection */
.role-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.role-btn {
    background: white;
    border: 2px solid #e8ecef;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.role-btn:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.2);
}

.role-btn.selected {
    border-color: #3498db;
    background: #f8fbff;
}

.role-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.role-title {
    font-weight: 500;
    color: #2c3e50;
    font-size: 1rem;
}

.role-desc {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-weight: 300;
}

/* Theme Selection */
.general-btn {
    width: 100%;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 15px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 20px;
}

.general-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.general-btn.selected {
    background: #27ae60;
}

.custom-theme {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-theme label {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 400;
}

.custom-theme input {
    padding: 12px 16px;
    border: 2px solid #e8ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.custom-theme input:focus {
    outline: none;
    border-color: #3498db;
}

.validation-message {
    font-size: 0.85rem;
    padding: 5px 0;
    min-height: 20px;
}

.validation-message.error {
    color: #e74c3c;
}

.validation-message.success {
    color: #27ae60;
}

/* Difficulty Slider */
.difficulty-slider {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-slider input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e8ecef;
    outline: none;
    -webkit-appearance: none;
}

.difficulty-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}

.difficulty-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}

.difficulty-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #7f8c8d;
}

/* Buttons */
.start-btn {
    width: 100%;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 10px;
}

.start-btn:hover:not(:disabled) {
    background: #229954;
    transform: translateY(-1px);
}

.start-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* Game Screen Styles */
.progress-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-weight: 500;
    color: #2c3e50;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e8ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #27ae60);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Game Info */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.info-item {
    flex: 1;
    text-align: center;
    padding: 0 10px;
    border-right: 1px solid #e8ecef;
}

.info-item:last-child {
    border-right: none;
}

.info-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* Conversation */
.game-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

.conversation {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    flex-grow: 1;
    overflow-y: auto;
    height: auto;
    min-height: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.message {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.message.user {
    background: #3498db;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.ai {
    background: #f8f9fa;
    color: #2c3e50;
    border: 1px solid #e8ecef;
    border-bottom-left-radius: 4px;
}

.message.system {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    text-align: center;
    margin: 0 auto 20px 0;
    font-style: italic;
}

/* Input Area */
.input-area {
    margin-bottom: 5px;
}

.input-container {
    position: relative;
    display: flex;
    background: white;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.input-container input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    font-size: 1rem;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    position: relative;
    z-index: 1;
    background-clip: padding-box;
    border-radius: 12px 0 0 12px;
}

.send-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 0 12px 12px 0;
    width: 48px;
    height: 48px;
    padding: 0;
    font-weight: 700;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    user-select: none;
    font-family: Arial, sans-serif;
    box-shadow: none;
}

.send-btn:hover {
    background: #2980b9;
}

.send-btn:disabled {
    background: #bdc3c7;
    color: #7f8c8d;
    cursor: not-allowed;
    transform: none;
}

.send-btn::before {
    content: '▶';
    display: block;
    transform: translateX(1px);
}

.send-btn:hover {
    background: rgba(52, 152, 219, 0.1);
    color: #2980b9;
}

.send-btn:disabled {
    color: #bdc3c7;
    cursor: not-allowed;
    background: transparent;
}

.send-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* Response Buttons */
.response-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.response-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.response-btn {
    background: white;
    border: 2px solid #3498db;
    color: #3498db;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.response-btn:hover {
    background: #3498db;
    color: white;
}

/* Game Controls */
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.control-btn.secondary {
    background: #95a5a6;
}

.control-btn.secondary:hover {
    background: #7f8c8d;
}

/* Score Screen */
.score-header {
    text-align: center;
    margin-bottom: 30px;
}

.score-header h2 {
    font-size: 2rem;
    color: #2c3e50;
    font-weight: 600;
}

.score-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 600;
    color: #3498db;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 400;
}

.score-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e8ecef;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        display: flex;
        flex-direction: column;
        height: 100vh;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .role-buttons {
        grid-template-columns: 1fr;
    }
    
    .setup-form {
        padding: 20px;
    }
    
    .game-info {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        margin-bottom: 10px;
        padding: 5px 10px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        height: 40px;
        overflow: hidden;
    }
    
    .info-item {
        flex: 1;
        text-align: center;
        padding: 0 5px;
        border-right: 1px solid #e8ecef;
        font-size: 0.85rem;
        line-height: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        overflow: hidden;
        white-space: nowrap;
    }
    
    .info-item:last-child {
        border-right: none;
    }
    
    .info-label {
        display: none;
    }
    
    .info-item span:last-child {
        font-weight: 500;
        color: #2c3e50;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .response-buttons {
        flex-direction: column;
    }
    
    .game-controls {
        flex-direction: row;
        justify-content: center;
        gap: 10px;
        margin-top: 10px;
        margin-bottom: 20px;
    }
    
    .control-btn {
        flex: 1;
        padding: 12px 0;
        font-size: 1rem;
    }
    
    .score-actions {
        flex-direction: column;
    }
    
    .input-container {
        flex-direction: row;
    }
    
    .send-btn {
        align-self: center;
        width: 48px;
        height: 48px;
    }

    .game-content {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .conversation {
        flex-grow: 1;
        min-height: 0;
        max-height: none;
        margin-bottom: 10px;
        overflow-y: auto;
    }

    .input-area {
        flex-shrink: 0;
        margin-bottom: 15px;
    }

    .progress-container {
        margin-bottom: 10px;
        padding: 10px 15px;
        height: 20px;
        position: relative;
    }

.progress-label {
    font-size: 0.75rem;
    margin: 0;
    line-height: 20px;
    position: absolute;
    width: 100%;
    text-align: center;
    color: #2c3e50;
    font-weight: 500;
    pointer-events: none;
}

    .progress-bar {
        height: 6px;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.8rem;
    }
    
    .conversation {
        min-height: 300px;
        max-height: none;
    }
    
    .message {
        max-width: 90%;
    }
    
    .stat-number {
        font-size: 2rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .role-btn {
        border-width: 3px;
    }
    
    .message {
        border-width: 2px;
    }
}

/* Hide main content on mobile devices in landscape orientation */
@media (max-width: 768px) and (orientation: landscape) {
    #setup-screen,
    #game-screen,
    #score-screen {
        display: none !important;
    }

    /* Show the landscape overlay message */
    #landscape-overlay {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: white;
        color: #2c3e50;
        font-family: 'Inter', sans-serif;
        font-size: 1.5rem;
        font-weight: 600;
        text-align: center;
        padding: 2rem;
        z-index: 2000;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        line-height: 1.4;
    }
}

/* Adjust game-content height slightly smaller on desktop */
@media (min-width: 769px) {
    .game-content {
        height: calc(100vh - 270px);
    }
}
