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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    color: #fff;
    min-height: 100vh;
}

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

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#save-info {
    color: #aaa;
    font-size: 0.9em;
    margin-top: 5px;
}

/* タブシステム */
/* レイアウト構造 */
main {
    padding: 20px 0;
}

#dynamic-area {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(10px);
    margin-bottom: 20px;
}

#control-area {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(10px);
}

.dynamic-content, .control-content {
    display: none;
}

.dynamic-content.active, .control-content.active {
    display: block;
}

#tabs {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 15px;
}

.tab {
    flex: 1;
    padding: 10px 5px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
    font-size: 0.9em;
}

.tab:hover {
    background: rgba(255,255,255,0.2);
}

.tab.active {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* メイン画面 - 動的エリア */

#player-stats .stat {
    margin: 0;
    font-size: 1em;
    text-align: left;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

#player-stats .stat:last-child {
    border-bottom: none;
}

/* ステータスバー */
.stat-label {
    margin-bottom: 5px;
}

.stat-bar {
    width: 100%;
    height: 16px;
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
}

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

.exp-bar {
    background: linear-gradient(90deg, #4CAF50, #66ff66);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.hp-bar.stat-bar-fill {
    background: linear-gradient(90deg, #f44336, #ff6666);
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.3);
}

#player-stats {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#battle-area {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
}

#area-info {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: bold;
}


/* 装備セクション */
#equipment-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* 装備スロット */
.equipment-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.equipment-slot {
    width: 60px;
    height: 60px;
    border: 2px solid #555;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.3s;
}

.equipment-slot:hover {
    border-color: #888;
}

.equipment-slot.equipped {
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.2);
}

.equipment-slot.selected {
    border-color: #ffaa00;
    background: rgba(255, 170, 0, 0.2);
}

/* 装備詳細 */
#equipment-details {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 8px;
}

#selected-equipment-info {
    font-size: 0.9em;
    line-height: 1.5;
    white-space: pre-line;
    min-height: 200px;
}

/* ツールチップ */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 120%;
    left: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    white-space: pre-line;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    width: 250px;
    text-align: left;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 110%;
    left: 15px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

/* 右端の装備スロットのツールチップは左側に表示 */
.equipment-slot[data-slot="legs"]::before,
.equipment-slot[data-slot="feet"]::before,
.equipment-slot[data-slot="right-ear"]::before,
.equipment-slot[data-slot="right-arm"]::before,
.equipment-slot[data-slot="right-ring"]::before {
    right: 0;
    left: auto;
}

.equipment-slot[data-slot="legs"]::after,
.equipment-slot[data-slot="feet"]::after,
.equipment-slot[data-slot="right-ear"]::after,
.equipment-slot[data-slot="right-arm"]::after,
.equipment-slot[data-slot="right-ring"]::after {
    right: 15px;
    left: auto;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* 敵情報 */
#enemy-info {
    text-align: center;
    margin: 15px auto;
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    max-width: 500px;
}

.enemy-name {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.enemy-hp {
    margin: 10px 0;
    font-size: 1.1em;
    font-weight: bold;
}

.enemy-hp-bar {
    width: 100%;
    height: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ffaa44);
    transition: width 0.5s ease;
    width: 100%;
}

/* 戦闘ログ */

#battle-log {
    margin-top: 20px;
}

#battle-log h4 {
    margin-bottom: 10px;
}

#log-content {
    height: 200px;
    overflow-y: auto;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9em;
    line-height: 1.4;
}

.log-entry {
    margin: 5px 0;
    padding: 3px 0;
}

.log-damage {
    color: #ff6666;
}

.log-exp {
    color: #66ff66;
}

.log-drop {
    color: #ffaa66;
    font-weight: bold;
}

