:root {
    --bg-color: #1a1a1a;
    --panel-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --accent: #4caf50;
    --danger: #ff5252;
    --highlight: #2196f3;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --mission-color: #e91e63;
    --crit-color: #ffd700;
    --token-color: #ff9800;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
}

#app {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    grid-template-rows: 60px 1fr;
    height: 100%;
    gap: 1px;
    background: #333;
}

/* スマホ用レイアウト */
@media (max-width: 768px) {
    body {
        height: 100dvh;
        overflow: hidden;
    }

    #app {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        gap: 0;
        padding-bottom: constant(safe-area-inset-bottom);
        padding-bottom: env(safe-area-inset-bottom);
        overflow: hidden;
        /* Prevent bounce */
    }

    header {
        height: auto !important;
        min-height: 44px;
        flex-shrink: 0;
        z-index: 100;
        padding: 4px 8px !important;
        flex-wrap: wrap;
    }

    header h1 {
        font-size: 0.9rem !important;
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    header h1 span {
        font-size: 0.65rem !important;
    }

    .info-btn {
        padding: 2px 4px !important;
        font-size: 0.7rem !important;
        margin-left: 2px !important;
    }

    .resources {
        font-size: 0.75rem;
        gap: 6px;
    }

    .save-btn {
        padding: 4px 8px !important;
        font-size: 0.8rem !important;
    }


    .panel {
        flex: 1;
        min-height: 0;
        /* Ensure flex shrinkage works */
        height: auto !important;
        /* Subtract header and nav */
        max-height: none;
        padding: 12px;
        overflow-y: auto;
    }

    .mobile-hidden {
        display: none !important;
    }

    .mobile-visible {
        display: flex !important;
    }

    .pc-battle-area:not(.mobile-visible) {
        display: none !important;
    }

    .pc-only {
        display: none !important;
    }

    /* Touch target improvements */
    button,
    .enemy-card,
    .area-btn,
    .upgrade-btn,
    .mission-btn,
    .villager-card {
        min-height: 48px;
        margin-bottom: 8px;
    }

    .tab-btn {
        min-height: 40px;
    }

    .resources {
        font-size: 0.8rem;
    }

    h1 {
        font-size: 1rem;
    }

    .tab-menu {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        gap: 8px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
        flex-shrink: 0;
    }

    .tab-menu::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex: 0 0 auto;
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

@media (min-width: 769px) {
    .mobile-nav {
        display: none !important;
    }

    .mobile-visible {
        display: flex !important;
        /* On PC, ensure it's flex as usual */
    }
}


header {
    grid-column: 1 / -1;
    background: var(--panel-bg);
    display: flex;
    align-items: center;
    padding: 0 15px;
    justify-content: space-between;
    border-bottom: 1px solid #444;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

h1 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--highlight);
}

.resources {
    display: flex;
    gap: 10px;
    font-weight: bold;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.panel {
    background: var(--bg-color);
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.enemy-card {
    background: var(--panel-bg);
    padding: 10px;
    border-radius: 4px;
    border-left: 4px solid var(--danger);
    cursor: pointer;
    transition: 0.2s;
    position: relative;
}

.enemy-card:hover {
    background: #3d3d3d;
}

.enemy-card.active {
    border-color: var(--accent);
    background: #334433;
}

.enemy-card.guardian {
    border-left-color: #ff9800;
}

.enemy-card.disabled {
    opacity: 0.5;
    filter: grayscale(100%);
    cursor: not-allowed;
    border-left-color: #777;
}

.enemy-card.disabled:hover {
    background: var(--panel-bg);
}

.hp-bar {
    height: 6px;
    background: #444;
    margin-top: 5px;
    border-radius: 3px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: var(--danger);
    width: 100%;
    transition: width 0.1s linear;
}

.defeated-mark {
    position: absolute;
    right: 10px;
    top: 10px;
    color: var(--accent);
    font-weight: bold;
    font-size: 0.8rem;
    border: 1px solid var(--accent);
    padding: 2px 5px;
    border-radius: 4px;
    transform: rotate(-10deg);
    z-index: 10;
}

.stat-box {
    background: var(--panel-bg);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    position: relative;
}

.stat-label {
    font-size: 0.85rem;
    color: #aaa;
}

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

.detail-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.7rem;
    padding: 2px 6px;
    background: #444;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    border: none;
}

.battle-view {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #000;
    border-radius: 8px;
    position: relative;
    min-height: 200px;
}

.battle-log {
    height: 150px;
    background: #111;
    overflow-y: auto;
    padding: 10px;
    font-family: monospace;
    font-size: 0.85rem;
    width: 100%;
    box-sizing: border-box;
    border-top: 1px solid #333;
}

.log-entry {
    margin-bottom: 4px;
    border-bottom: 1px solid #222;
    padding-bottom: 2px;
}

.crit-log {
    color: var(--crit-color);
    font-weight: bold;
    text-shadow: 0 0 3px #ff9800;
}

.dodge-log {
    color: #87ceeb;
    font-style: italic;
}

.skill-log {
    color: #e91e63;
    font-weight: bold;
    border-left: 2px solid #e91e63;
    padding-left: 5px;
}

.damage-pop {
    position: absolute;
    color: #fff;
    font-weight: bold;
    animation: popUp 0.8s forwards;
    font-size: 1.2rem;
    text-shadow: 0 0 3px red;
    pointer-events: none;
}

.damage-pop.crit {
    color: var(--crit-color);
    font-size: 1.5rem;
    text-shadow: 0 0 5px orange;
    z-index: 100;
}

.damage-pop.miss {
    color: #87ceeb;
    font-size: 1rem;
    text-shadow: none;
}

@keyframes popUp {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(-30px);
        opacity: 0;
    }
}

