/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Touch optimization for mobile */
button, .answer-btn, .menu-btn, .action-btn {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Prevent zoom on input focus for iOS */
input, select, textarea {
    font-size: 16px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #ffffff;
    overflow: hidden;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
}

.loading-content {
    text-align: center;
    animation: fadeIn 1s ease-in-out;
}

.gaussian-logo {
    font-size: 4rem;
    color: #64ffda;
    margin-bottom: 2rem;
    animation: rotate 2s linear infinite;
}

.game-title {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffffff;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(100, 255, 218, 0.5);
}

.game-subtitle {
    font-size: 1.2rem;
    color: #b0bec5;
    margin-bottom: 2rem;
}

.loading-bar {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin: 2rem auto;
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #64ffda, #00bcd4);
    width: 0%;
    animation: loading 3s ease-in-out forwards;
}

.loading-text {
    color: #90a4ae;
    font-size: 1rem;
    margin-top: 1rem;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes loading {
    to { width: 100%; }
}

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

/* ===== GAME CONTAINER ===== */
.game-container {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    overflow: hidden;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===== TITLE SCREEN ===== */
#title-screen {
    background: radial-gradient(ellipse at center, rgba(100, 255, 218, 0.1) 0%, transparent 70%),
                linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    align-items: center;
    justify-content: center;
}

.title-content {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

.title-logo {
    margin-bottom: 3rem;
}

.gaussian-icon {
    font-size: 5rem;
    color: #64ffda;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

.title-logo h1 {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: #ffffff;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 30px rgba(100, 255, 218, 0.5);
}

.subtitle {
    font-size: 1.2rem;
    color: #b0bec5;
    margin-bottom: 1rem;
}

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

.menu-btn {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.menu-btn:hover:not(:disabled) {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(100, 255, 218, 0.3);
}

.menu-btn.primary {
    background: linear-gradient(135deg, #64ffda, #00bcd4);
    color: #1a1a2e;
    font-weight: 700;
}

.menu-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.title-info {
    font-size: 0.9rem;
    color: #90a4ae;
    line-height: 1.6;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== MAP SCREEN ===== */
#map-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(100, 255, 218, 0.2);
}

.map-title h2 {
    font-family: 'Orbitron', monospace;
    color: #64ffda;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-status {
    display: flex;
    align-items: center;
    gap: 2rem;
    font-weight: 500;
}

.level {
    color: #ffd700;
    font-weight: 700;
}

.exp {
    color: #90a4ae;
}

.map-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#world-map {
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 15px;
    background: radial-gradient(circle at center, rgba(100, 255, 218, 0.05) 0%, transparent 70%);
    cursor: crosshair;
    max-width: 100%;
    max-height: 100%;
}

/* ===== LOCATION PANEL ===== */
.location-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #64ffda;
    border-radius: 15px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.location-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(100, 255, 218, 0.3);
}

.location-header h3 {
    color: #64ffda;
    font-size: 1.4rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: #90a4ae;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #ff5722;
}

.location-content p {
    color: #b0bec5;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.location-actions {
    display: flex;
    gap: 1rem;
}

.action-btn {
    flex: 1;
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
}

.action-btn.primary {
    background: linear-gradient(135deg, #64ffda, #00bcd4);
    color: #1a1a2e;
    font-weight: 700;
}

/* ===== MAP CONTROLS ===== */
.map-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-top: 2px solid rgba(100, 255, 218, 0.2);
}

.control-btn {
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateY(-2px);
}

/* ===== BATTLE SCREEN ===== */
#battle-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#battle-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.3);
    z-index: 0;
}

#battle-screen > * {
    position: relative;
    z-index: 1;
}

/* Ensure result area is always on top */
#battle-screen .result-area {
    z-index: 9999 !important;
}

.battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(100, 255, 218, 0.2);
    height: 50px; /* Reduced header height */
    flex-shrink: 0; /* Prevent shrinking */
    box-sizing: border-box;
}

.location-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(100, 255, 218, 0.1);
    border-radius: 20px;
    color: #64ffda;
    font-weight: 500;
}

.battle-progress {
    color: #ffd700;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Header menu button - small and compact */
#battle-menu.battle-menu-btn {
    background: rgba(100, 255, 218, 0.1) !important;
    border: 1px solid rgba(100, 255, 218, 0.3) !important;
    border-radius: 6px !important;
    color: #64ffda !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-size: 0.9rem !important;
    padding: 0.4rem 0.6rem !important;
    width: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 32px !important;
    height: 32px !important;
}

/* Battle Menu Overlay */
.battle-menu-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9000 !important;
    animation: battle-menu-fade-in 0.3s ease !important;
}

/* Battle Menu Container */
.battle-menu {
    background: rgba(26, 26, 46, 0.95) !important;
    border: 2px solid #64ffda !important;
    border-radius: 15px !important;
    padding: 2rem !important;
    min-width: 320px !important;
    max-width: 400px !important;
    width: 90% !important;
    text-align: center !important;
    animation: battle-menu-slide-up 0.3s ease !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5) !important;
}

