/* リセットとベース設定 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: #e2e8f0;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
}

/* ヘッダー */
header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, #7c2d12 0%, #dc2626 50%, #ef4444 100%);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(124, 45, 18, 0.5);
}

header h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 800;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.01em;
}

header h2 {
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 500;
    opacity: 0.95;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* プロローグ画面 */
.prologue-screen {
    padding: 30px 20px;
    background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
    color: #f9fafb;
    text-align: center;
}

.prologue-content h3 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #fca5a5;
}

.prologue-text {
    max-width: 600px;
    margin: 0 auto 30px;
    font-size: 1.1rem;
    line-height: 1.8;
}

.prologue-text p {
    margin-bottom: 15px;
}

.start-game-btn {
    background: linear-gradient(135deg, #7c2d12 0%, #dc2626 50%, #ef4444 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(124, 45, 18, 0.4);
}

.start-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 45, 18, 0.6);
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 50%, #ef4444 100%);
}

.start-game-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(124, 45, 18, 0.4);
}

/* メインコンテンツ */
main {
    flex: 1;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* 開始画面 */
.start-screen {
    animation: fadeIn 0.5s ease-out;
}

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

/* 現状情報ボックス */
.case-info {
    background: rgba(15, 15, 35, 0.8);
    border: 2px solid #dc2626;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.2);
    backdrop-filter: blur(10px);
}

.case-info h3 {
    color: #fca5a5;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #dc2626;
}

.status-grid {
    display: grid;
    gap: 15px;
}

.status-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 15px;
    background: rgba(30, 30, 46, 0.6);
    border-radius: 8px;
    border-left: 4px solid #dc2626;
}

.status-label {
    font-weight: 600;
    color: #fca5a5;
    font-size: 0.9rem;
}

.status-value {
    color: #e2e8f0;
    font-size: 1rem;
}

/* イントロテキスト */
.intro-text {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid #0284c7;
    text-align: center;
}

.intro-text p {
    margin: 8px 0;
    color: #0284c7;
    font-weight: 500;
}

/* キャラクター選択 */
.character-select {
    background: rgba(15, 15, 35, 0.8);
    border: 2px solid #dc2626;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.2);
    backdrop-filter: blur(10px);
}

.character-select h3 {
    color: #fca5a5;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.character-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px;
    border: 2px solid #dc2626;
    background: linear-gradient(135deg, rgba(30, 30, 46, 0.8) 0%, rgba(45, 45, 61, 0.8) 100%);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 120px;
    backdrop-filter: blur(5px);
}

.character-card:hover {
    transform: translateY(-3px);
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.character-card:hover .character-icon,
.character-card:hover .character-name,
.character-card:hover .character-hint {
    color: #ffffff;
}

.character-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.character-name {
    font-weight: 600;
    color: #fca5a5;
    font-size: 1rem;
    margin-bottom: 5px;
}

.character-hint {
    font-size: 0.8rem;
    color: #9ca3af;
    font-weight: 400;
}

/* ゲーム画面 */
.game-screen {
    animation: slideIn 0.5s ease-out;
}

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

/* ゲームヘッダー */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 15, 35, 0.9);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid #dc2626;
    backdrop-filter: blur(10px);
}

.current-character {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fca5a5;
    text-shadow: 0 0 10px rgba(252, 165, 165, 0.3);
}

.memory-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.memory-label {
    font-size: 0.9rem;
    color: #d1d5db;
    font-weight: 500;
}

.memory-count {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.3);
    border: 1px solid #7c2d12;
}

/* 会話エリア */
.conversation-area {
    background: rgba(15, 15, 35, 0.9);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid #dc2626;
    backdrop-filter: blur(10px);
}

.character-image {
    text-align: center;
    margin-bottom: 20px;
}

.character-image img {
    max-width: 200px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 3px solid #dc2626;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
    transition: all 0.3s ease;
}

.character-image img:hover {
    transform: scale(1.02);
    border-color: #ef4444;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
}

.chat-container {
    min-height: 100px;
}

/* メッセージスタイル */
.message {
    margin-bottom: 15px;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 100%;
    word-wrap: break-word;
}

.message p {
    margin: 0;
}

.user-message {
    background: linear-gradient(135deg, rgba(30, 30, 46, 0.8) 0%, rgba(45, 45, 61, 0.8) 100%);
    color: #fca5a5;
    border: 1px solid #dc2626;
    margin-left: auto;
    margin-right: 0;
    text-align: right;
    backdrop-filter: blur(5px);
}

.bot-message {
    background: linear-gradient(135deg, rgba(124, 45, 18, 0.8) 0%, rgba(87, 83, 35, 0.8) 100%);
    color: #fef3c7;
    border: 1px solid #f59e0b;
    margin-left: 0;
    margin-right: auto;
    backdrop-filter: blur(5px);
}

/* 入力エリア */
.input-area {
    background: rgba(15, 15, 35, 0.9);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid #dc2626;
    backdrop-filter: blur(10px);
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-container input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #7c2d12;
    border-radius: 12px;
    font-size: 16px;
    background: rgba(30, 30, 46, 0.8);
    color: #fca5a5;
    transition: all 0.3s ease;
    outline: none;
    backdrop-filter: blur(5px);
}