@keyframes popDown {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(30px);
        opacity: 0;
    }
}

.damage-pop.player-dmg {
    color: #ff5252;
    font-size: 1.4rem;
    text-shadow: 0 0 5px #b71c1c;
    animation: popDown 0.8s forwards;
}

.shaking {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.item-row {
    padding: 8px 0;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-effect {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}

.upgrade-btn {
    width: 100%;
    padding: 10px;
    background: var(--panel-bg);
    border: 1px solid #444;
    color: #fff;
    cursor: pointer;
    text-align: left;
    margin-bottom: 5px;
    border-radius: 4px;
}

.upgrade-btn:hover {
    background: #3d3d3d;
}

.upgrade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-bg);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.calc-row.total {
    border-top: 1px solid #555;
    padding-top: 5px;
    font-weight: bold;
    color: var(--accent);
    margin-top: 10px;
    font-size: 1.1rem;
}

button {
    cursor: pointer;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    background: #444;
    color: white;
    transition: 0.2s;
}

button:hover {
    background: #555;
}

button.save-btn {
    background: var(--highlight);
}

.tab-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.tab-btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 8px 5px;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 4px;
    background: #444;
    color: white;
    min-width: 60px;
}

.tab-btn.active {
    background: var(--accent);
    color: #000;
    font-weight: bold;
}

.mission-btn {
    width: 100%;
    background: #333;
    border: 1px solid #555;
    padding: 10px;
    margin-bottom: 5px;
    text-align: left;
    border-radius: 4px;
}

.mission-btn:hover {
    background: #444;
}

.mission-btn.completed {
    border-color: var(--accent);
    background: #2e3e2e;
}

.mission-btn.active {
    border-color: var(--mission-color);
    background: #3e2e2e;
}

.active-mission-banner {
    background: var(--mission-color);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 10px;
}

.drop-info {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 6px;
    border-top: 1px dashed #444;
    padding-top: 4px;
}

.drop-item {
    display: block;
}

.mission-info-box {
    background: #3e2723;
    border: 1px solid var(--mission-color);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 10px;
    text-align: center;
    font-size: 0.9rem;
    color: #fff;
}

.mission-info-box strong {
    color: var(--mission-color);
    display: block;
    margin-bottom: 2px;
}

.area-btn {
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    padding: 10px;
    background: var(--panel-bg);
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
}

.area-btn:hover {
    background: #3d3d3d;
}

.area-btn.active {
    border-color: var(--accent);
    background: #334433;
    font-weight: bold;
}

.extra-badge {
    color: var(--mission-color);
    font-weight: bold;
    font-size: 0.8em;
    margin-right: 3px;
}

/* スマホ用ボトムナビゲーション */
.mobile-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--panel-bg);
    border-top: 1px solid #444;
    height: 60px;
    padding-bottom: constant(safe-area-inset-bottom);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

.nav-item {
    background: transparent;
    padding: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 0;
    flex: 1;
    color: #888;
}

.nav-item:hover {
    background: transparent;
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 0.7rem;
}

.nav-item.active {
    color: var(--highlight);
}

.nav-item.active .nav-icon {
    filter: drop-shadow(0 0 5px var(--highlight));
}

/* 図鑑用スタイル（エリアグループ化対応） */

.zukan-area-group {
    border: 1px solid #444;
    background: #222;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 15px;
}

.zukan-area-title {
    margin-top: 0;
    margin-bottom: 10px;
    color: #87ceeb;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    font-size: 1rem;
}

.zukan-card {
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 5px;
    position: relative;
}

.zukan-name {
    font-weight: bold;
    color: var(--highlight);
}

.zukan-kill {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 0.9rem;
    color: #aaa;
}

.zukan-stats {
    font-size: 0.85rem;
    margin-top: 5px;
    color: #ccc;
}

.zukan-bonus {
    color: var(--accent);
    font-size: 0.8rem;
    margin-top: 3px;
}

.changelog-item {
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.changelog-item:last-child {
    border-bottom: none;
}

.changelog-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.changelog-ver {
    font-weight: bold;
    color: var(--highlight);
}

.changelog-date {
    color: #aaa;
    font-size: 0.85rem;
}

.changelog-content {
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.9rem;
    color: #ddd;
}

.info-btn {
    width: auto;
    padding: 5px 10px;
    font-size: 0.85rem;
    margin-left: 10px;
    background: #444;
}

.villager-card {
    background: #263238;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #37474f;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.villager-card:hover {
    background: #37474f;
    border-color: #00bcd4;
}

/* 通知システム (Premium Aesthetic) */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    background: rgba(45, 45, 45, 0.9);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--highlight);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    min-width: 200px;
    pointer-events: auto;
    animation: noti-slide-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.notification.item {
    border-left-color: var(--accent);
}

.notification.token {
    border-left-color: var(--token-color);
}

.noti-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.noti-msg {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    margin-top: 2px;
}

@keyframes noti-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* Vue Transition */
.noti-enter-active,
.noti-leave-active {
    transition: all 0.4s ease;
}

.noti-enter-from {
    transform: translateX(100%);
    opacity: 0;
}

.noti-leave-to {
    transform: translateX(50%) scale(0.9);
    opacity: 0;
}