/* Mobile-First Design for GermanFun */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --bg-color: #f8f9fa;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    touch-action: manipulation;
    color: #212529; /* Default text color */
}

#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

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

.screen.active {
    display: block;
}

/* Ensure text is visible on dark gradient background */
/* Only apply to headings that are direct children or in specific containers */
.screen > h1, .screen > h2, .screen > h3, 
.screen > .text-center > h1, 
.screen > .text-center > h2, 
.screen > .text-center > h3 {
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Ensure specific header elements are visible */
.header-section h2,
#leaderboard-screen > .text-center h2,
#lobby-screen > .header-section h2 {
    color: #ffffff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Keep card headings with default dark color for readability on white background */
.card h1, .card h2, .card h3, .card h4, .card h5, .card h6,
.card-header h1, .card-header h2, .card-header h3, .card-header h4, .card-header h5, .card-header h6 {
    color: #212529 !important;
    text-shadow: none !important;
}

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

/* Cards */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

.card-body {
    padding: 1.5rem;
}

/* Buttons - Large Touch Targets */
.btn {
    min-height: 48px;
    font-weight: 600;
    border-radius: 10px;
    touch-action: manipulation;
    user-select: none;
}

.btn-lg {
    min-height: 56px;
    font-size: 1.1rem;
}

/* Form Controls */
.form-control,
.form-control-lg {
    border-radius: 10px;
    border: 2px solid #dee2e6;
    min-height: 48px;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Players List */
.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.player-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.player-score {
    color: var(--primary-color);
    font-weight: bold;
}

/* Game Header */
.game-header {
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    margin-bottom: 20px;
}

/* Help Panel */
.help-panel {
    animation: slideDown 0.3s ease-out;
}

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

.help-request-item {
    background: #fff3cd;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--warning-color);
}

.help-request-item:last-child {
    margin-bottom: 0;
}

/* Question Container */
.question-container {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    min-height: 400px;
}

.question-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
}

.verb-display {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: #e7f3ff;
    border-radius: 15px;
}

/* Answer Options */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.answer-btn {
    min-height: 60px;
    font-size: 1.1rem;
    text-align: left;
    padding: 15px 20px;
    border: 2px solid #dee2e6;
    background: white;
    transition: all 0.2s;
}

.answer-btn:hover,
.answer-btn:active {
    transform: scale(0.98);
    border-color: var(--primary-color);
}

.answer-btn.correct {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.answer-btn.incorrect {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

/* Matching Game */
.matching-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.matching-card {
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 15px;
    font-size: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.matching-card.selected {
    background: #e7f3ff;
    border-color: var(--primary-color);
    transform: scale(0.95);
}

.matching-card.matched {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
    pointer-events: none;
}

/* Memory Game */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.memory-card {
    aspect-ratio: 1;
    min-height: 100px;
    background: var(--primary-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    perspective: 1000px;
}

.memory-card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
}

.memory-card-front {
    background: var(--primary-color);
    color: white;
    font-size: 2rem;
}

.memory-card-back {
    background: white;
    border: 2px solid #dee2e6;
    transform: rotateY(180deg);
    font-size: 0.9rem;
    font-weight: bold;
}

.memory-card.matched {
    opacity: 0.6;
    pointer-events: none;
}

/* Fill Gap Game */
.sentence-display {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    font-size: 1.2rem;
    margin: 20px 0;
    text-align: center;
    line-height: 1.8;
}

.sentence-gap {
    display: inline-block;
    min-width: 120px;
    border-bottom: 3px solid var(--primary-color);
    padding: 0 10px;
    margin: 0 5px;
    font-weight: bold;
    color: var(--primary-color);
}

/* Leaderboard */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.leaderboard-item {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.leaderboard-rank {
    font-size: 1.5rem;
    font-weight: bold;
    color: #6c757d;
    min-width: 40px;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
    color: #ffd700;
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    color: #c0c0c0;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    color: #cd7f32;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.leaderboard-stats {
    font-size: 0.9rem;
    color: #6c757d;
}

.leaderboard-score {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.badge-container {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.player-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e7f3ff;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Result Feedback */
.result-feedback {
    padding: 30px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: center;
    animation: bounceIn 0.5s;
}

.result-feedback.correct {
    background: #d1e7dd;
    color: #0f5132;
}

.result-feedback.incorrect {
    background: #f8d7da;
    color: #842029;
}

.result-feedback h3 {
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.result-feedback h4 {
    margin-top: 10px;
    font-size: 1.3rem;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Responsive Adjustments */
@media (min-width: 768px) {
    #app {
        padding: 40px 20px;
    }
    
    .memory-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .matching-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Accessibility */
.btn:focus,
.form-control:focus,
.answer-btn:focus,
.matching-card:focus,
.memory-card:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
}


/* WebSocket Status Indicator */
.ws-status {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
    cursor: pointer;
}

.ws-status.connecting {
    background: #ffc107;
    color: #000;
}

.ws-status.connected {
    background: #28a745;
    color: white;
}

.ws-status.disconnected {
    background: #6c757d;
    color: white;
}

.ws-status.error {
    background: #dc3545;
    color: white;
    animation: pulseWS 1s infinite;
}

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

@media (max-width: 768px) {
    .ws-status {
        top: 5px;
        left: 5px;
        font-size: 0.7rem;
        padding: 5px 10px;
    }
}
