:root {
    --bg-color: #0d0d1a;
    --text-color: #e0e0ff;
    --border-color: #4a4a8a;
    --panel-bg: rgba(30, 30, 60, 0.9);
    --accent-color: #00d4ff;
    --hover-color: #005a8a;
    --pixel-size: 4px;
    --shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

#player-coords {
    color: #aaa;
    font-size: 12px;
    margin-left: 10px;
}

@import url('https://fonts.googleapis.com/css2?family=DotGothic16&display=swap');

* {
    box-sizing: border-box;
    font-family: 'DotGothic16', sans-serif;
    image-rendering: pixelated;
}

body {
    background: radial-gradient(circle, #1a1a2e 0%, #0d0d1a 100%);
    color: var(--text-color);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    width: 850px;
    height: 650px;
    border: var(--pixel-size) solid var(--border-color);
    background-color: #000;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), var(--shadow);
}

#game-header {
    height: 70px;
    border-bottom: var(--pixel-size) solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    background: linear-gradient(to bottom, #1e1e3c, #111122);
}

#player-summary span {
    margin-right: 15px;
    text-shadow: 2px 2px #000;
}

#player-hp-bar {
    color: #ff4b2b;
    font-weight: bold;
}

#game-screen {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0px, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 2px);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#message-log {
    height: 180px;
    border: calc(var(--pixel-size) / 2) solid var(--border-color);
    background-color: rgba(10, 10, 20, 0.95);
    overflow-y: auto;
    padding: 15px;
    font-size: 14px;
    line-height: 1.6;
    box-shadow: inset 0 0 10px #000;
}

#message-log div {
    margin-bottom: 5px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#game-menu {
    height: 90px;
    border-top: var(--pixel-size) solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: linear-gradient(to top, #1e1e3c, #111122);
}

button {
    background-color: #2a2a4a;
    color: var(--accent-color);
    border: calc(var(--pixel-size) / 2) solid var(--accent-color);
    padding: 12px 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    text-transform: uppercase;
    box-shadow: 3px 3px 0 #000;
}

button:hover {
    background-color: var(--accent-color);
    color: #000;
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 #000;
}

button:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.hidden {
    display: none !important;
}

#modal-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(3px);
}

#modal-content {
    background-color: #1e1e3c;
    border: var(--pixel-size) solid var(--accent-color);
    padding: 40px;
    width: 80%;
    max-height: 80%;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 20px var(--accent-color);
}

#modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 12px;
    background: #ff4b2b;
    border-color: #fff;
    color: #fff;
}

#action-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* フィールド移動用スタイル */
#world-container {
    width: 100%;
    height: 300px;
    /* バトル時などは可変、探索時はこの固定高 */
    position: relative;
    overflow: hidden;
    background: #000;
    border: calc(var(--pixel-size) / 2) solid var(--border-color);
}

#world-map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
}

#minimap-container {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 120px;
    height: 120px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--border-color);
    z-index: 20;
    pointer-events: none;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

.tile {
    width: 32px;
    height: 32px;
    background-size: cover;
}

