* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation; /* Prevents double-tap zoom */
    overflow: hidden;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

/* Group Selection Screen */
#group-selection .container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 30px 20px;
    margin: 20px;
    margin-top: 60px;
}

#group-selection h1 {
    font-size: 2em;
    margin-bottom: 15px;
    color: #333;
}

#group-selection p {
    font-size: 1.1em;
    color: #666;
    margin-bottom: 25px;
}

#group-select {
    width: 100%;
    padding: 18px;
    font-size: 1.2em;
    border: 2px solid #ddd;
    border-radius: 12px;
    margin-bottom: 15px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E") no-repeat right 15px center;
    background-size: 12px;
}

#start-btn {
    width: 100%;
    padding: 20px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

#start-btn:active:not(:disabled) {
    transform: scale(0.98);
}

#start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Game Screen - Mobile First */
#game-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: rgba(255, 255, 255, 0.98);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.group-info {
    font-weight: bold;
    font-size: 1.1em;
    color: #667eea;
}

.progress {
    font-size: 0.95em;
    color: #666;
    font-weight: 500;
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.riddle-section {
    background: white;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 50vh;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.riddle-section h2 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.4em;
}

#riddle-text {
    font-size: 1.15em;
    line-height: 1.7;
    margin-bottom: 15px;
    color: #333;
    padding: 18px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.instruction {
    color: #666;
    font-style: italic;
    margin-bottom: 15px;
    font-size: 1em;
}

.fun-content {
    margin: 15px 0;
    padding: 15px;
    background: #fff3cd;
    border-radius: 12px;
    border-left: 4px solid #ffc107;
}

.fun-content.hidden {
    display: none;
}

.fun-text {
    font-size: 1.05em;
    color: #856404;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.5;
}

.fun-image {
    width: 100%;
    max-width: 100%;
    border-radius: 12px;
    margin-top: 10px;
}

.submit-answer-btn {
    width: 100%;
    padding: 18px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 15px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.submit-answer-btn:active:not(:disabled) {
    background: #5568d3;
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.submit-answer-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.give-up-section {
    margin: 20px 0;
}

details {
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 15px;
}

summary {
    cursor: pointer;
    font-weight: 600;
    color: #764ba2;
    padding: 5px;
    font-size: 1.05em;
    -webkit-tap-highlight-color: transparent;
}

.give-up-content {
    margin-top: 15px;
}

#password-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 1.1em;
}

#reveal-btn {
    width: 100%;
    padding: 16px;
    background: #764ba2;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}

#reveal-btn:active {
    background: #5a3880;
    transform: scale(0.98);
}

.answer-section {
    background: #e8f5e9;
    padding: 18px;
    border-radius: 12px;
    margin: 15px 0;
}

.answer-section.hidden {
    display: none;
}

.answer-section h3 {
    color: #2e7d32;
    margin-bottom: 10px;
    font-size: 1.2em;
}

#answer-text {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #333;
    line-height: 1.6;
}

#next-riddle-btn {
    width: 100%;
    padding: 18px;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

#next-riddle-btn:active {
    background: #1b5e20;
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.4);
}

.feedback {
    margin-top: 12px;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    display: none;
    font-size: 1.05em;
    line-height: 1.5;
}

.feedback.success {
    display: block;
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.feedback.error {
    display: block;
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.error {
    color: #dc3545;
    margin-top: 5px;
    font-size: 1em;
}

.map-section {
    flex: 1;
    position: relative;
    min-height: 300px;
}

#map {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Make map markers more touch-friendly */
.leaflet-marker-icon {
    cursor: pointer !important;
}

.leaflet-popup-content {
    font-size: 1.1em;
    line-height: 1.5;
}

/* Completion Screen */
#completion-screen .container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 40px 25px;
    margin: 20px;
    margin-top: 80px;
}

#completion-screen h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #667eea;
}

#completion-screen p {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 15px;
    line-height: 1.6;
}

#restart-btn {
    margin-top: 30px;
    padding: 18px 40px;
    font-size: 1.2em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}

#restart-btn:active {
    transform: scale(0.98);
}

/* Tablet and Desktop Adjustments */
@media (min-width: 768px) {
    .content {
        flex-direction: row;
    }

    .riddle-section {
        width: 45%;
        max-height: none;
        border-right: 1px solid #ddd;
        padding: 30px;
    }

    .riddle-section h2 {
        font-size: 1.6em;
    }

    #riddle-text {
        font-size: 1.25em;
        padding: 20px;
    }

    .map-section {
        width: 55%;
        min-height: auto;
    }

    #group-selection .container,
    #completion-screen .container {
        max-width: 600px;
        padding: 60px 40px;
        margin-top: 100px;
    }

    #group-selection h1 {
        font-size: 2.5em;
    }

    #completion-screen h1 {
        font-size: 3em;
    }
}

@media (min-width: 1024px) {
    .riddle-section {
        width: 40%;
        padding: 35px;
    }

    .map-section {
        width: 60%;
    }
}

/* Improve touch targets on all screen sizes */
button, a, summary, select {
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
    select,
    input[type="password"] {
        font-size: 16px !important;
    }
}