.input-container input::placeholder {
    color: #9ca3af;
}

.input-container input:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

.send-btn {
    padding: 14px 24px;
    border: none;
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%);
}

/* ゲームクリアエリア */
.game-clear-area {
    text-align: center;
    margin: 20px 0;
}

.game-clear-btn {
    padding: 20px 40px;
    border: none;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #ffffff;
    border-radius: 16px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
    animation: pulse 2s infinite;
    transition: all 0.3s ease;
}

.game-clear-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(139, 92, 246, 0.6);
}

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

/* 手がかり詳細 */
.memory-details {
    background: rgba(15, 15, 35, 0.9);
    border: 2px solid #dc2626;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.2);
    backdrop-filter: blur(10px);
    position: relative;
}

.memory-details h4 {
    color: #fca5a5;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(252, 165, 165, 0.3);
}

.memory-list {
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.6;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    border-radius: 8px;
    background: rgba(30, 30, 46, 0.5);
    backdrop-filter: blur(5px);
}

.memory-item {
    margin: 8px 0;
    padding: 10px 12px;
    background: rgba(124, 45, 18, 0.3);
    border-radius: 6px;
    border-left: 3px solid #dc2626;
    color: #fef3c7;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(220, 38, 38, 0.3);
    transition: all 0.3s ease;
}

/* アクションボタン */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.action-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 120px;
}

.action-btn.secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
}

.action-btn.secondary:hover {
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
}

.action-btn.danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.3);
}

.action-btn.danger:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

/* モーダルウィンドウ */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: #ffffff;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.4s ease-out;
    border: 1px solid #e2e8f0;
}

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

.modal-content h2 {
    color: #8b5cf6;
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 700;
}

.modal-content p {
    margin-bottom: 30px;
    line-height: 1.8;
    color: #374151;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.play-again-btn {
    padding: 15px 30px;
    border: none;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.play-again-btn:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.close-btn {
    padding: 15px 30px;
    border: 2px solid #6b7280;
    background: transparent;
    color: #6b7280;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #6b7280;
    color: #ffffff;
    transform: translateY(-2px);
}

/* タイムループモーダル専用スタイル */
.loop-modal {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    color: #f9fafb;
    border: 2px solid #fbbf24;
}

.loop-modal h2 {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.loop-message {
    margin: 20px 0;
    color: #ffffff;
}

.loop-message p {
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: #ffffff !important;
}

.loop-warning {
    color: #fbbf24 !important;
    font-weight: 600;
    background: rgba(251, 191, 36, 0.1);
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #fbbf24;
}

.loop-continue-btn {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
}

.loop-continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.6);
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

/* フッター */
footer {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    color: #ffffff;
    margin-top: auto;
}

footer p {
    font-size: 14px;
    opacity: 0.9;
}

/* レスポンシブデザイン - モバイルファースト */
@media (max-width: 768px) {
    main {
        padding: 15px;
    }
    
    header {
        padding: 20px 15px;
    }
    
    .case-info, .conversation-area, .input-area, .memory-details {
        padding: 20px;
    }
    
    .character-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .character-card {
        padding: 15px 10px;
        min-height: 100px;
    }
    
    .character-icon {
        font-size: 1.8rem;
    }
    
    .character-name {
        font-size: 0.9rem;
    }
    
    .character-hint {
        font-size: 0.75rem;
    }
    
    .game-header {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 10px;
        text-align: left;
        padding: 15px;
    }
    
    .current-character {
        font-size: 1rem;
        flex: 1;
        min-width: 200px;
    }
    
    .memory-indicator {
        flex-shrink: 0;
        background: rgba(30, 30, 46, 0.8);
        padding: 8px 12px;
        border-radius: 8px;
        border: 1px solid #dc2626;
    }
    
    .input-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .input-container input,
    .send-btn {
        width: 100%;
    }
    
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-content {
        margin: 15px;
        padding: 25px;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-buttons button {
        width: 100%;
    }
    
    .character-image img {
        max-width: 180px;
    }
    
    .memory-details {
        position: sticky;
        top: 10px;
        z-index: 10;
    }
    
    .memory-list {
        max-height: 120px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .status-item {
        padding: 12px;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
        margin: 0 auto;
    }
    
    .character-card {
        min-height: 80px;
    }
    
    .message {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    .input-container input {
        padding: 12px 16px;
        font-size: 16px;
    }
    
    .send-btn {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .game-clear-btn {
        padding: 16px 32px;
        font-size: 16px;
    }
    
    .character-image img {
        max-width: 150px;
    }
    
    .action-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* 横画面モバイル対応 */
@media (max-width: 768px) and (orientation: landscape) {
    .character-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
    }
    
    .character-card {
        padding: 10px 8px;
        min-height: 70px;
    }
    
    .character-icon {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }
    
    .character-name {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    
    .character-hint {
        font-size: 0.7rem;
    }
}