/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

nav {
    padding: 1rem 0;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-main {
    text-align: center;
    flex: 1;
    min-width: 300px;
}

.nav-main h1 {
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1rem;
}

/* Location Display */
.location-display {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    min-width: 250px;
    transition: all 0.3s ease;
    animation: slideInRight 0.5s ease-out;
}

.location-display.hidden {
    display: none;
}

.location-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.location-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.location-details {
    flex: 1;
    min-width: 0;
}

.location-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-meta {
    font-size: 0.8rem;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clear-location-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.2rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.clear-location-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 0;
}

.section {
    margin-bottom: 3rem;
}

.section.hidden {
    display: none;
}

/* Welcome section */
#welcome {
    text-align: center;
    color: white;
}

#welcome h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#welcome p {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.ai-powered {
    font-size: 1rem !important;
    color: #f39c12 !important;
    font-weight: bold;
    margin-bottom: 2rem !important;
}

/* Location section */
#location-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.location-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-container {
    display: flex;
    gap: 0.5rem;
}

#location-search {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

#location-search:focus {
    outline: none;
    border-color: #667eea;
}

.location-result {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 1rem;
}

/* Trivia section */
#trivia-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.trivia-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.trivia-card h3 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 1rem;
}

#trivia-question {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: #34495e;
}

.trivia-options {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.option-button {
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    background: white;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.option-button:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.option-button.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.option-button.correct {
    border-color: #27ae60;
    background: #27ae60;
    color: white;
}

.option-button.incorrect {
    border-color: #e74c3c;
    background: #e74c3c;
    color: white;
}

.trivia-answer {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

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

#answer-explanation {
    margin-top: 0.5rem;
    color: #7f8c8d;
    font-style: italic;
}

.trivia-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-tertiary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-tertiary {
    background: #95a5a6;
    color: white;
}

.btn-tertiary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.4);
}

.hidden {
    display: none !important;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    text-align: center;
    padding: 1rem 0;
    margin-top: auto;
    backdrop-filter: blur(10px);
}

footer p {
    color: #7f8c8d;
}

/* API Key Section */
.api-key-setup {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    margin: 0 auto;
}

.api-key-setup h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 1rem;
}

.api-key-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
    border-left: 4px solid #3498db;
}

.api-key-info ol {
    margin: 0.5rem 0 0 1rem;
}

.api-key-info li {
    margin-bottom: 0.5rem;
}

.api-key-info a {
    color: #3498db;
    text-decoration: none;
}

.api-key-info a:hover {
    text-decoration: underline;
}

.api-key-note {
    margin-top: 1rem;
    text-align: center;
}

.api-key-note small {
    color: #7f8c8d;
}

/* Loading Screen */
#loading-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-screen {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
}

.loading-animation {
    position: relative;
    margin: 0 auto 2rem;
    width: 120px;
    height: 120px;
}

.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    width: 120px;
    height: 120px;
    border: 4px solid #e1e8ed;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 2s linear infinite;
}

.loading-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    margin: -30px 0 0 -30px;
    background: #667eea;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% { 
        transform: scale(0.5);
        opacity: 0.3;
    }
    50% { 
        transform: scale(1);
        opacity: 0.8;
    }
}

#loading-title {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

#loading-message {
    color: #7f8c8d;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.loading-progress {
    margin: 2rem 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e1e8ed;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    width: 0%;
    transition: width 0.5s ease;
    animation: progressShimmer 2s infinite;
}

@keyframes progressShimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.progress-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border-radius: 12px;
    background: #f8f9fa;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.step.active {
    background: #667eea;
    color: white;
    opacity: 1;
    transform: scale(1.05);
}

.step.completed {
    background: #27ae60;
    color: white;
    opacity: 1;
}

.step-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.step-text {
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
}

.loading-tips {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin: 1.5rem 0;
    border-left: 4px solid #3498db;
}

#loading-tip {
    margin: 0;
    color: #2c3e50;
    font-size: 0.95rem;
}

#cancel-loading {
    margin-top: 1rem;
}

/* Button States */
.btn-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    color: white;
}

/* Loading Screen Transitions */
.section-transition {
    animation: fadeInUp 0.5s ease-out;
}

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

.loading-fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .nav-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .nav-main {
        min-width: auto;
    }
    
    .nav-main h1 {
        font-size: 1.5rem;
    }
    
    .location-display {
        min-width: auto;
        width: 100%;
        max-width: 350px;
    }
    
    #welcome h2 {
        font-size: 2rem;
    }
    
    #welcome p {
        font-size: 1rem;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .trivia-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-primary,
    .btn-secondary,
    .btn-tertiary {
        width: 100%;
        max-width: 200px;
    }

    /* Loading screen mobile styles */
    .loading-screen {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }

    .loading-animation {
        width: 80px;
        height: 80px;
    }

    .loading-spinner {
        width: 80px;
        height: 80px;
    }

    .loading-pulse {
        width: 40px;
        height: 40px;
        margin: -20px 0 0 -20px;
    }

    #loading-title {
        font-size: 1.4rem;
    }

    .progress-steps {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .step {
        padding: 0.75rem 0.5rem;
    }

    .step-icon {
        font-size: 1.2rem;
    }

    .step-text {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .section {
        margin-bottom: 2rem;
    }
    
    #location-section,
    #trivia-section {
        padding: 1rem;
    }
    
    .trivia-card {
        padding: 1rem;
    }
    
    nav h1 {
        font-size: 1.3rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
}