.battle-menu-title {
    color: #64ffda !important;
    margin-bottom: 1.5rem !important;
    font-size: 1.3rem !important;
    font-weight: 600 !important;
}

.battle-menu-options {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.8rem !important;
}

/* Battle Menu Buttons */
.battle-menu-btn {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 1rem 1.5rem !important;
    background: rgba(100, 255, 218, 0.1) !important;
    border: 2px solid rgba(100, 255, 218, 0.3) !important;
    border-radius: 10px !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    font-size: 1rem !important;
    font-family: 'Noto Sans JP', sans-serif !important;
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.8rem !important;
}

.battle-menu-btn:hover {
    background: rgba(100, 255, 218, 0.2) !important;
    border-color: #64ffda !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(100, 255, 218, 0.3) !important;
}

.battle-menu-btn:active {
    transform: translateY(0) !important;
}

/* Animation keyframes */
@keyframes battle-menu-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes battle-menu-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== NEW LAYOUT: CHARACTER DISPLAY ===== */
.character-display {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Main content area - horizontal layout */
.character-main {
    flex: 1;
    display: flex;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.8) 0%, rgba(22, 33, 62, 0.9) 100%);
    position: relative;
    height: calc(100vh - 50px); /* Adjust for smaller header */
    max-height: calc(100vh - 50px);
}

/* Character card container - left side (40% width) */
.character-side {
    flex: 0 0 40%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.character-card {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 2/3; /* Maintain proper card ratio */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 1000px;
}

/* Content area - right side (60% width) */
.content-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    min-height: 0; /* Allow shrinking */
    gap: 1rem;
}

.character-card-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, rgba(100, 255, 218, 0.1) 0%, rgba(0, 188, 212, 0.1) 100%);
    border: 3px solid #64ffda;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(100, 255, 218, 0.3);
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

.character-card-inner:hover {
    transform: rotateY(2deg) rotateX(2deg) scale(1.02);
}

/* Character image with proper aspect ratio */
.character-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Maintain aspect ratio while fitting in container */
    object-position: center;
}

/* Dialogue section at top of content side */
.dialogue-section {
    flex: 0 0 auto;
    padding: 0.8rem;
    background: rgba(22, 33, 62, 0.8);
    border-radius: 15px;
    order: 1; /* Show first */
}

/* Question section below dialogue */
.question-section {
    flex: 1;
    display: none; /* Hidden by default */
    flex-direction: column;
    overflow-y: auto;
    order: 2; /* Show second */
}

.character-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        180deg, 
        transparent 0%, 
        transparent 60%, 
        rgba(0, 0, 0, 0.6) 100%
    );
    pointer-events: none;
    z-index: 2;
}

.character-rarity {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 3;
    backdrop-filter: blur(10px);
}

.character-fallback h3 {
    color: #64ffda;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.character-fallback p {
    color: #90a4ae;
    font-size: 1rem;
}

