:root {
    --bg-color: #000000;
    --border-color: #ffffff;
    --text-color: #ffffff;
    --panel-bg: rgba(0, 0, 0, 0.8);
    --scanner-color: #ff0000;
    --font-family: 'DotGothic16', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    /* テキスト選択を防止してドラッグしやすくする */
}

body {
    background-color: #222;
    /* 全体の背景は少し明るめの黒 */
    color: var(--text-color);
    font-family: var(--font-family);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    /* スクロールバーを隠す */
}

/* 3ペインレイアウトのコンテナ */
#game-container {
    display: flex;
    width: 95vw;
    height: 90vh;
    gap: 10px;
}

/* 共通パネルスタイル（RPG風の白い枠線） */
.panel {
    background-color: var(--panel-bg);
    border: 4px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.panel-title {
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

/* 左側：商品棚 */
#shelf-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    /* コンテナ外へのドラッグは一旦考慮しないか、別途調整 */
}

#products-container {
    position: relative;
    width: 100%;
    height: 100%;
}

/* 右側：マイバッグ */
#bag-area {
    flex: 1;
    position: relative;
}

#scanned-items-container {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    padding: 10px;
}

/* 中央：レジ筐体 */
#register-area {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* モニター領域（RPGの戦闘画面風） */
#monitor {
    border: 2px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    height: 60%;
    display: flex;
    flex-direction: column;
}

#monster-display {
    text-align: center;
    margin-bottom: 10px;
}

#monster-name {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

#monster-hp-bar-container {
    width: 80%;
    height: 10px;
    background-color: #555;
    margin: 0 auto 5px auto;
    border: 1px solid #fff;
}

#monster-hp-bar {
    width: 100%;
    /* 初期値、あとでJSで操作 */
    height: 100%;
    background-color: #00ff00;
    transition: width 0.3s;
}

#monster-image {
    font-size: 4rem;
    /* 絵文字のサイズ */
    margin: 10px 0;
    /* ダメージ時のアニメーションなどにも利用 */
}

#scan-log {
    flex: 1;
    border: 1px dotted var(--border-color);
    padding: 5px;
    margin-bottom: 10px;
    overflow-y: auto;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
}

.log-entry {
    margin-bottom: 2px;
}

#total-display {
    text-align: right;
    font-size: 1.5rem;
    border-top: 2px solid var(--border-color);
    padding-top: 5px;
}

/* センサー領域 */
#scanner-area {
    height: 100px;
    border: 2px dashed #666;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 0, 0, 0.05);
}

#scanner-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--scanner-color);
    box-shadow: 0 0 10px var(--scanner-color);
}

#scanner-text {
    position: relative;
    z-index: 1;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    pointer-events: none;
    /* ドラッグの邪魔にならないように */
}

/* お会計ボタン */
.btn {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 2px solid var(--border-color);
    padding: 15px;
    font-size: 1.2rem;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #333;
}

.hidden {
    display: none !important;
}

/* -- アニメーションクラス -- */
.shake {
    animation: shake 0.5s 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);
    }
}

.flash {
    animation: flash 0.3s;
}

@keyframes flash {
    0% {
        background-color: rgba(255, 255, 255, 0);
    }

    50% {
        background-color: rgba(255, 255, 255, 0.8);
    }

    100% {
        background-color: rgba(255, 255, 255, 0);
    }
}

/* ------------------------
   商品のスタイル（Product.js用）
   ------------------------ */
.product-item {
    position: absolute;
    width: 80px;
    height: 80px;
    background-color: #333;
    border: 2px solid #aaa;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: transform 0.1s;
}

.product-item:active {
    cursor: grabbing;
}

.product-emoji {
    font-size: 2rem;
}

.product-name {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.product-price {
    font-size: 0.8rem;
    color: #ffdd00;
}

.product-item.dragging {
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    /* JS側で fixed 等にして動かすためポインターイベントを無効化（下の要素にイベントを貫通させる） */
    pointer-events: none;
}

.product-item.scanned {
    /* マイバッグエリアに置かれたときのスタイル */
    margin: 5px;
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    transform: scale(0.9);
    cursor: default;
    opacity: 0.6;
}

.critical-item {
    border-color: #ff00ff;
    box-shadow: 0 0 10px #ff00ff;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.05);
    }
}

/* ------------------------
   ダメージポップアップ
   ------------------------ */
.damage-popup {
    position: fixed;
    color: #ff3333;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 0 #fff, -1px -1px 0 #fff;
    pointer-events: none;
    z-index: 2000;
    animation: popup 1s ease-out forwards;
}

@keyframes popup {
    0% {
        transform: scale(0.5) translateY(0);
        opacity: 1;
    }

    30% {
        transform: scale(1.5) translateY(-20px);
        opacity: 1;
    }

    100% {
        transform: scale(1) translateY(-50px);
        opacity: 0;
    }
}

/* 属性ごとの色変更 */
.damage-popup.style-normal {
    color: #ff3333;
}

.damage-popup.style-fire {
    color: #ff8800;
    text-shadow: 2px 2px 0 #fff, -1px -1px 0 #ffff00;
}

.damage-popup.style-heal {
    color: #00ff00;
    text-shadow: 2px 2px 0 #fff, -1px -1px 0 #005500;
}

.damage-popup.style-ice {
    color: #00ffff;
    text-shadow: 2px 2px 0 #fff, -1px -1px 0 #0000ff;
}

.damage-popup.style-slash {
    color: #ffffff;
    text-shadow: 2px 2px 0 #555, -1px -1px 0 #000;
    /* 斬撃風の斜めに切れるような動きを追加 */
    animation: slashPopup 1s ease-out forwards;
}

@keyframes slashPopup {
    0% {
        transform: scale(0.5) translateY(0) skewX(20deg);
        opacity: 1;
    }

    30% {
        transform: scale(1.5) translateX(30px) translateY(-10px) skewX(20deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) translateX(50px) translateY(-30px) skewX(20deg);
        opacity: 0;
    }
}

/* ------------------------
   イベント演出（カットイン・キャッシュバック）
   ------------------------ */

/* カットイン演出 */
.cutin-container {
    position: fixed;
    top: 30%;
    left: -100%;
    width: 100vw;
    height: 150px;
    background: linear-gradient(90deg, rgba(255, 0, 0, 0) 0%, rgba(255, 0, 0, 0.8) 50%, rgba(255, 0, 0, 0) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    pointer-events: none;
    animation: cutinSlide 1.2s cubic-bezier(0.1, 0.8, 0.9, 0.2) forwards;
}

.cutin-text {
    font-size: 4rem;
    color: #fff;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    font-weight: bold;
    transform: skewX(-15deg);
}

@keyframes cutinSlide {
    0% {
        left: -100%;
    }

    40% {
        left: 0;
    }

    60% {
        left: 0;
    }

    100% {
        left: 100%;
    }
}

/* キャッシュバック（コインドロップ）演出 */
.coin {
    position: fixed;
    top: -50px;
    font-size: 2rem;
    z-index: 4000;
    pointer-events: none;
    animation: drop 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes drop {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0;
    }
}