/* レアリティ色 */
.rarity-white { color: #ffffff; }
.rarity-green { color: #66ff66; }
.rarity-blue { color: #6666ff; }
.rarity-purple { color: #cc66ff; }
.rarity-orange { color: #ff9933; }
.rarity-red { color: #ff3333; }

/* インベントリ - 動的エリア */
#inventory-dynamic {
    overflow-y: auto;
}

#inventory-list {
    height: 100%;
    overflow-y: auto;
}

/* インベントリ - コントロールエリア */
#inventory-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 15px;
    border: 1px solid #666;
    background: rgba(0,0,0,0.3);
    color: #fff;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.filter-btn:hover, .filter-btn.active {
    background: rgba(255,255,255,0.2);
}

#inventory-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    height: 100%;
    overflow-y: auto;
}

.inventory-item {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s;
}

.inventory-item:hover {
    background: rgba(255,255,255,0.1);
}

.inventory-item.equipped {
    border-color: #4CAF50;
}

.item-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.item-stats {
    font-size: 0.9em;
    opacity: 0.8;
}

.item-enhancement {
    color: #ffaa00;
    font-weight: bold;
}

/* ショップ - 動的エリア */
#shop-dynamic {
    overflow-y: auto;
}

#shop-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    height: 100%;
    overflow-y: auto;
}

.shop-item {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.shop-item .price {
    color: #ffdd00;
    font-weight: bold;
    font-size: 1.2em;
    margin: 10px 0;
}

.buy-btn {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.buy-btn:hover {
    background: #45a049;
}

.buy-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

/* 強化システム - 動的エリア */
#enhance-dynamic {
    overflow: hidden;
}

#enhance-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
}

#enhance-item-select, #enhance-details {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#enhance-item-list {
    flex: 1;
    overflow-y: auto;
}

.enhance-item {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

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

#enhance-options {
    margin-top: 20px;
}

.enhance-option {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.enhance-btn {
    padding: 8px 16px;
    background: #ff9900;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.enhance-btn:hover {
    background: #e88800;
}

.enhance-btn:disabled {
    background: #666;
    cursor: not-allowed;
}

/* 実績・統計 */
#collection-stats, #battle-stats {
    margin: 20px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background: rgba(0,0,0,0.3);
    border-radius: 5px;
}

/* スマホ対応 */
@media (max-width: 768px) {
    #game-container {
        padding: 5px;
        height: 100vh;
    }
    
    header {
        margin-bottom: 5px;
    }
    
    header h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    
    main {
        padding: 10px 0;
    }
    
    #dynamic-area {
        padding: 10px;
        margin-bottom: 10px;
    }
    
    #control-area {
        padding: 10px;
    }
    
    #equipment-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .equipment-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .equipment-slot {
        width: 50px;
        height: 50px;
        font-size: 0.7em;
    }
    
    #enhance-section {
        grid-template-columns: 1fr;
    }
    
    #inventory-list {
        grid-template-columns: 1fr;
    }
    
    #shop-items {
        grid-template-columns: 1fr;
    }
    
    #tabs {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .tab {
        font-size: 0.85em;
        padding: 8px 10px;
        flex: 1;
        min-width: 60px;
    }
    
    .tab-content {
        padding: 15px;
    }
    
    #log-content {
        height: 150px;
        font-size: 0.8em;
    }
    
    .inventory-item {
        padding: 10px;
    }
    
    .shop-item {
        padding: 15px;
    }
    
    #player-stats .stat {
        font-size: 1em;
    }
    
    .enemy-name {
        font-size: 1.3em;
    }
    
    #inventory-filters {
        gap: 5px;
    }
    
    .filter-btn {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 5px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .equipment-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }
    
    .equipment-slot {
        width: 45px;
        height: 45px;
        font-size: 0.6em;
    }
    
    .tab {
        font-size: 0.8em;
        padding: 6px 8px;
    }
    
    .tab-content {
        padding: 10px;
    }
    
    #log-content {
        height: 120px;
    }
    
    .inventory-item, .shop-item, .enhance-item {
        padding: 8px;
    }
    
    .stat-item {
        font-size: 0.9em;
    }
}