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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #e74c3c;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e9ecef;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    
    /* 五行の色 */
    --wood-color: #27ae60;
    --fire-color: #e74c3c;
    --earth-color: #f39c12;
    --metal-color: #95a5a6;
    --water-color: #3498db;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
}

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

/* ヘッダー */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

h1 {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* 言語セレクター */
.language-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.lang-btn {
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    background: var(--card-background);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
    font-weight: 500;
}

.lang-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* セクション共通 */
section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

section h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* デスクレイアウト */
.desk-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.desk-grid {
    display: grid;
    grid-template-columns: repeat(3, 150px);
    grid-template-rows: repeat(3, 150px);
    gap: 15px;
    background: var(--background-color);
    padding: 20px;
    border-radius: 12px;
    position: relative;
}

.desk-cell {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.desk-cell:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.desk-cell.drag-over {
    background: #e8f5e9;
    border-color: var(--wood-color);
    transform: scale(1.05);
}

.desk-cell.center {
    background: #fff3e0;
}

.cell-label {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: 600;
}

.item-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* デスクセルの五行色分け */
.desk-cell[data-element="wood"] { border-left: 4px solid var(--wood-color); }
.desk-cell[data-element="fire"] { border-left: 4px solid var(--fire-color); }
.desk-cell[data-element="earth"] { border-left: 4px solid var(--earth-color); }
.desk-cell[data-element="metal"] { border-left: 4px solid var(--metal-color); }
.desk-cell[data-element="water"] { border-left: 4px solid var(--water-color); }

/* アイテム */
.items-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.item {
    background: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    cursor: move;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.item.dragging {
    opacity: 0.5;
    transform: scale(0.9);
}

.item.placed {
    width: 80px;
    height: 80px;
    padding: 10px;
}

.item span:first-child {
    font-size: 2em;
}

.item.placed span:last-child {
    font-size: 0.7em;
}

/* 五行バランス */
.balance-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    align-items: center;
}

.element-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.element-bar {
    display: grid;
    grid-template-columns: 60px 1fr 40px;
    align-items: center;
    gap: 15px;
}

.element-name {
    font-weight: 600;
    text-align: right;
}

.bar-container {
    background: var(--background-color);
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 12px;
}

#woodBar { background: var(--wood-color); }
#fireBar { background: var(--fire-color); }
#earthBar { background: var(--earth-color); }
#metalBar { background: var(--metal-color); }
#waterBar { background: var(--water-color); }

.element-value {
    font-weight: 600;
    color: var(--text-secondary);
}

/* バランススコア */
.balance-score {
    text-align: center;
    padding: 20px;
    background: var(--background-color);
    border-radius: 12px;
}

.balance-score h3 {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 1em;
}

.score-display {
    font-size: 3em;
    font-weight: 700;
    color: var(--primary-color);
    position: relative;
}

.score-display::after {
    content: '/100';
    font-size: 0.4em;
    color: var(--text-secondary);
    position: absolute;
    bottom: 0;
    margin-left: 5px;
}

/* レコメンデーション */
.recommendations {
    background: var(--background-color);
    padding: 20px;
    border-radius: 8px;
    min-height: 80px;
}

.recommendations p {
    line-height: 1.8;
    color: var(--text-color);
}

.recommendations p.positive {
    color: var(--wood-color);
    font-weight: 500;
}

.recommendations p.warning {
    color: var(--fire-color);
    font-weight: 500;
}

/* フッター */
footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .desk-grid {
        grid-template-columns: repeat(3, 100px);
        grid-template-rows: repeat(3, 100px);
        gap: 10px;
        padding: 15px;
    }
    
    .balance-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .items-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    section {
        padding: 20px;
    }
    
    h1 {
        font-size: 2em;
    }
}

/* アニメーション */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.desk-cell:has(.item) {
    animation: pulse 0.5s ease-out;
}