@keyframes cardEntrance {
    0% {
        transform: scale(0.8) rotateY(-20deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.05) rotateY(10deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotateY(0deg);
        opacity: 1;
    }
}

/* Removed - now handled inline in JavaScript */

.character-dialogue {
    flex: 1;
    display: flex;
    align-items: center;
}

/* NEW LAYOUT: Dialogue box styles */
.dialogue-box {
    background: rgba(22, 33, 62, 0.95);
    border: 2px solid rgba(100, 255, 218, 0.4);
    border-radius: 15px;
    padding: 1.2rem;
    margin: 0;
    backdrop-filter: blur(15px);
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.dialogue-text {
    color: #ffffff;
    line-height: 1.6;
    font-size: 1.1rem;
    margin: 0;
    padding-right: 60px; /* Space for next button */
}

.dialogue-controls {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.dialogue-btn {
    background: rgba(100, 255, 218, 0.2);
    border: 1px solid #64ffda;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #64ffda;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important;
    z-index: 100;
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: none; /* Hidden by default */
}

.dialogue-btn:hover {
    background: #64ffda;
    color: #1a1a2e;
    transform: scale(1.1);
}

/* Interactive dialogue state */
.dialogue-interactive {
    cursor: pointer !important;
}

.dialogue-interactive::after {
    content: '';
    position: absolute;
    bottom: 10px;
    right: 15px;
    width: 8px;
    height: 8px;
    background: #64ffda;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* Ensure dialogue button is always visible and clickable */
.dialogue-btn-ready {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 1000 !important;
    position: relative !important;
    background: rgba(100, 255, 218, 0.3) !important;
    animation: button-pulse 1.5s infinite !important;
}

@keyframes button-pulse {
    0%, 100% { 
        background: rgba(100, 255, 218, 0.3);
        transform: scale(1);
    }
    50% { 
        background: rgba(100, 255, 218, 0.5);
        transform: scale(1.05);
    }
}

/* ===== NEW LAYOUT: QUESTION AREA ===== */
.question-area {
    height: 100%;
    overflow: visible;
    padding: 0;
    margin: 0;
}

/* Question content styling */
.question-content {
    background: rgba(26, 26, 46, 0.6);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(10px);
}

.question-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(100, 255, 218, 0.2);
}

.question-header h3 {
    color: #64ffda;
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

#question-text {
    color: #ffffff;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Answer options */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.answer-btn {
    background: rgba(100, 255, 218, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 10px;
    padding: 1rem;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.answer-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateY(-2px);
}

.answer-btn.selected {
    background: rgba(100, 255, 218, 0.3);
    border-color: #64ffda;
    box-shadow: 0 5px 15px rgba(100, 255, 218, 0.3);
}

.option-letter {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    background: rgba(100, 255, 218, 0.2);
    border: 1px solid #64ffda;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #64ffda;
}

.option-text {
    flex: 1;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .character-main {
        flex-direction: column;
    }
    
    .character-side {
        flex: 0 0 40vh;
        padding: 1rem;
    }
    
    .content-side {
        flex: 1;
        padding: 1rem;
    }
    
    .character-card {
        max-width: 300px;
    }
    
    .question-content {
        padding: 1rem;
    }
    
    .dialogue-section {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .character-side {
        flex: 0 0 35vh;
        padding: 0.5rem;
    }
    
    .content-side {
        padding: 0.5rem;
    }
    
    .character-card {
        max-width: 250px;
    }
    
    .question-content {
        padding: 0.8rem;
    }
    
    .dialogue-section {
        padding: 0.8rem;
    }
    
    #question-text {
        font-size: 1rem;
    }
    
    .answer-btn {
        padding: 0.8rem;
    }
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(100, 255, 218, 0.2);
}

.question-header h3 {
    color: #64ffda;
    font-size: 1.4rem;
    font-weight: 700;
}

.question-meta {
    display: flex;
    gap: 1rem;
}

.difficulty, .category {
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
}

.difficulty {
    background: rgba(255, 215, 0, 0.2);
    color: #ffd700;
    border: 1px solid #ffd700;
}

.category {
    background: rgba(100, 255, 218, 0.2);
    color: #64ffda;
    border: 1px solid #64ffda;
}

.question-content {
    margin-bottom: 2rem;
}

#question-text {
    color: #ffffff;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 4px solid #64ffda;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.answer-btn {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #ffffff;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    gap: 1rem;
}

.answer-btn:hover {
    background: rgba(100, 255, 218, 0.1);
    border-color: rgba(100, 255, 218, 0.3);
    transform: translateX(5px);
}

.answer-btn.selected {
    background: rgba(100, 255, 218, 0.4);
    border-color: #64ffda;
    border-width: 3px;
    box-shadow: 0 0 20px rgba(100, 255, 218, 0.6);
    transform: translateX(8px) scale(1.02);
}

.answer-btn.selected .option-text {
    color: #ffffff;
    font-weight: 700;
}

.answer-btn.selected .option-letter {
    background: #64ffda;
    color: #1a1a2e;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(100, 255, 218, 0.8);
}

/* Enhanced selection animations */
@keyframes selectPulse {
    0% {
        transform: translateX(8px) scale(1.02);
    }
    50% {
        transform: translateX(12px) scale(1.05);
        box-shadow: 0 0 30px rgba(100, 255, 218, 0.8);
    }
    100% {
        transform: translateX(8px) scale(1.02);
        box-shadow: 0 0 20px rgba(100, 255, 218, 0.6);
    }
}

@keyframes buttonEnable {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== NEW INSTANT FEEDBACK SYSTEM ===== */

/* Correct answer animation */
@keyframes correctPulse {
    0%, 100% { 
        transform: scale(1); 
    }
    25% { 
        transform: scale(1.03);
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.8);
    }
    50% { 
        transform: scale(1.06);
        box-shadow: 0 0 35px rgba(76, 175, 80, 1);
    }
    75% { 
        transform: scale(1.03);
        box-shadow: 0 0 25px rgba(76, 175, 80, 0.8);
    }
}

/* Incorrect answer shake animation */
@keyframes incorrectShake {
    0%, 100% { 
        transform: translateX(0); 
    }
    10%, 30%, 50%, 70%, 90% { 
        transform: translateX(-8px); 
    }
    20%, 40%, 60%, 80% { 
        transform: translateX(8px); 
    }
}

/* Slide up animation for explanations */
@keyframes slideUp {
    from { 
        transform: translateY(20px); 
        opacity: 0; 
        max-height: 0;
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
        max-height: 100px;
    }
}

/* Instant feedback states */
.answer-btn.instant-correct {
    background: rgba(76, 175, 80, 0.3) !important;
    border-color: #4caf50 !important;
    border-width: 3px !important;
    animation: correctPulse 0.8s ease-out;
}

.answer-btn.instant-incorrect {
    background: rgba(244, 67, 54, 0.3) !important;
    border-color: #f44336 !important;
    border-width: 3px !important;
    animation: incorrectShake 0.6s ease-out;
}

.answer-btn.instant-unselected {
    opacity: 0.4 !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.answer-btn.instant-correct .option-letter {
    background: #4caf50 !important;
    color: white !important;
    font-weight: 800;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.8);
}

.answer-btn.instant-incorrect .option-letter {
    background: #f44336 !important;
    color: white !important;
    font-weight: 800;
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.8);
}

/* Inline explanation styles */
.answer-explanation {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    display: none;
    animation: slideUp 0.4s ease-out;
}

.answer-explanation.show {
    display: block;
}

.answer-explanation.correct {
    background: rgba(76, 175, 80, 0.15);
    border-left: 4px solid #4caf50;
    color: #e8f5e8;
}

.answer-explanation.incorrect {
    background: rgba(244, 67, 54, 0.15);
    border-left: 4px solid #f44336;
    color: #ffebee;
}

/* Character reaction box */
.character-reaction {
    background: rgba(100, 255, 218, 0.1);
    border: 2px solid #64ffda;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 20px 0;
    text-align: center;
    animation: slideUp 0.5s ease-out;
    display: none;
}

.character-reaction.show {
    display: block;
}

.character-reaction.correct {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
}

.character-reaction.incorrect {
    background: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
}

/* Statistics display */
.stats-display {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 12px 16px;
    margin: 15px 0;
    gap: 15px;
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    margin: 2px 0;
}

.stat-label {
    font-size: 0.8rem;
    color: #90a4ae;
}

.stat-item.positive .stat-value {
    color: #4caf50;
}

.stat-item.bonus .stat-value {
    color: #ff9800;
}

.stat-item.neutral .stat-value {
    color: #64ffda;
}

/* Progress indicator */
.progress-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.progress-dot.completed {
    background: #4caf50;
    transform: scale(1.2);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.progress-dot.current {
    background: #64ffda;
    transform: scale(1.4);
    box-shadow: 0 0 12px rgba(100, 255, 218, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

/* Next Question Button System */
.next-question-button {
    text-align: center;
    margin: 20px 0;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.next-question-button.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.next-button-container {
    border-radius: 15px;
    padding: 20px;
    animation: successGlow 0.6s ease-out;
}

.next-button-container.success {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4caf50;
}

.next-button-container.continue {
    background: rgba(255, 152, 0, 0.1);
    border: 2px solid #ff9800;
    animation: continueGlow 0.6s ease-out;
}

.success-message {
    color: #4caf50;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.continue-message {
    color: #ff9800;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.success-icon {
    font-size: 1.5rem;
    animation: bounce 1s ease-in-out infinite;
}

.continue-icon {
    font-size: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
}

.next-question-btn {
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto;
    transition: all 0.3s ease;
    color: white;
}

.next-question-btn.success {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.next-question-btn.success:hover {
    background: linear-gradient(135deg, #66bb6a, #81c784);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.next-question-btn.continue {
    background: linear-gradient(135deg, #ff9800, #ffb74d);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
}

.next-question-btn.continue:hover {
    background: linear-gradient(135deg, #ffb74d, #ffcc02);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

.next-question-btn:active {
    transform: translateY(0);
}

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

@keyframes successGlow {
    0% {
        box-shadow: 0 0 0 rgba(76, 175, 80, 0);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.6);
    }
    100% {
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
    }
}

@keyframes continueGlow {
    0% {
        box-shadow: 0 0 0 rgba(255, 152, 0, 0);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 152, 0, 0.6);
    }
    100% {
        box-shadow: 0 0 15px rgba(255, 152, 0, 0.3);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
    60% {
        transform: translateY(-3px);
    }
}

/* Legacy auto-advance (for backward compatibility) */
.auto-advance {
    text-align: center;
    margin: 20px 0;
    padding: 10px;
    background: rgba(100, 255, 218, 0.1);
    border-radius: 8px;
    border: 1px solid #64ffda;
    display: none;
}

.auto-advance.show {
    display: block;
    animation: slideUp 0.3s ease-out;
}

.countdown-circle {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #64ffda;
    border-radius: 50%;
    margin: 0 10px;
    position: relative;
    animation: spin 3s linear;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== INCORRECT ANSWER CHOICE SYSTEM ===== */

.incorrect-choice-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.incorrect-choice-overlay.show {
    opacity: 1;
    visibility: visible;
}

.incorrect-choice-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border: 3px solid #f44336;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(244, 67, 54, 0.3);
    animation: modalSlideIn 0.4s ease-out;
    position: relative;
}

.incorrect-choice-modal::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #f44336, #e91e63, #f44336);
    border-radius: 15px;
    z-index: -1;
    animation: glowBorder 2s ease-in-out infinite alternate;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes glowBorder {
    from {
        box-shadow: 0 0 20px rgba(244, 67, 54, 0.5);
    }
    to {
        box-shadow: 0 0 40px rgba(244, 67, 54, 0.8);
    }
}

.incorrect-icon {
    font-size: 4rem;
    color: #f44336;
    margin-bottom: 20px;
    animation: shake 0.6s ease-out;
}

.incorrect-title {
    font-size: 1.8rem;
    color: #f44336;
    font-weight: bold;
    margin-bottom: 15px;
}

.incorrect-message {
    color: #b0bec5;
    line-height: 1.6;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

.incorrect-warning {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid #ff9800;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    color: #ffcc02;
    font-size: 0.95rem;
    line-height: 1.5;
}

.incorrect-warning .warning-icon {
    color: #ff9800;
    margin-right: 8px;
    font-size: 1.1rem;
}

.incorrect-choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
}

.incorrect-choice-btn {
    padding: 15px 20px;
    border: 2px solid;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    min-height: 60px;
}

.incorrect-choice-btn.continue {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4caf50;
    color: #4caf50;
}

.incorrect-choice-btn.continue:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: #66bb6a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.incorrect-choice-btn.return {
    background: rgba(33, 150, 243, 0.1);
    border-color: #2196f3;
    color: #2196f3;
}

.incorrect-choice-btn.return:hover {
    background: rgba(33, 150, 243, 0.2);
    border-color: #42a5f5;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

.choice-description {
    font-size: 0.9rem;
    color: #90a4ae;
    margin-top: 5px;
    font-weight: normal;
}

/* ===== COMPREHENSIVE RESPONSIVE DESIGN ===== */

/* Tablet styles (601px - 1024px) */
@media (max-width: 1024px) and (min-width: 601px) {
    .game-title {
        font-size: 2rem;
    }
    
    .game-subtitle {
        font-size: 1rem;
    }
    
    .world-map {
        width: 90%;
        height: 450px;
    }
    
    .location-panel {
        max-width: 350px;
        margin: 20px;
    }
    
    .question-container {
        padding: 20px;
    }
    
    .answer-btn {
        padding: 12px 16px;
        font-size: 1rem;
    }
}

/* Mobile styles (max-width: 600px) */
@media (max-width: 600px) {
    /* Base mobile optimizations */
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    /* Loading Screen Mobile */
    .gaussian-logo {
        font-size: 3rem;
        margin-bottom: 1.5rem;
    }
    
    .game-title {
        font-size: 1.8rem;
        margin-bottom: 1rem;
        line-height: 1.2;
    }
    
    .game-subtitle {
        font-size: 0.9rem;
        margin-bottom: 2rem;
    }
    
    .loading-bar {
        width: 250px;
        height: 6px;
    }
    
    .loading-text {
        font-size: 0.9rem;
    }
    
    /* Title Screen Mobile */
    .title-content {
        padding: 20px;
        text-align: center;
    }
    
    .title-logo h1 {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    .title-logo .subtitle {
        font-size: 0.9rem;
        margin-bottom: 2rem;
    }
    
    .title-menu {
        gap: 15px;
    }
    
    .menu-btn {
        padding: 15px 25px;
        font-size: 1rem;
        width: 100%;
        max-width: 280px;
    }
    
    .title-info {
        margin-top: 30px;
    }
    
    .title-info p {
        font-size: 0.85rem;
        line-height: 1.4;
        margin: 8px 0;
    }
    
    /* Map Screen Mobile */
    .map-content {
        padding: 10px;
        height: calc(100vh - 60px);
        overflow: hidden;
    }
    
    .world-map {
        width: 100%;
        height: calc(100vh - 120px);
        min-height: 400px;
        max-height: 600px;
    }
    
    .location-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 20px 20px 0 0;
        max-width: none;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    .location-header {
        padding: 15px 20px 10px;
        position: sticky;
        top: 0;
        background: inherit;
        z-index: 1;
    }
    
    .location-header h3 {
        font-size: 1.2rem;
    }
    
    .close-btn {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
    
    .location-content {
        padding: 10px 20px 25px;
    }
    
    .location-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-btn {
        width: 100%;
        padding: 15px;
        font-size: 1rem;
        justify-content: center;
    }
    
    .map-controls {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 1000;
    }
    
    .control-btn {
        padding: 12px;
        font-size: 1rem;
        width: 50px;
        height: 50px;
    }
    
    /* Battle Screen Mobile */
    .battle-screen {
        padding: 10px;
        height: 100vh;
        overflow-y: auto;
    }
    
    .battle-header {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .battle-title {
        font-size: 1.5rem;
    }
    
    .battle-controls {
        gap: 8px;
    }
    
    .battle-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        min-width: auto;
    }
    
    .character-display {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .character-info h3 {
        font-size: 1.2rem;
    }
    
    .character-info .character-title {
        font-size: 0.85rem;
    }
    
    .character-avatar {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
    
    /* Question Area Mobile */
    .question-container {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .question-header {
        margin-bottom: 15px;
    }
    
    .question-title {
        font-size: 1.3rem;
    }
    
    .question-meta {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .question-difficulty,
    .question-category {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
    
    .question-content {
        margin: 15px 0;
    }
    
    .question-text {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    /* Answer Options Mobile */
    .answer-options {
        gap: 12px;
        margin: 20px 0;
    }
    
    .answer-btn {
        padding: 15px 12px;
        font-size: 0.95rem;
        line-height: 1.4;
        min-height: 70px;
        display: flex;
        align-items: center;
        text-align: left;
    }
    
    .option-letter {
        font-size: 1.1rem;
        margin-right: 12px;
        flex-shrink: 0;
        width: 25px;
    }
    
    .option-text {
        flex: 1;
        word-wrap: break-word;
    }
    
    /* Stats Display Mobile */
    .stats-display {
        padding: 12px 15px;
        margin: 15px 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-item {
        padding: 8px 10px;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    /* Dialogue Section Mobile */
    .dialogue-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .dialogue-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .dialogue-content {
        margin-left: 15px;
    }
    
    .dialogue-name {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    .dialogue-text {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .continue-prompt {
        font-size: 0.8rem;
        margin-top: 8px;
    }
    
    /* Next Question Button Mobile */
    .next-button-container {
        padding: 15px;
        margin: 15px 0;
    }
    
    .success-message,
    .continue-message {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .success-icon,
    .continue-icon {
        font-size: 1.2rem;
    }
    
    .next-question-btn {
        padding: 15px 25px;
        font-size: 1rem;
        width: 100%;
        max-width: 250px;
    }
    
    /* Incorrect Choice Modal Mobile */
    .incorrect-choice-modal {
        padding: 20px;
        margin: 20px;
        max-width: calc(100vw - 40px);
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
    
    .modal-icon {
        font-size: 3rem;
    }
    
    .modal-header h3 {
        font-size: 1.3rem;
    }
    
    .modal-content p {
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .incorrect-choice-btn {
        padding: 15px 20px;
        font-size: 1rem;
        min-height: 60px;
        width: 100%;
        text-align: center;
    }
    
    .choice-description {
        font-size: 0.8rem;
        margin-top: 5px;
    }
    
    /* Result Area Mobile */
    .result-area {
        padding: 15px;
        margin: 15px 0;
    }
    
    .result-header {
        margin-bottom: 15px;
    }
    
    .result-status {
        font-size: 1.2rem;
    }
    
    .result-details {
        gap: 10px;
    }
    
    .result-item {
        padding: 10px;
    }
    
    .result-label {
        font-size: 0.8rem;
    }
    
    .result-value {
        font-size: 1rem;
    }
    
    .explanation {
        font-size: 0.9rem;
        line-height: 1.5;
        padding: 15px;
    }
}

/* Very small mobile devices (max-width: 360px) */
@media (max-width: 360px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .game-subtitle {
        font-size: 0.8rem;
    }
    
    .menu-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .question-title {
        font-size: 1.1rem;
    }
    
    .answer-btn {
        padding: 12px 10px;
        font-size: 0.9rem;
        min-height: 65px;
    }
    
    .option-letter {
        font-size: 1rem;
        width: 20px;
    }
    
    .next-question-btn {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

/* Landscape mobile orientation */
@media (max-width: 800px) and (orientation: landscape) {
    .loading-screen,
    .battle-screen {
        overflow-y: auto;
    }
    
    .world-map {
        height: calc(100vh - 80px);
    }
    
    .location-panel {
        max-height: 60vh;
    }
    
    .character-display {
        flex-direction: row;
        align-items: center;
        padding: 10px 15px;
    }
    
    .character-avatar {
        width: 50px;
        height: 50px;
        margin-right: 15px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gaussian-logo,
    .character-avatar,
    .dialogue-avatar {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Mobile keyboard open state */
.mobile-device.keyboard-open {
    height: 100vh;
    overflow: hidden;
}

.mobile-device.keyboard-open .battle-screen {
    height: 100vh;
    overflow-y: auto;
}

.mobile-device.keyboard-open .location-panel {
    max-height: 40vh;
}

/* iOS Safari specific fixes */
@supports (-webkit-appearance: none) {
    .mobile-device {
        -webkit-overflow-scrolling: touch;
    }
    
    .mobile-device input,
    .mobile-device textarea {
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* Android Chrome specific fixes */
@media screen and (max-width: 600px) {
    .mobile-device {
        /* Fix viewport jumping on scroll */
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
}

.answer-btn.correct {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4caf50;
}

.answer-btn.incorrect {
    background: rgba(244, 67, 54, 0.2);
    border-color: #f44336;
}

.option-letter {
    width: 30px;
    height: 30px;
    background: rgba(100, 255, 218, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #64ffda;
    flex-shrink: 0;
}

.option-text {
    flex: 1;
    font-size: 1rem;
    line-height: 1.4;
}

.question-controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* ===== RESULT AREA ===== */
.result-area {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8); /* Darker overlay for modal effect */
    display: flex;
    align-items: center; /* Center vertically for popup effect */
    justify-content: center;
    backdrop-filter: blur(15px);
    z-index: 9999;
    animation: modalFadeIn 0.3s ease-out; /* Popup animation */
}

.result-content {
    text-align: center;
    max-width: 600px;
    width: 90%;
    max-height: 80vh; /* Popup-like max height */
    padding: 2.5rem;
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.98) 0%, rgba(16, 21, 62, 0.98) 100%);
    border-radius: 20px;
    border: 3px solid #64ffda;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(100, 255, 218, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1); /* Multiple shadows for depth */
    overflow-y: auto;
    position: relative;
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy popup animation */
    transform-origin: center;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
}

.result-icon .fa-check {
    color: #4caf50;
}

.result-icon .fa-times {
    color: #f44336;
}

#result-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #ffffff;
}

#result-explanation {
    color: #ffffff; /* Brighter text color for better visibility */
    line-height: 1.6;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    max-height: 400px; /* Increased height */
    overflow-y: auto;
    text-align: left;
    padding: 1.5rem;
    background: rgba(100, 255, 218, 0.1); /* More visible background */
    border-radius: 10px;
    border: 1px solid rgba(100, 255, 218, 0.3);
    border-left: 4px solid #64ffda;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.result-btn {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
    transform: translateY(-2px);
}

.result-btn.primary {
    background: linear-gradient(135deg, #64ffda, #00bcd4);
    color: #1a1a2e;
    font-weight: 700;
}

/* ===== GAME OVER SCREEN ===== */
#gameover-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.gameover-content {
    text-align: center;
    max-width: 600px;
    padding: 3rem;
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid #f44336;
    border-radius: 20px;
    backdrop-filter: blur(20px);
}

.gameover-icon {
    font-size: 4rem;
    color: #f44336;
    margin-bottom: 1.5rem;
}

.gameover-content h2 {
    font-size: 2.5rem;
    color: #f44336;
    margin-bottom: 1rem;
    font-weight: 700;
}

#gameover-message {
    color: #b0bec5;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.gameover-stats {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.stat {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    color: #90a4ae;
}

.stat-value {
    color: #ffffff;
    font-weight: 700;
}

.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gameover-btn {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(244, 67, 54, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.gameover-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    border-color: #f44336;
    transform: translateY(-2px);
}

.gameover-btn.primary {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    border-color: #f44336;
}

/* ===== VICTORY SCREEN ===== */
#victory-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.victory-content {
    text-align: center;
    max-width: 700px;
    padding: 3rem;
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid #4caf50;
    border-radius: 20px;
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 10;
}

.victory-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    border-radius: 50%;
    animation: float 3s ease-in-out infinite;
}

.particle:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    top: 60%;
    right: 15%;
    animation-delay: 1s;
}

.particle:nth-child(3) {
    bottom: 30%;
    left: 20%;
    animation-delay: 2s;
}

.victory-icon {
    font-size: 4rem;
    color: #ffd700;
    margin-bottom: 1.5rem;
    animation: bounce 1s ease-in-out infinite;
}

.victory-content h2 {
    font-size: 2.5rem;
    color: #4caf50;
    margin-bottom: 1rem;
    font-weight: 700;
}

.victory-title {
    font-size: 1.3rem;
    color: #ffffff;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.victory-subtitle {
    color: #b0bec5;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.final-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
}

.stat-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1.5rem;
}

.stat-card h4 {
    color: #64ffda;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
}

.stat-label {
    font-size: 0.9rem;
    color: #90a4ae;
}

.achievement-list {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1.5rem;
}

.achievement-list h4 {
    color: #64ffda;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.achievement-list ul {
    list-style: none;
}

.achievement-list li {
    color: #b0bec5;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.achievement-list .fas {
    color: #ffd700;
}

.victory-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.victory-btn {
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(76, 175, 80, 0.3);
    border-radius: 10px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.victory-btn:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4caf50;
    transform: translateY(-2px);
}

.victory-btn.primary {
    background: linear-gradient(135deg, #4caf50, #388e3c);
    border-color: #4caf50;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== MODAL SYSTEM ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    backdrop-filter: blur(10px);
}

.modal {
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #64ffda;
    border-radius: 15px;
    max-width: 90%;
    max-height: 90%;
    min-width: 400px;
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 2px solid rgba(100, 255, 218, 0.2);
}

.modal-header h3 {
    color: #64ffda;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: #90a4ae;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #ff5722;
}

.modal-content {
    padding: 2rem;
    max-height: 500px;
    overflow-y: auto;
}

/* ===== INVENTORY MODAL ===== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.inventory-item {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.inventory-item:hover {
    background: rgba(100, 255, 218, 0.1);
    border-color: #64ffda;
}

.inventory-item.equipped {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.item-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.item-name {
    font-size: 0.9rem;
    color: #ffffff;
    font-weight: 500;
}

.item-description {
    font-size: 0.8rem;
    color: #90a4ae;
    margin-top: 0.3rem;
}

/* ===== STATUS MODAL ===== */
.status-display {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.status-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 1.5rem;
}

.status-section h4 {
    color: #64ffda;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    color: #b0bec5;
}

.status-row span:last-child {
    color: #ffffff;
    font-weight: 600;
}

.progress-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-item span:first-child {
    min-width: 80px;
    color: #90a4ae;
    font-size: 0.9rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #64ffda, #00bcd4);
    transition: width 0.5s ease;
}

/* ===== CONFIRMATION MODAL ===== */
.confirm-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.confirm-btn {
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(100, 255, 218, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.confirm-btn:hover {
    background: rgba(100, 255, 218, 0.2);
    border-color: #64ffda;
}

.confirm-btn.primary {
    background: linear-gradient(135deg, #64ffda, #00bcd4);
    color: #1a1a2e;
    font-weight: 700;
}

/* ===== INFO MODAL ===== */
#info-modal {
    animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Result popup animations */
@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.info-message-content {
    color: #ffffff;
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border-left: 4px solid #64ffda;
    white-space: pre-line; /* 改行を保持 */
}

.info-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.info-btn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #64ffda, #00bcd4);
    border: none;
    border-radius: 10px;
    color: #1a1a2e;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
    justify-content: center;
}

.info-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(100, 255, 218, 0.4);
    background: linear-gradient(135deg, #80ffea, #26c6da);
}

.info-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgba(100, 255, 218, 0.3);
}

/* 情報モーダル用のアイコンカラー */
#info-modal .modal-header h3 i {
    color: #64ffda;
}

/* ===== RESPONSIVE DESIGN FOR INFO MODAL ===== */
@media (max-width: 768px) {
    .modal {
        min-width: 90%;
        max-width: 95%;
        margin: 1rem;
    }
    
    .info-message-content {
        font-size: 1rem;
        padding: 0.8rem;
    }
    
    .info-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .modal-header h3 {
        font-size: 1.2rem;
    }
    
    .modal-content {
        padding: 1.5rem;
    }
    
    /* Battle screen responsive adjustments */
    .battle-header {
        padding: 0.5rem 1rem;
        height: 60px; /* Smaller header on mobile */
    }
    
    .character-display {
        flex-direction: column;
        height: 280px; /* Fixed height for mobile */
        padding: 1rem;
        gap: 1rem;
    }
    
    .character-card {
        width: 200px;
        height: 200px; /* Smaller card for mobile */
    }
    
    .character-dialogue {
        max-width: 100%;
    }
    
    .question-area {
        max-height: calc(100vh - 60px - 280px); /* Adjusted for mobile */
        padding: 1rem;
        min-height: 200px;
    }
    
    #question-text {
        font-size: 1rem;
        padding: 1rem;
    }
    
    .answer-btn {
        font-size: 0.9rem;
        padding: 0.8rem;
    }
    
    /* Result area mobile adjustments */
    .result-content {
        padding: 1.5rem 1rem;
        max-height: 85vh; /* Popup-style height on mobile */
        width: 95%;
        animation-duration: 0.3s; /* Faster animation on mobile */
    }
    
    #result-explanation {
        font-size: 1rem;
        max-height: 250px;
        padding: 1rem;
    }
    
    .result-icon {
        font-size: 3rem; /* Smaller icon on mobile */
    }
}

/* ===== DEBUG PANEL ===== */
.debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(26, 26, 46, 0.95);
    border: 2px solid #ff9800;
    border-radius: 10px;
    padding: 1rem;
    max-width: 300px;
    backdrop-filter: blur(20px);
    z-index: 6000;
}

.debug-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: #ff9800;
}

.debug-header h4 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#toggle-debug {
    background: none;
    border: none;
    color: #90a4ae;
    cursor: pointer;
    font-size: 1.2rem;
}

.debug-section {
    margin-bottom: 1rem;
}

.debug-section h5 {
    color: #64ffda;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.debug-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.debug-info span {
    color: #90a4ae;
    font-size: 0.8rem;
}

.debug-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.debug-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 152, 0, 0.2);
    border: 1px solid #ff9800;
    border-radius: 5px;
    color: #ff9800;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.debug-btn:hover {
    background: #ff9800;
    color: #1a1a2e;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
    .map-container {
        padding: 1rem;
    }
    
    #world-map {
        width: 100%;
        max-width: 700px;
    }
    
    .character-display {
        flex-direction: column;
        align-items: center;
        padding: 1rem;
        gap: 1rem;
    }
    
    .character-card {
        width: 250px;
        height: 320px;
    }
    
    .dialogue-box::before {
        display: none;
    }
    
    .final-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .title-logo h1 {
        font-size: 2rem;
    }
    
    .map-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .player-status {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .character-card {
        width: 200px;
        height: 280px;
    }
    
    .question-controls {
        flex-direction: column;
    }
    
    .result-actions, .gameover-actions, .victory-actions {
        flex-direction: column;
    }
    
    .location-panel {
        width: 95%;
        padding: 1.5rem;
    }
    
    .modal {
        min-width: 90%;
        margin: 1rem;
    }
    
    .debug-panel {
        right: 10px;
        top: 10px;
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    .title-content {
        padding: 1rem;
    }
    
    .gaussian-icon {
        font-size: 3rem;
    }
    
    .game-title {
        font-size: 1.5rem;
    }
    
    .map-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .control-btn {
        flex: 1;
        min-width: 100px;
    }
    
    .battle-header {
        padding: 0.5rem 1rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .character-display {
        padding: 0.5rem;
    }
    
    .question-area {
        padding: 1rem;
    }
    
    #question-text {
        font-size: 1rem;
        padding: 1rem;
    }
    
    .answer-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    
    .option-letter {
        width: 25px;
        height: 25px;
        font-size: 0.8rem;
    }
}

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

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: #64ffda;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #00bcd4;
}

/* ===== SELECTION STYLES ===== */
::selection {
    background: rgba(100, 255, 218, 0.3);
    color: #ffffff;
}

::-moz-selection {
    background: rgba(100, 255, 218, 0.3);
    color: #ffffff;
}