.tile.grass {
    background-color: #2d5a27;
    background-image:
        radial-gradient(#3a6b2f 1px, transparent 1px),
        radial-gradient(#3a6b2f 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    position: relative;
}

.tile.grass::after {
    content: '"';
    font-size: 8px;
    color: #4a8a3a;
    position: absolute;
    top: 5px;
    left: 10px;
}

.tile.forest {
    background-color: #1a3311;
    background-image:
        linear-gradient(135deg, #224411 25%, transparent 25%),
        linear-gradient(225deg, #224411 25%, transparent 25%);
    background-size: 8px 8px;
    position: relative;
}

.tile.forest::before {
    content: '▲';
    font-size: 14px;
    color: #142b0d;
    position: absolute;
    top: 2px;
    left: 4px;
    text-shadow: 2px 2px #000;
}

.tile.water {
    background-color: #1e3c5a;
    background-image:
        linear-gradient(0deg, #1b3652 10%, transparent 10%),
        linear-gradient(90deg, #1b3652 10%, transparent 10%);
    background-size: 8px 8px;
}

.tile.mountain {
    background-color: #4a4a4a;
    position: relative;
}

.tile.mountain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #666 50%, #333 50%);
    clip-path: polygon(50% 10%, 10% 90%, 90% 90%);
}

.tile.town {
    background-color: #a67c52;
    border: 2px solid #5d4037;
    background-image: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.1) 0, rgba(0, 0, 0, 0.1) 2px, transparent 2px, transparent 4px);
}

.tile.dungeon {
    background-color: #331133;
    border: 2px solid #ff00ff;
    box-shadow: inset 0 0 10px #ff00ff;
}

.loc-tag {
    font-size: 8px;
    background: #000;
    color: #ff0;
    padding: 1px;
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
}

#player-sprite {
    position: absolute;
    width: 28px;
    height: 32px;
    z-index: 10;
    transition: left 0.12s linear, top 0.12s linear;
}

.hero-visual {
    background-color: #ffcc00;
    /* 体 */
    border-radius: 4px;
    box-shadow:
        0 -4px 0 #333,
        /* 髪 */
        0 4px 0 #555,
        /* 足 */
        -4px 0 0 #005a8a,
        /* 盾 */
        8px 0 0 #ccc;
    /* 剣 */
    position: relative;
}

.hero-visual::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 4px;
    width: 4px;
    height: 4px;
    background: #000;
    box-shadow: 12px 0 0 #000;
    /* 目 */
}

/* インベントリ・スキル用スタイル */
.skill-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.skill-item {
    background: #2a2a4a;
    border: 1px solid var(--accent-color);
    padding: 8px;
    cursor: pointer;
    font-size: 10px;
}

.skill-item:hover {
    background: var(--hover-color);
}

.skill-element-炎 {
    border: 2px solid #ff4b2b !important;
}

.skill-element-氷 {
    border: 2px solid #00d4ff !important;
}

.skill-element-風 {
    border: 2px solid #2ecc71 !important;
}

.skill-element-土 {
    border: 2px solid #a67c52 !important;
}

.skill-element-光 {
    border: 2px solid #ffd700 !important;
}

.skill-element-闇 {
    border: 2px solid #9b59b6 !important;
}

.skill-element-無 {
    border: 2px solid #ecf0f1 !important;
}

/* モバイル操作パッド */
#mobile-pad {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.pad-row {
    display: flex;
    gap: 5px;
}

.pad-btn {
    width: 50px;
    height: 50px;
    background-color: rgba(30, 30, 60, 0.8);
    border: 2px solid var(--accent-color);
    color: var(--accent-color);
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    touch-action: manipulation;
}

.pad-btn:active {
    background-color: var(--accent-color);
    color: #000;
}

/* スキル詳細ビュー */
.skill-detail-view {
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
}

.skill-info p {
    margin: 5px 0;
    font-size: 12px;
}

.skill-desc {
    font-style: italic;
    color: #ffd700;
    margin: 10px 0;
}

/* 装備画面 */
.equip-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.equip-slot-item {
    background: #2a2a4a;
    border: 1px solid var(--border-color);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    cursor: pointer;
}

.equip-slot-item:hover {
    background: var(--hover-color);
}

/* ショップ */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.shop-item {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-color);
    padding: 10px;
    text-align: center;
}

#fullscreen-map-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#map-canvas-wrapper {
    flex: 1;
    position: relative;
    border: 2px solid var(--accent-color);
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#fullscreen-map-canvas {
    max-width: 100%;
    max-height: 100%;
    image-rendering: auto;
}

#map-footer {
    padding-top: 10px;
    text-align: center;
    color: var(--accent-color);
    font-size: 14px;
}