/* ===== CSS Custom Properties ===== */
:root {
    /* Colors */
    --primary-color: #7087cf;
    --secondary-color: #ff6b9d;
    --accent-color: #f0d000;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-dark: #333333;
    --bg-overlay: rgba(0, 0, 0, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.1);
    --bg-modal: rgba(0, 0, 0, 0.9);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(45deg, #ff6b9d, #ff8c94);
    --gradient-accent: linear-gradient(45deg, #f0d000, #ffdf00);
    --gradient-glass: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Typography */
    --font-main: 'Noto Sans JP', sans-serif;
    --font-accent: 'Orbitron', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-xxl: 2rem;
    
    /* Animations */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --animation-bounce: cubic-bezier(0.25, 1, 0.5, 1);
    
    /* Z-index layers */
    --z-background: 1;
    --z-character: 10;
    --z-ui: 20;
    --z-modal: 30;
    --z-loading: 40;
    --z-controller: 150; /* コントローラー用の高いz-index */
}

/* ===== Global Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: var(--font-main);
    font-size: var(--font-size-md);
    color: var(--text-primary);
    background: var(--gradient-primary);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

body {
    position: relative;
}

/* ===== Loading Screen ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-loading);
}

.loading-content {
    text-align: center;
    animation: fadeInUp 0.8s var(--animation-bounce);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid var(--text-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto var(--spacing-lg);
}

.loading-text {
    font-size: var(--font-size-lg);
    font-weight: 500;
    margin-bottom: var(--spacing-lg);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.loading-progress {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 3px;
    animation: loading-progress 2s ease-in-out infinite;
}

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

@keyframes loading-progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

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

/* ===== Background Layer ===== */
.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-background);
}

.background-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

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

/* ===== Character Layer ===== */
.character-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-character);
    pointer-events: none;
}

.live2d-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

/* ===== UI Layer ===== */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-ui);
    pointer-events: none;
}

.ui-layer * {
    pointer-events: auto;
}

/* ===== Top UI ===== */
.top-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.title-area {
    animation: slideInLeft 0.8s var(--animation-bounce);
}

.title-main {
    font-size: var(--font-size-xxl);
    font-weight: 700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
    margin-bottom: var(--spacing-xs);
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.title-sub {
    font-family: var(--font-accent);
    font-size: var(--font-size-sm);
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.nav-menu {
    display: flex;
    gap: var(--spacing-sm);
    animation: slideInRight 0.8s var(--animation-bounce);
}

.nav-button {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: var(--spacing-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-button:active {
    transform: translateY(0);
}

.nav-icon {
    font-size: var(--font-size-lg);
}

/* ===== Stats Display ===== */
.stats-display {
    position: absolute;
    top: var(--spacing-xl);
    right: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    animation: fadeInDown 1s var(--animation-bounce) 0.5s both;
}

.stat-item {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: center;
    min-width: 120px;
}

.stat-label {
    display: block;
    font-size: var(--font-size-xs);
    opacity: 0.8;
    margin-bottom: var(--spacing-xs);
}

.stat-value {
    display: block;
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* ===== Message System ===== */
#message-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: var(--spacing-xl);
}

.character-nameplate {
    position: absolute;
    bottom: 100%;
    left: var(--spacing-xl);
    margin-bottom: var(--spacing-sm);
    background: var(--gradient-secondary);
    border: 3px solid var(--text-primary);
    border-radius: 20px 20px 5px 20px;
    padding: var(--spacing-sm) var(--spacing-lg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: translateY(10px);
    opacity: 0;
    transition: all var(--transition-normal);
}

.character-nameplate.show {
    transform: translateY(0);
    opacity: 1;
}

.character-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.message-window {
    background: var(--bg-overlay);
    backdrop-filter: blur(15px);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: var(--spacing-xl);
    min-height: 120px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateY(50px);
    opacity: 0;
    transition: all var(--transition-slow);
}

.message-window.show {
    transform: translateY(0);
    opacity: 1;
}

.message-text {
    font-size: var(--font-size-md);
    line-height: 1.8;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    min-height: 60px;
    display: flex;
    align-items: center;
}

.continue-button {
    position: absolute;
    right: var(--spacing-lg);
    bottom: var(--spacing-lg);
    background: var(--bg-glass);
    border: 2px solid var(--text-primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

.continue-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.continue-icon {
    font-size: var(--font-size-lg);
}

/* ===== Choice System ===== */
.choice-system {
    margin-top: var(--spacing-lg);
    animation: fadeInUp 0.6s var(--animation-bounce);
}

.choice-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    max-width: 600px;
    margin: 0 auto;
}

.choice-button {
    background: var(--gradient-glass);
    backdrop-filter: blur(10px);
    border: 3px solid var(--accent-color);
    border-radius: 25px;
    padding: var(--spacing-lg) var(--spacing-xl);
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: left;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.choice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.6s ease;
}

.choice-button:hover::before {
    left: 100%;
}

.choice-button:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 24px rgba(240, 208, 0, 0.4);
    border-color: #ffdf00;
    background: rgba(255, 255, 255, 0.15);
}

.choice-button:active {
    transform: translateY(-1px) scale(1.01);
}

.choice-icon {
    margin-right: var(--spacing-sm);
    font-size: var(--font-size-lg);
}

/* ===== Message Controls ===== */
.message-controls {
    position: absolute;
    right: var(--spacing-xl);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.control-button {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: var(--spacing-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-normal);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.control-button.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: var(--bg-modal);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: var(--spacing-sm);
    z-index: var(--z-modal);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: fadeInScale 0.2s ease;
}

.context-item {
    padding: var(--spacing-sm) var(--spacing-lg);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-radius: 8px;
    font-size: var(--font-size-sm);
}

.context-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Modals ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-modal);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80%;
    overflow-y: auto;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
    animation: slideInUp 0.4s var(--animation-bounce);
}

.modal-header {
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: var(--font-size-xl);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-xl);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: 8px;
    transition: background var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: var(--spacing-xl);
}

.setting-group {
    margin-bottom: var(--spacing-lg);
}

.setting-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: var(--spacing-md);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: var(--font-size-sm);
    line-height: 1.6;
}

.history-item:last-child {
    border-bottom: none;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

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

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* ===== Responsive Design ===== */
/* レスポンシブ対応はpc-styles.cssとsp-styles.cssに移行済み */
/* DeviceManagerによるデバイス判定でCSSを切り替えるため、メディアクエリは不要 */

/* ===== Special Effects ===== */
.glow {
    box-shadow: 0 0 20px var(--accent-color);
}

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.bounce {
    animation: bounceIn 0.6s var(--animation-bounce);
}

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

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Vue Transitions ===== */
.fade-enter-active, .fade-leave-active {
    transition: opacity 0.3s ease;
}

.fade-enter-from, .fade-leave-to {
    opacity: 0;
}

/* ===== Message Box Improvements ===== */
.message-box {
    cursor: pointer;
    position: relative;
}

.message-box .text-galge-gray {
    color: rgba(255, 255, 255, 0.6);
}

/* タイプライター効果中のカーソル */
.typing-cursor::after {
    content: '|';
    animation: blink 1s infinite;
    opacity: 1;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}