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

:root {
    --primary-color: #6A5ACD;
    --secondary-color: #4B0082;
    --accent-color: #FFD700;
    --bg-dark: #0F0F23;
    --bg-light: #1a1a3e;
    --text-light: #E0E0E0;
    --text-dark: #333;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* 背景の星空エフェクト */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, white, transparent),
        radial-gradient(1px 1px at 50px 50px, white, transparent),
        radial-gradient(1px 1px at 80px 10px, white, transparent),
        radial-gradient(2px 2px at 130px 80px, white, transparent);
    background-size: 200px 200px;
    animation: starsMove 100s linear infinite;
    opacity: 0.5;
}

@keyframes starsMove {
    to {
        transform: translateY(-200px);
    }
}

/* オーロラエフェクト */
.aurora {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at center, 
        rgba(106, 90, 205, 0.3) 0%,
        rgba(75, 0, 130, 0.2) 30%,
        rgba(0, 0, 0, 0) 70%);
    animation: aurora 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes aurora {
    0%, 100% { transform: rotate(0deg) scale(1); opacity: 0.3; }
    50% { transform: rotate(180deg) scale(1.2); opacity: 0.5; }
}

/* ヘッダー */
header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 2rem;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.logo-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ナビゲーション */
nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--text-light);
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.nav-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(106, 90, 205, 0.4);
}

.nav-btn.active {
    background: var(--primary-color);
    box-shadow: 0 5px 20px rgba(106, 90, 205, 0.4);
}

/* メインコンテンツ */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.tab-content {
    display: none;
    animation: fadeIn 0.5s ease;
}

.tab-content.active {
    display: block;
}

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

/* フォーム */
.dream-input-container {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dream-input-container h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--accent-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-light);
    font-weight: 500;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(106, 90, 205, 0.3);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

input[type="checkbox"] {
    margin-right: 0.5rem;
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(106, 90, 205, 0.4);
}

/* ギャラリー */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.filter-container select {
    padding: 0.5rem 1rem;
    background: var(--glass-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: var(--text-light);
}

.dream-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.dream-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.dream-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(106, 90, 205, 0.3);
}

.dream-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.dream-card h3 {
    color: var(--accent-color);
    font-size: 1.2rem;
}

.mood-emoji {
    font-size: 1.5rem;
}

.dream-preview {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.dream-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dream-date {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.visualize-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.visualize-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

/* 分析 */
.analysis-container {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card h3 {
    color: var(--text-light);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.stat-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--accent-color);
}

.stat-text {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.keyword-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.keyword {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--primary-color);
    border-radius: 15px;
    margin: 0.2rem;
    transition: all 0.3s ease;
}

.keyword:hover {
    transform: scale(1.1);
    background: var(--secondary-color);
}

.mood-chart {
    margin-top: 2rem;
}

.mood-chart h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
}

.mood-bar-container {
    display: grid;
    grid-template-columns: 120px 1fr 60px;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.mood-label {
    text-align: right;
}

.mood-bar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
}

.mood-bar-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    border-radius: 10px;
    transition: width 1s ease;
}

.mood-count {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
}

.modal-content {
    position: relative;
    background: var(--bg-light);
    margin: 5% auto;
    padding: 2rem;
    width: 90%;
    max-width: 800px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.close:hover {
    color: var(--accent-color);
    transform: rotate(90deg);
}

.dream-visualization {
    margin-bottom: 2rem;
    text-align: center;
}

.dream-visualization canvas {
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    height: auto;
}

.dream-details h3 {
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.dream-details p {
    line-height: 1.8;
    margin-bottom: 1rem;
}

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

.tag {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: var(--primary-color);
    border-radius: 15px;
    font-size: 0.9rem;
}

/* レスポンシブ */
@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .logo {
        font-size: 1.5rem;
    }
    
    nav {
        flex-wrap: wrap;
    }
    
    .nav-btn {
        font-size: 0.9rem;
        padding: 0.4rem 1rem;
    }
    
    main {
        padding: 0 1rem;
    }
    
    .dream-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 10% auto;
        padding: 1rem;
    }
}