:root {
    --bg-color: #0f0f13;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-color: #f0f0f0;
    --accent-color: #7c4dff;
    --primary-color: #448aff;
    --danger-color: #ff5252;
    --success-color: #69f0ae;
    --warning-color: #ffd740;
    --warning-alt-color: #ffd740;
    --sub-text-color: #bbb;
    --font-main: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    --ui-scale: 1.0;
    font-size: 16px;
}

.hidden {
    display: none !important;
}

/* 小さな画面ではベースのフォントサイズを下げ、相対単位(rem)を使っている全要素を一律で縮小する */
@media (max-width: 600px) {
    :root {
        font-size: 14px;
    }
}

/* 超小型画面（400px以下）向けのさらなる縮小 */
@media (max-width: 400px) {
    :root {
        font-size: 12px;
    }
}

/* .asset-theme-cute の配色定義は削除し、アセットのみを切り替えるように変更済み */

.asset-theme-cute .glass-panel {
    border-image: url('../images/UI(cute)/ui_window_frame.webp') 150 stretch;
}

.asset-theme-cute .action-btn.primary {
    border-image-source: url('../images/UI(cute)/ui_btn_primary_n.webp');
}
.asset-theme-cute .action-btn.primary:hover {
    border-image-source: url('../images/UI(cute)/ui_btn_primary_h.webp');
}
.asset-theme-cute .action-btn.danger {
    border-image-source: url('../images/UI(cute)/ui_btn_danger_n.webp');
}
.asset-theme-cute .action-btn.danger:hover {
    border-image-source: url('../images/UI(cute)/ui_btn_danger_h.webp');
}
.asset-theme-cute .action-btn.secondary {
    border-image-source: url('../images/UI(cute)/ui_btn_secondary_n.webp');
}
.asset-theme-cute .action-btn.secondary:hover {
    border-image-source: url('../images/UI(cute)/ui_btn_secondary_h.webp');
}
.asset-theme-cute .action-btn.success {
    border-image-source: url('../images/UI(cute)/ui_btn_primary_n.webp');
}
.asset-theme-cute .action-btn.success:hover {
    border-image-source: url('../images/UI(cute)/ui_btn_primary_h.webp');
}
.asset-theme-cute .action-btn.success .btn-emoji {
    filter: none; /* キュートテーマではボタン自体が最初からピンクなのでフィルタ不要 */
}
.asset-theme-cute .dungeon-card,
.asset-theme-cute .glass-panel.modal-content {
    border-image: url('../images/UI(cute)/ui_window_frame.webp') 150 stretch;
}
/* ハンバーガーメニュー項目のキュート化 - 状態別画像切り替え */
.asset-theme-cute #floating-menu-list .menu-item {
    background-image: url('../images/UI(cute)/ui_btn_primary_n.webp'); 
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    border: none;
}
.asset-theme-cute #floating-menu-list .menu-item:hover {
    background-image: url('../images/UI(cute)/ui_btn_primary_h.webp') !important;
}
.asset-theme-cute #floating-menu-list .menu-item.danger {
    /* ダンジョンボタンもデザイン統一 */
    background-image: url('../images/UI(cute)/ui_btn_primary_n.webp') !important;
}
.asset-theme-cute #floating-menu-list .menu-item.danger:hover {
    background-image: url('../images/UI(cute)/ui_btn_primary_h.webp') !important;
}




/* フローティングボタンのキュート化 */
.asset-theme-cute .floating-menu-btn,
.asset-theme-cute .floating-chat-btn,
.asset-theme-cute .floating-discord-btn {
    background-color: #ff85c0;
    border-color: #ff69b4;
    box-shadow: 0 0 0.6rem rgba(255, 105, 180, 0.5);
}

.asset-theme-cute .tip-list-scroll-area {
    background-image: url('../images/UI(cute)/ui_divider.webp');
    background-repeat: repeat-x;
    background-position: bottom;
}

.text-gray-400,
.text-gray-500,
.text-gray-600,
.sub-text {
    color: var(--sub-text-color) !important;
}

html {
    overflow: hidden !important; /* UIスケール(transform)時のFixed要素の挙動を保つため、html自体はスクロールさせない */
    height: 100%;
    touch-action: manipulation;
}

body {
    background-color: #000;
    color: var(--text-color);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    height: 100vh; /* 画面の高さを固定 */
    box-sizing: border-box;
    overflow-y: auto !important; /* body を唯一のスクロールコンテナにする */
    overflow-x: clip; 
    position: relative;
}

/* 背景画像レイヤー */
body::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../images/background.jpg');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    z-index: -2;
}

/* テーマカラーオーバーレイレイヤー */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    opacity: 0.9;
    z-index: -1;
}

/* Tips List Styles */
.tips-list-button-container {
    text-align: center;
}

.tips-list-scroll-area {
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-align: left;
}

.tips-category-group {
    margin-bottom: 20px;
}

.tips-category-title {
    color: var(--warning-color);
    font-size: 1.1rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
    padding-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tip-list-item {
    font-size: 0.9rem;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    line-height: 1.4;
    color: #ddd;
}

.tip-list-item:last-child {
    border-bottom: none;
}

/* Glassmorphism Logic -> Premium UI Frame */
.glass-panel {
    background-color: var(--glass-bg); /* Use semi-transparent background */
    border: 60px solid transparent; /* Expanded border width for a larger frame (45px -> 60px) */
    border-image: url('../images/UI/ui_window_frame.webp') 150 stretch; /* Protect corners from stretching (150px slice out of ~1000px) */
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    /* For better text contrast against the new background */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    /* Set color safely */
    color: #fff;
    border-radius: 0; /* Let border-image handle corners */
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 800px;
    min-height: 100vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 15px;
    padding-bottom: 20px;
    height: auto !important;
    /* Allow expansion */
    overflow: visible !important;
    /* Prevent internal clipping */
    transform: scale(var(--ui-scale, 1.0));
    transform-origin: top center;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .app-container {
        padding: 5px;
        padding-top: 15px;
        /* Increase top padding for mobile */
    }

    .status-panel {
        padding: 15px;
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
}

.game-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
    /* サイズアップに合わせて間隔も調整 */
}

.title-logo-img {
    height: auto;
    max-height: 60px;
    /* 120pxから60pxに縮小 */
    width: auto;
    object-fit: contain;
    /* 白い発光エフェクトを追加（文字と統一） */
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

.title-text-img {
    height: auto;
    max-height: 80px;
    /* 50pxから80pxに拡大 */
    width: auto;
    object-fit: contain;
    /* 白い発光エフェクトを追加 */
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

/* モバイル対応 */
@media (max-width: 600px) {
    .title-logo-img {
        max-height: 40px;
        /* モバイル用さらに縮小 */
    }

    .title-text-img {
        max-height: 45px;
        /* 35pxから引き上げ */
    }

    .game-title {
        gap: 10px;
    }
}

.global-stats {
    display: flex;
    gap: 15px;
    font-weight: bold;
    font-size: 0.95rem;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow: visible;
    /* Ensure content flows */
}

/* Game Screen */
#game-screen {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    min-height: 200px;
    position: relative;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* コンテナからはみ出る背景を隠す */
    z-index: 1;
}

.dungeon-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.dungeon-bg-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.35;
    /* 視認性のための不透明度調整 */
    transition: opacity 0.8s ease-in-out;
}

.dungeon-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
}

.scene-content {
    width: 100%;
    text-align: center;
}

.message-box {
    margin-bottom: 15px;
}

#main-message {
    font-size: 1.5rem;
    margin: 10px 0;
    line-height: 1.4;
    font-weight: 600;
}

#sub-message {
    font-size: 0.95em;
    color: var(--sub-text-color);
}

.ad-wrapper {
    background: #fff;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 4px;
}

.battle-log-area {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    /* Internal scroll */
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
    color: #ffe082;
    text-align: left;
    white-space: pre-wrap;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

/* Log Container */
.log-panel {
    height: 200px;
    /* Fixed height for log area */
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.log-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    font-family: 'Consolas', monospace;
    font-size: 0.9em;
}

.log-entry {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 6px 0;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Footer / Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    /* CRITICAL: Allow wrapping */
    justify-content: center;
    gap: 8px;
    padding: 15px;
}

/* 2-column Grid for Menu */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 15px;
}

.action-btn {
    padding: 1.25rem 2rem; /* rem ベースに変更 */
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, filter 0.2s, border-image-source 0.2s;
    background-color: transparent;
    border-style: solid;
    /* 9スライス設定: rem ベースに変更 */
    border-width: 1.3rem 2.2rem;
    border-image-source: url('../images/UI/ui_btn_primary_n.webp');
    border-image-slice: 80 140 fill;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8), 0 0 5px rgba(0, 0, 0, 0.5);
    flex: 1 1 auto;
    /* ボタンの余白と文字サイズ制御 - rem ベース */
    padding: 0.2rem 0.5rem; /* さらに削る */
    min-height: 3.5rem;    /* 4rem -> 3.5rem */
    line-height: 1.1;
    white-space: nowrap;
    font-size: clamp(0.7rem, 1.5vw + 0.5rem, 1rem); 
    min-width: 6.5rem;    /* 7.5rem -> 6.5rem */
    max-width: 12rem;      /* 13.5rem -> 12rem */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
}

/* 400px以下ではさらにタイトに */
@media (max-width: 400px) {
    .action-btn {
        border-width: 1rem 1.8rem; /* 枠も削る */
        min-height: 3rem;
        padding: 0.15rem 0.4rem;
    }
}

/* 500px以下の画面向け (ボタン折り返し・フレーム削減) */
@media (max-width: 500px) {
    .action-btn {
        border-width: 0.8rem 1.2rem;
        min-height: 2.5rem;
        padding: 0.1rem 0.2rem;
        font-size: 0.75rem;
        min-width: 4.5rem; /* さらなる縮小で改行を促す */
    }
}

@keyframes btn-sprite-anim {
    /* スプライトから9スライスへ移行したため不要だが互換性のため残置・空に */
}

.action-btn:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    border-image-source: url('../images/UI/ui_btn_primary_h.webp');
    transform: translateY(-2px);
}

.menu-item:hover {
    /* 画像切り替えは各コンポーネント定義（または個別ID）で行うため、ここでは共通挙動のみ定義 */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}


/* .menu-item.danger の強力な個別指定は削除し、基底スタイルに従わせる */


.action-btn:active {
    transform: scale(0.95) translateY(0);
    filter: brightness(0.8);
}

.action-btn.primary {
    border-image-source: url('../images/UI/ui_btn_primary_n.webp');
}

.action-btn.primary:hover {
    border-image-source: url('../images/UI/ui_btn_primary_h.webp');
}

.action-btn.danger {
    border-image-source: url('../images/UI/ui_btn_danger_n.webp');
}

.action-btn.danger:hover {
    border-image-source: url('../images/UI/ui_btn_danger_h.webp');
    transform: translateY(-2px);
}

.action-btn.success {
    /* 緑色ベースのボタン */
    border-image-source: url('../images/UI/ui_btn_primary_n.webp');
    filter: hue-rotate(270deg) saturate(1.5);
}

/* 絵文字の色をフィルタ適用前の状態に戻す */
.action-btn.success .btn-emoji {
    display: inline-block;
    filter: hue-rotate(-270deg) saturate(0.67); /* ボタンのフィルタを打ち消す（1/1.5 ≒ 0.67） */
}

.action-btn.success:hover {
    border-image-source: url('../images/UI/ui_btn_primary_h.webp');
    transform: translateY(-2px);
}

.action-btn.secondary {
    border-image-source: url('../images/UI/ui_btn_secondary_n.webp');
}

.action-btn.secondary:hover {
    border-image-source: url('../images/UI/ui_btn_secondary_h.webp');
    transform: translateY(-2px);
}

.action-btn.warning {
    /* Use secondary as base but tint it yellow */
    border-image-source: url('../images/UI/ui_btn_secondary_n.webp');
    filter: sepia(1) hue-rotate(-30deg) saturate(3);
}

.action-btn.warning:hover {
    border-image-source: url('../images/UI/ui_btn_secondary_h.webp');
    transform: translateY(-2px);
}

/* Stats Panel */
.status-panel {
    padding: 20px;
}

#pet-name {
    margin: 0 0 15px 0;
    font-size: 1.4rem;
    color: var(--text-color);
    text-align: center;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.stats-grid {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    /* Align bottom */
    gap: 15px;
    flex-wrap: wrap;
    /* Wrap on tiny screens */
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 60px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--sub-text-color);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-weight: 800;
    color: #fff;
    font-size: 1rem;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.2;
    text-align: center;
    text-shadow: 1px 1px 0 #888, -1px 1px 0 #888, 1px -1px 0 #888, -1px -1px 0 #888;
}

.hp-bar-container {
    width: 100%;
    min-width: 100px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

.hp-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff5252, #ff1744);
    /* Red gradient for HP */
    transition: width 0.4s ease-out;
}

/* Modal System */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-backdrop, rgba(0, 0, 0, 0.85));
    /* Darker overlay */
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
    /* Safe area */
    box-sizing: border-box;
    /* Mobile Height Fix */
    height: 100dvh;
    overscroll-behavior: contain;
}

/* Scroll Lock Class (Applied via UIManager) */
.no-scroll {
    overflow: hidden !important;
    touch-action: none;
}

/* Click Blocker (Ghost Touch Prevention) */
#click-blocker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    /* Highest priority */
    background: transparent;
    pointer-events: auto;
    display: none;
}

#click-blocker.active {
    display: block;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--modal-bg, #1e1e24);
    border: 1px solid var(--modal-border);
    border-radius: 16px;
    width: 100%;
    max-width: min(500px, var(--modal-max-width, 95vw));
    max-height: var(--modal-max-height, 95vh);
    /* Max height for scroll */
    overflow-y: auto;
    /* Internal scroll */
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(var(--ui-scale, 1.0));
    transform-origin: center center;
    transition: transform 0.3s ease;
}

/* Ensure glass-panel overrides default modal styles */
.glass-panel.modal-content {
    background-color: var(--glass-bg);
    border: 45px solid transparent; 
    border-image: url('../images/UI/ui_window_frame.webp') 150 stretch;
    border-radius: 0;
}

/* モーダルのスクロールバーが9スライス装飾に被る問題の修正 */
.glass-panel.modal-content::-webkit-scrollbar {
    width: 6px;
}
.glass-panel.modal-content::-webkit-scrollbar-track {
    background: transparent;
    margin: var(--modal-border-margin, 45px) 0; /* カスタムプロパティを使用し、メディアクエリで縮小時に追従 */
}
.glass-panel.modal-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}
.glass-panel.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* スマホ画面向けウィンドウフレーム縮小 */
@media (max-width: 500px) {
    .glass-panel {
        border-width: 20px !important;
    }
    .glass-panel.modal-content {
        border-width: 20px !important;
        padding: 15px; /* さらに要素の描画領域を広げる */
        --modal-border-margin: 20px; /* スクロールバーの余白も縮小 */
    }
}

/* Common Rogue UI Inputs */
.rogue-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    padding: 8px 12px;
    outline: none;
    transition: all 0.2s;
}

.rogue-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(68, 138, 255, 0.4);
    background: rgba(0, 0, 0, 0.6);
}

.rogue-input::placeholder {
    color: #666;
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0) scale(var(--ui-scale, 1.0));
}

.wide-modal {
    max-width: min(800px, var(--modal-max-width, 95vw));
}

.modal-content h2 {
    color: var(--text-color);
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.5rem;
}

.modal-controls {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Specific Content Styles */

#auto-sell-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auto-sell-options label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

#auto-sell-options label:hover {
    background: rgba(255, 255, 255, 0.05);
}

#auto-sell-options input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Dungeon List */
.dungeon-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    /* Responsive Grid */
    gap: 15px;
    padding: 10px 0;
}

.dungeon-card {
    background: var(--glass-bg);
    border: 35px solid transparent;
    border-image: url('../images/UI/ui_window_frame.webp') 150 stretch;
    border-radius: 0;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.dungeon-card:hover {
    background: rgba(68, 138, 255, 0.2);
    border-color: var(--primary-color);
    transform: translateY(-5px);
}

.dungeon-card h3 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: var(--warning-alt-color);
}

.dungeon-info {
    font-size: 0.85rem;
    color: var(--sub-text-color);
}

.dungeon-fee {
    color: var(--warning-alt-color);
    font-weight: bold;
    margin: 5px 0;
}

/* Category System */
.category-card {
    /* borderとbackgroundのオーバーライドを削除し、.dungeon-cardのフレームを継承しつつ調整 */
    border-width: 20px; /* 35pxだと太すぎるため縮小 */
    background: var(--card-bg, rgba(20, 20, 30, 0.7)); /* テキストが見やすいように背景を少し暗くする */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}

.category-card h3 {
    font-size: 1.3rem;
    color: var(--warning-alt-color);
}

.back-btn {
    grid-column: 1 / -1;
    /* Span full width */
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.15);
}

/* Inventory List */
.inventory-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.inventory-table th {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--sub-text-color);
}

.inventory-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Minigames */
.fishing-scene,
.track-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.slot-machine {
    background: #222;
    border-radius: 15px;
    padding: 20px;
    border: 4px solid #444;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 5px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.fishing-scene {
    height: 180px;
}

.track-container {
    height: auto;
    min-height: 250px;
    background: #2e7d32;
    padding-bottom: 5px;
}

/* Sub Menu in Dungeon */
.sub-menu {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--modal-border);
    color: #ccc;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.secondary-btn {
    color: var(--sub-text-color);
}

/* Pet Menu Grid */
.menu-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}

/* ペットメニュー アクショングリッド */
.pet-action-section {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.pet-action-section-title {
    font-size: 0.8rem;
    color: var(--sub-text-color);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 4px;
}

.pet-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.pet-action-grid .action-btn {
    width: 100%;
    max-width: none;
    padding: 10px 8px;
    font-size: 0.85rem;
}

.pet-action-full {
    grid-column: 1 / -1;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hidden {
    display: none !important;
}

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    /* Allow clicking through container */
}

.toast {
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    min-width: 280px;
    max-width: 400px;
    animation: toastSlideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    display: flex;
    align-items: center;
    gap: 12px;
    backdrop-filter: blur(10px);
    pointer-events: auto;
    /* Re-enable clicks on toasts */
    font-size: 0.95rem;
    font-weight: 500;
}

.toast.success {
    border-left: 5px solid var(--success-color);
}

.toast.error {
    border-left: 5px solid var(--danger-color);
}

.toast.info {
    border-left: 5px solid var(--primary-color);
}

.toast.warning {
    border-left: 5px solid var(--warning-color);
    color: #fff;
}

.toast-icon {
    font-size: 1.2rem;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}



@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateX(50px);
    }
}

/* Slot Animations */
@keyframes spinBlur {
    0% {
        transform: translateY(0);
        filter: blur(2px);
    }

    100% {
        transform: translateY(-50px);
        filter: blur(2px);
    }
}

@keyframes bounceStop {
    0% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(10px);
    }

    100% {
        transform: translateY(0);
    }
}

@keyframes rainbowBg {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes rainbowBorder {
    0% {
        border-color: #ff0000;
        box-shadow: 0 0 10px #ff0000;
    }

    20% {
        border-color: #ffff00;
        box-shadow: 0 0 10px #ffff00;
    }

    40% {
        border-color: #00ff00;
        box-shadow: 0 0 10px #00ff00;
    }

    60% {
        border-color: #00ffff;
        box-shadow: 0 0 10px #00ffff;
    }

    80% {
        border-color: #0000ff;
        box-shadow: 0 0 10px #0000ff;
    }

    100% {
        border-color: #ff00ff;
        box-shadow: 0 0 10px #ff00ff;
    }
}

.reel {
    width: 80px;
    height: 100px;
    background: #fff;
    border: 3px solid #000;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    color: #333;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    line-height: 1;
    text-shadow: none;
    /* No shadow needed for emoji on white */
    transition: transform 0.1s, filter 0.1s;
}

.reel.spinning {
    animation: spinBlur 0.1s linear infinite;
    color: rgba(255, 255, 255, 0.5);
    /* Dim text while spinning */
}

.reel.bounce {
    animation: bounceStop 0.3s ease-out;
}

/* Fever Mode */
.slot-machine.fever-mode {
    border: 3px solid #ff0000;
    animation: rainbowBorder 2s linear infinite;
}

.modal-content.fever-mode {
    background: linear-gradient(45deg, #330000, #331a00, #333300, #003300, #003333, #000033, #1a0033);
    background-size: 400% 400%;
    animation: rainbowBg 5s ease infinite;
}

/* Keiba Animation */
.lane {
    position: relative;
    height: 35px;
    /* Increased height */
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
}

.lane:last-child {
    border-bottom: none;
}

.goal-line {
    position: absolute;
    left: 5%;
    /* Moved to left */
    top: 0;
    bottom: 0;
    width: 4px;
    /* Thicker */
    background: repeating-linear-gradient(45deg,
            #fff,
            #fff 5px,
            #ff0000 5px,
            #ff0000 10px);
    z-index: 1;
    opacity: 0.8;
}

.horse-runner {
    position: absolute;
    left: 95%;
    /* Start from right */
    font-size: 1.8rem;
    transition: left 0.5s linear;
    z-index: 2;
    white-space: nowrap;
    line-height: 1;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    /* Removed transform: scaleX(-1) because default emoji 🐎 faces left */
}

.horse-name-tag {
    font-size: 0.65rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    padding: 1px 4px;
    border-radius: 4px;
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%);
    /* Removed scaleX(-1) */
    white-space: nowrap;
    pointer-events: none;
}

/* Advertisement */
.ad-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    padding: 10px 0;
    min-height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.ad-placeholder {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
}

/* --- Mobile Responsive Fixes --- */
@media (max-width: 600px) {
    .modal-content.wide-modal {
        width: 95%;
        max-width: none;
        padding: 15px;
        max-height: 90vh;
        /* Prevent overflow on small screens */
        overflow-y: auto;
    }

    /* Extra scroll space for Keiba on mobile */
    #modal-keiba .modal-content {
        padding-bottom: 200px;
    }

    .horse-runner {
        font-size: 1.4rem;
        /* Smaller horses */
    }

    .horse-name-tag {
        font-size: 0.5rem;
        bottom: -5px;
    }

    .lane {
        height: 30px;
        /* Thinner lanes */
    }

    .keiba-controls {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 50px;
    }

    .keiba-controls button {
        width: auto;
        flex: 1;
        margin-left: 0;
        padding: 10px 5px;
        /* 省スペース化 */
        font-size: 0.9rem;
        /* 少し文字を小さくして収まりよくする */
    }

    .race-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .bet-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .bet-controls select,
    .bet-controls input {
        width: 100%;
        margin-bottom: 5px;
    }

    /* Ensure track fits */
    .track-container {
        overflow-x: hidden;
        /* No scroll, just fit */
    }

    /* Adjust log height */
    #keiba-log-container {
        height: 80px;
        font-size: 0.8rem;
    }
}

/* Dungeon Controls (Relocated) */
.dungeon-controls-area {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px 0;
    width: 100%;
    flex-wrap: wrap;
}

/* Ensure hidden still works */
.dungeon-controls-area.hidden {
    display: none !important;
}

/* Save Data Modal */
#save-data-area {
    width: 100%;
    height: 300px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #eee;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    padding: 10px;
    resize: vertical;
    outline: none;
    white-space: pre-wrap;
    /* Allow wrapping */
    word-break: break-all;
    /* Break long strings */
    margin-top: 10px;
}

#save-data-area:focus {
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.5);
}

/* Inventory Overhaul */
.inventory-modal-panel {
    display: flex;
    flex-direction: column;
    height: 80vh;
    /* Fixed height for modal */
    max-height: 600px;
}

.inventory-tabs-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 10px;
    padding-bottom: 5px;
}


/* --- Monster Detail Modal Extensions --- */
#monster-detail-name {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.monster-detail-flavor {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    /* 暗くして可読性アップ */
    border-radius: 8px;
    font-style: italic;
    color: #ffd700;
    border-left: 5px solid var(--primary-color);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.detail-section {
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    /* セクション全体に暗い背景を追加 */
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-label {
    font-weight: bold;
    font-size: 0.85rem;
    display: inline-block;
    padding: 3px 12px;
    border-radius: 4px;
    margin-bottom: 8px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.section-edible .detail-label {
    background: #e67e22;
}

.section-cooking .detail-label {
    background: #3498db;
}

.section-taste .detail-label {
    background: #9b59b6;
}

.section-trivia .detail-label {
    background: #27ae60;
}

.detail-text {
    font-size: 1.25rem;
    padding-left: 12px;
    border-left: 3px solid var(--primary-color);
    margin-top: 5px;
    color: #fff;
    line-height: 1.5;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.monster-detail-scroll-area {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 12px;
}

.inventory-tabs {
    display: flex;
    gap: 10px;
}

.inventory-sort-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 5px 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: #ddd;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
}

.inventory-summary-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.inventory-grid {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    /* Card Width increased to prevent squashing */
    gap: 12px;
    padding: 10px;
    align-content: start;
}

/* Item Card */
.item-card {
    background: rgba(30, 30, 40, 0.9);
    border: 25px solid transparent; /* Slightly thinner border to gain content space */
    border-image: url('../images/UI/ui_window_frame.webp') 150 stretch;
    border-radius: 0;
    padding: 5px;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    display: flex;
    flex-direction: column;
    min-height: 180px; /* Increased min-height */
    height: auto;
}

/* ... existing hover styles ... */

.item-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    margin-bottom: 8px;
    min-height: 24px;
}

.item-name {
    font-weight: bold;
    font-size: 0.85rem;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Restricted to 2 lines for card balance */
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.6em; /* Fixed height for name to align other elements */
    margin-bottom: 5px;
}

/* Favorite Button inside card */
.btn-favorite {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    transition: transform 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-favorite:hover {
    transform: scale(1.2);
}

.btn-favorite.active {
    filter: drop-shadow(0 0 2px rgba(255, 0, 0, 0.5));
}

.item-stats {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: auto;
    /* Push to bottom */
    text-align: center;
}

.item-price {
    font-size: 0.75rem;
    color: gold;
    text-align: right;
    margin-top: 4px;
}

.item-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #4CAF50;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.inventory-actions {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* --- Item Tooltip --- */
/* --- Tooltip Trigger Button (Mobile) --- */
.tooltip-trigger {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    /* Reverted to 24px */
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    /* Reverted to 14px */
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    /* Above card click area */
    pointer-events: auto;
    /* Ensure clickable */
    transition: background 0.2s;
}

.tooltip-trigger:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Progress Bar (Bulk Reincarnate) */
.progress-container {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #81c784);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    transition: width 0.3s ease;
}

#auto-loop-speed {
    width: 100% !important;
}

/* --- Item Tooltip --- */
.item-tooltip {
    position: fixed;
    z-index: 100001;
    /* Highest Priority (Above everything) */
    pointer-events: none;
    /* Pass through mouse events */
    background: rgba(15, 15, 19, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    max-width: 320px;
    white-space: normal;
    transition: opacity 0.15s ease, visibility 0.15s;
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: 85vh;
    min-width: 240px;
    overflow-y: auto;
    opacity: 1;
    visibility: visible;
    scrollbar-width: none; /* Firefox */
}

.item-tooltip::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.item-tooltip.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.tooltip-header {
    font-weight: bold;
    margin-bottom: 0px;
    /* Removed margin */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 2px;
    font-size: 1.0em;
    text-align: left;
    line-height: 1.1;
    /* Tighter line height */
}

.tooltip-level {
    display: flex;
    flex-direction: column;
}

.tooltip-level.hidden {
    display: none !important;
}

.tooltip-body {
    display: flex;
    flex-direction: column;
    gap: 0px;
    /* No gap */
    margin-top: 2px;
    /* Small gap from border */
    font-size: 0.9em;
    line-height: 1.1;
}

.tooltip-stat {
    display: flex;
    justify-content: space-between;
    font-family: 'Consolas', monospace;
    line-height: 1.2;
    /* Tighten line height */
}

.tooltip-affix {
    margin-top: 6px;
    /* Reduced from 8px */
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    font-size: 0.8em;
    color: #ccc;
    display: flex;
    flex-direction: column;
    gap: 1px;
    /* Very tight gap for affixes */
}

.affix-row {
    color: #ffd700;
    /* Gold for affixes */
    line-height: 1.2;
}

/* --- Form Elements (Inputs & Selects UX Improvement) --- */
input[type="number"], select {
    background-color: rgba(30, 30, 40, 0.9);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5);
    transition: all 0.2s ease;
    outline: none;
}

input[type="number"]:focus, select:focus {
    border-color: #4facfe;
    box-shadow: 0 0 10px rgba(79, 172, 254, 0.6), inset 0 2px 5px rgba(0,0,0,0.5);
}

select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23FFFFFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px auto;
    padding-right: 40px;
    cursor: pointer;
}

select option {
    background-color: #222;
    color: #fff;
    padding: 10px;
}

/* --- Chat Styles --- */
.chat-log-area {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    font-size: 0.95rem;
    animation: slideIn 0.2s ease;
}

.chat-message.system {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: #aaa;
    font-size: 0.8rem;
    text-align: center;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 4px;
}

.chat-name {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.9rem;
}

.chat-time {
    font-size: 0.75rem;
    color: #666;
}

.chat-body {
    line-height: 1.4;
    word-break: break-all;
    white-space: pre-wrap;
}

.chat-link {
    color: #4fc3f7;
    text-decoration: underline;
    cursor: default;
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
}

.chat-input-row {
    display: flex;
    gap: 10px;
}

.chat-input-field {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    font-family: inherit;
}

.chat-input-field:focus {
    border-color: var(--primary-color);
    outline: none;
}

.chat-input-field.name {
    width: 150px;
}

.chat-input-field.comment {
    flex: 1;
    resize: none;
    height: 40px;
}

.send-btn {
    width: 80px;
    height: 40px;
    align-self: center;
    /* Align with textarea */
}

/* ===== Floating Action Areas (Stack Layout) ===== */
#floating-action-area-right,
#floating-action-area-left {
    position: fixed;
    z-index: 21000;
    /* セーフエリア + 基本余白(15px) */
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column-reverse;
    gap: 15px;
    pointer-events: none;
    transform: scale(var(--ui-scale, 1.0));
}

#floating-action-area-right {
    right: 15px;
    align-items: flex-end;
}

#floating-action-area-left {
    left: 15px;
    align-items: flex-start;
}

#floating-action-area-right>*,
#floating-action-area-left>* {
    pointer-events: auto;
}

/* Wrappers for diagonal expansion */
#wrapper-menu,
#wrapper-chat {
    position: relative;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Floating Chat Widget ===== */
#floating-chat-container {
    position: static;
    inset: auto;
    margin: 0;
}

/* ===== Pet Avatar Widget (Floating Area Version) ===== */
.pet-widget {
    position: relative;
    width: 3.75rem; /* ボタンと同じサイズ感へ */
    height: 3.75rem;
    cursor: pointer;
    z-index: 22000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pet-widget-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pet-widget-bubble {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    white-space: nowrap;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--primary-color);
    pointer-events: none;
}

.pet-widget-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 15px;
    border-width: 8px;
    border-style: solid;
    border-color: var(--primary-color) transparent transparent transparent;
}

/* フローティングボタン */
.floating-chat-btn {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(68, 138, 255, 0.5);
}

.floating-chat-btn.has-unread {
    animation: floatingPulse 1.5s infinite;
}

/* 未読バッジ */
.floating-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgeBounce 0.5s ease;
}

@keyframes badgeBounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* --- Transcendence Effect Styles --- */
.btn-rainbow {
    background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
    background-size: 1800% 1800%;
    animation: rainbow-bg 5s ease infinite;
    color: white;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    border: none;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(213, 0, 249, 0.4);
    transition: transform 0.2s;
    font-size: 1.2rem;
}

.btn-rainbow:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(213, 0, 249, 0.6);
}

@keyframes rainbow-bg {
    0% {
        background-position: 0% 82%
    }

    50% {
        background-position: 100% 19%
    }

    100% {
        background-position: 0% 82%
    }
}

.transcendence-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

.transcendence-particle {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    font-size: 2.5rem;
    animation: particle-fade-up 3s forwards ease-out;
}

@keyframes particle-fade-up {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(0);
        opacity: 0;
    }

    20% {
        opacity: 1;
        transform: translate(var(--tx), var(--ty)) rotate(180deg) scale(1.5);
    }

    100% {
        transform: translate(var(--tx2), var(--ty2)) rotate(360deg) scale(1);
        opacity: 0;
    }
}

/* --- Monster Book Styles --- */
.monster-buff-banner {
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.3), rgba(68, 138, 255, 0.3));
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#fishing-book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding: 10px;
    max-height: 55vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.fishing-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.fishing-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.monster-book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding: 10px;
    max-height: 55vh;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.monster-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.monster-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.monster-card.unknown {
    opacity: 0.5;
    filter: grayscale(1);
    cursor: default;
    background: rgba(0, 0, 0, 0.3);
}

/* --- Blacksmith Ore UI (Rich Version) --- */
.ore-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.ore-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.ore-item.selected-ore {
    background: rgba(255, 255, 0, 0.05);
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3), inset 0 0 10px rgba(255, 215, 0, 0.1);
}

.ore-item[data-ore="ore_sand"] {
    border-left: 3px solid #d2b48c;
}

.ore-item[data-ore="ore_shard"] {
    border-left: 3px solid #87ceeb;
}

.ore-item[data-ore="ore_jewel"] {
    border-left: 3px solid #ff69b4;
}

.ore-item[data-ore="ore_gem"] {
    border-left: 3px solid #adff2f;
}

.ore-icon-large {
    font-size: 1.8rem;
    margin-bottom: 4px;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

.ore-synth-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.2s;
    overflow: hidden;
}

.ore-synth-row:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

.ore-enhance-info-panel {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.7);
    color: #fff;
}

.text-outline {
    text-shadow:
        -1px -1px 0 #333,
        1px -1px 0 #333,
        -1px 1px 0 #333,
        1px 1px 0 #333,
        0px 0px 4px rgba(0, 0, 0, 0.8);
}

.btn-ore-synth {
    min-width: 100px;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.inventory-selector h3 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 15px 0 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.monster-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.monster-card .monster-name {
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monster-card .boss-label {
    background: var(--danger-color);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 800;
}

.monster-card .card-count {
    font-size: 0.8rem;
    color: var(--sub-text-color);
}

.monster-card .card-buff {
    font-size: 0.75rem;
    color: var(--success-color);
    font-weight: bold;
    margin-top: auto;
}

@media (max-width: 600px) {
    .monster-book-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }
}

/* チャットウィジェット本体 */
.floating-chat-widget {
    position: fixed;
    bottom: 90px;
    right: 90px;
    transform-origin: bottom right;
    width: 350px;
    height: 450px;
    z-index: 21001;
    /* Higher than wrapper */
    background: #1e1e24;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: widgetSlideIn 0.3s ease;
}

.floating-chat-widget.hidden {
    display: none !important;
}

@keyframes widgetSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes floatingPulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    50% {
        box-shadow: 0 4px 30px rgba(255, 82, 82, 0.6);
    }
}

/* ウィジェットヘッダー */
.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: linear-gradient(135deg, rgba(68, 138, 255, 0.2), rgba(124, 77, 255, 0.2));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.widget-title {
    font-weight: bold;
    font-size: 1rem;
    color: #fff;
}

.widget-controls {
    display: flex;
    gap: 8px;
}

.widget-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ccc;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* チャットログエリア */
.widget-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
}

.widget-chat-log .chat-message {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.85rem;
}

.widget-chat-log .chat-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.widget-chat-log .chat-name {
    font-weight: bold;
    color: var(--primary-color);
}

.widget-chat-log .chat-time {
    font-size: 0.7rem;
    color: #888;
}

.widget-chat-log .chat-body {
    color: #ddd;
    line-height: 1.4;
    word-break: break-word;
}

.widget-chat-log .chat-message.system {
    background: rgba(68, 138, 255, 0.1);
    color: #aaa;
    text-align: center;
    font-size: 0.8rem;
}

/* 入力エリア */
.widget-input-area {
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.widget-input-area input,
.widget-input-area textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    padding: 8px 10px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.widget-input-area input:focus,
.widget-input-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.widget-input-area input {
    margin-bottom: 8px;
}

.widget-input-row {
    display: flex;
    gap: 8px;
}

.widget-input-row textarea {
    flex: 1;
    resize: none;
    height: 50px;
}

.widget-send-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    color: white;
    width: 50px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.widget-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(68, 138, 255, 0.4);
}

/* モバイル対応 */
@media (max-width: 450px) {

    #wrapper-menu,
    #wrapper-chat {
        width: 50px;
        height: 50px;
    }

    iframe {
        max-width: 100%;
        /* Prevent iframe overflow */
    }

    #floating-action-area-right {
        right: calc(10px + env(safe-area-inset-right));
        /* Prevent cutoff */
    }

    .floating-chat-widget {
        position: fixed;
        width: calc(100vw - 30px);
        height: 40vh;
        /* Aligned top of menu button + 1 button size gap (50px) */
        /* Chat(50) + Gap(15) + Menu(50) + Gap(50) = 165px */
        bottom: 180px;
        right: 15px;
        top: auto;
        z-index: 21001;
    }

    #floating-chat-container {
        /* Reset mobile overrides */
        right: auto;
        bottom: auto;
    }

    .floating-chat-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
}

/* =========================================
   Cookie Consent Banner
   ========================================= */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 28, 0.98));
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding: 15px 20px;
    z-index: 10000;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.consent-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.consent-content p {
    margin: 0;
    font-size: 0.9rem;
    color: #ddd;
    flex: 1;
    min-width: 200px;
}

.consent-content .action-btn {
    flex-shrink: 0;
    min-width: 120px;
    padding: 10px 25px;
}

/* モバイル対応 */
@media (max-width: 500px) {
    .cookie-consent-banner {
        padding: 12px 15px;
    }

    .consent-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .consent-content p {
        font-size: 0.85rem;
    }

    .consent-content .action-btn {
        width: 100%;
    }
}

/* Pet Dialogue Container */
.pet-dialogue-container {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    pointer-events: none;
    margin-bottom: 10px;
    animation: bubblePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pet-dialogue-icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
    margin-bottom: -15px;
    /* Overlap slightly with bubble */
    z-index: 2;
    animation: iconBounce 2s infinite ease-in-out;
}

/* Fix for Pet Detail dialogue z-index */
.pet-dialogue-inline-container {
    z-index: 18000 !important;
}

/* --- Blacksmith Ore Feature Enhancements --- */

/* 鉱石アイテムカード */
.ore-item {
    background: rgba(45, 55, 72, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    margin: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-width: 100px;
}

.ore-item:hover {
    transform: translateY(-4px);
    background: rgba(60, 75, 95, 0.6);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.ore-item.selected-ore {
    background: linear-gradient(135deg, rgba(66, 153, 225, 0.3), rgba(66, 153, 225, 0.1));
    border: 2px solid #4299e1 !important;
    box-shadow: 0 0 15px rgba(66, 153, 225, 0.5);
}

.ore-icon-wrapper {
    font-size: 2.5rem;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.ore-name {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 4px;
    text-align: center;
    color: #fff;
}

.ore-count {
    font-size: 0.85rem;
    color: #a0aec0;
    font-family: 'Inter', sans-serif;
}

/* 強化セクションのパネル */
.ore-enhance-panel {
    background: linear-gradient(180deg, rgba(26, 32, 44, 0.8), rgba(45, 55, 72, 0.8));
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 24px;
    margin-top: 16px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.05);
}

.enhance-target-slot {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    margin: 0 auto 16px;
}

.enhance-target-slot.occupied {
    background: rgba(66, 153, 225, 0.1);
    border: 2px solid #4299e1;
    border-style: solid;
}

/* 成功率・費用表示 */
.enhance-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.info-item {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 10px;
    text-align: center;
}

.info-label {
    font-size: 0.75rem;
    color: #718096;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.info-value {
    font-size: 1.1rem;
    font-weight: bold;
    font-family: 'JetBrains Mono', monospace;
}

/* 成功率の色分け */
.rate-high {
    color: #48bb78;
}

.rate-mid {
    color: #ecc94b;
}

.rate-low {
    color: #f56565;
}

/* 合成システム用 */
.ore-synth-row {
    background: rgba(45, 55, 72, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.ore-synth-row:hover {
    background: rgba(45, 55, 72, 0.5);
    border-color: rgba(66, 153, 225, 0.3);
}

.synth-arrow {
    font-size: 1.5rem;
    color: #4299e1;
    margin: 0 10px;
}

.synth-btn {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 100px;
}

.synth-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(66, 153, 225, 0.6);
}

.synth-btn:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.6;
}

/* 費用テキストの強調 */
.cost-text {
    font-family: 'JetBrains Mono', monospace;
    color: #ecc94b;
}

/* レアリティ別の光彩 */
.rarity-COMMON {
    border-left: 4px solid #b0b0b0;
}

.rarity-RARE {
    border-left: 4px solid #60a5fa;
}

.rarity-LEGENDARY {
    border-left: 4px solid #ff4500;
}

.rarity-GOD {
    border-left: 4px solid #ffd700;
    animation: god-glow 2s infinite alternate;
}

@keyframes god-glow {
    from {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }

    to {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
}

/* =========================================
   Transcendence (超越) Styles
   ========================================= */
.syn-slot.selected {
    border-color: #d500f9 !important;
    background: rgba(213, 0, 249, 0.2) !important;
    box-shadow: 0 0 15px rgba(213, 0, 249, 0.5), inset 0 0 10px rgba(213, 0, 249, 0.2);
    transform: scale(1.05);
}

.transcendence-preview {
    border: 1px solid rgba(213, 0, 249, 0.3);
    box-shadow: inset 0 0 20px rgba(213, 0, 249, 0.1);
}

#btn-open-transcendence.pet-action-full {
    width: 100%;
    margin-top: 10px;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}



#trans-protection-list {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

#trans-shop-list::-webkit-scrollbar,
#trans-protection-list::-webkit-scrollbar {
    width: 6px;
}

#trans-shop-list::-webkit-scrollbar-thumb,
#trans-protection-list::-webkit-scrollbar-thumb {
    background: rgba(213, 0, 249, 0.3);
    border-radius: 3px;
}

.trans-shop-info {
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.1);
}

.secondaryDisabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Ensure Slot Modal Content allows overflow for popping icon */
#modal-slot .modal-content {
    overflow: visible !important;
}

/* Large Pet Icon (100px) */
.pet-icon-large {
    width: 100px;
    height: 100px;
    object-fit: contain;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.1s;
}

.pet-icon-large:active {
    transform: scale(0.95);
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* ペット詳細・お世話用 吹き出し */
.pet-dialogue-bubble {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(255, 255, 255, 0.98);
    color: #333;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);

    /* 確実に折り返すための設定 */
    white-space: normal !important;
    word-break: break-all !important;
    width: 260px;
    max-width: 90vw;
    line-height: 1.4;
    text-align: center;
    border: 2px solid #333;
    z-index: 18000 !important;

    display: none;
    pointer-events: none;
}

.pet-dialogue-bubble.show {
    display: block;
    animation: bubblePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pet-dialogue-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    /* 下側に配置 */
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    /* 下向きの矢印 */
}

/* Slot Win Display */
.slot-win-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    font-weight: 900;
    color: #FFD700;
    /* Gold */
    text-shadow:
        2px 2px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000,
        1px 1px 0 #000;
    z-index: 101;
    pointer-events: none;
    animation: winFlash 0.5s ease-in-out infinite alternate, winPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
}

@keyframes bubblePop {
    0% {
        transform: translateX(-50%) scale(0.5);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

@keyframes winPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    80% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes winFlash {
    from {
        text-shadow: 0 0 10px #FFD700, 2px 2px 0 #000;
    }

    to {
        text-shadow: 0 0 20px #FF8C00, 2px 2px 0 #000;
    }
}

/* Ensure Modal Content is the base for absolute positioning */
#modal-slot .modal-content,
#modal-fishing .modal-content {
    position: relative;
    overflow: visible !important;
}

/* --- Pet Message Window (Minigames) - Premium Frame Design --- */
.pet-message-window {
    display: flex;
    align-items: flex-start;
    background: rgba(30, 30, 35, 0.85);
    /* Darker base for contrast */
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 15px;
    margin: 0 10px 20px 10px;
    gap: 15px;
    min-height: 90px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: slideInDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.pet-message-icon-wrapper {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.5);
}

.pet-message-icon {
    width: 95%;
    height: 95%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.pet-message-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pet-message-name {
    font-size: 0.9rem;
    font-weight: 900;
    color: #ffca28;
    /* Vivid amber for name */
    margin-bottom: 8px;
    letter-spacing: 0.05em;
}

/* The requested "Frame" for dialogue text */
.pet-message-text {
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.6;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    /* Much darker for readability */
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 4px solid #ffca28;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure Scene Containers allow display */
.slot-machine,
.fishing-scene {
    position: relative;
    overflow: visible !important;
}

/* Disable old dialogue */
.pet-dialogue-container {
    display: none !important;
}

/* =========================================
   Floating Hamburger Menu
   ========================================= */
#floating-menu-container {
    position: static;
    inset: auto;
    margin: 0;
    z-index: auto;
    display: block;
    width: 100%;
    height: 100%;
}

/* Ensure children catch events */
#floating-menu-container>* {
    pointer-events: auto;
}

/* Ensure children catch events */
#floating-menu-container>* {
    pointer-events: auto;
}

/* Toggle Menu Button (Hamburger) */
.floating-menu-btn {
    width: 3.75rem; /* 60px -> 3.75rem */
    height: 3.75rem;
    border-radius: 50%;
    background: rgba(30, 30, 35, 0.95);
    border: 0.06rem solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 900; /* Lower than modal (usually 1000+), but higher than normal content */
}

.floating-menu-btn:hover {
    transform: scale(1.1);
    background: rgba(50, 50, 60, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
}

.floating-menu-btn.active {
    background: var(--primary-color);
    transform: rotate(90deg);
    box-shadow: 0 0 15px rgba(68, 138, 255, 0.6);
}

/* Menu Dropdown List */
.floating-menu-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;

    /* Diagonal Top-Left Expansion */
    position: absolute;
    bottom: 75px;
    right: 75px;
    transform-origin: bottom right;

    /* Scroll Support */
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;

    /* Animation */
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none !important;
    /* Start hidden/inactive */
    transition: all 0.25s ease-out;
    transform-origin: bottom right;

    /* Firefox Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

/* Chrome/Webkit Scrollbar */
.floating-menu-list::-webkit-scrollbar {
    width: 6px;
}

.floating-menu-list::-webkit-scrollbar-track {
    background: transparent;
}

.floating-menu-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.floating-menu-list.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto !important;
}

.menu-item {
    background-color: transparent;
    background-image: url('../images/UI/ui_btn_secondary_n.webp');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;

    border: none;
    color: #fff;
    padding: 0.8rem 1.25rem; /* 1.5rem 1.75rem -> 0.8rem 1.25rem */
    font-size: 1.05rem;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 0.125rem 0.6rem rgba(0, 0, 0, 0.5);
    transition: transform 0.1s, filter 0.2s;
    text-shadow: 0.06rem 0.06rem 0.18rem rgba(0, 0, 0, 0.8), 0 0 0.3rem rgba(0, 0, 0, 0.5);
    min-height: 2.5rem; /* 3.5rem -> 2.5rem */
    backdrop-filter: blur(5px);

    /* Fixed width or min-width */
    min-width: 8rem;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
}

.menu-item:hover {
    background-image: url('../images/UI/ui_btn_secondary_h.webp');
}


/* ダンジョンへボタンの文字サイズ調整のみ個別に適用 */
#btn-dungeon {
    font-size: 0.9rem !important;
}


/* 400px以下ではさらにタイトに */
@media (max-width: 400px) {
    .menu-item {
        min-height: 3rem;
        padding: 1rem 1.25rem;
        min-width: 7rem;
    }
}



/* Discord Button */
#floating-discord-container {
    position: static;
    inset: auto;
    margin: 0;
    z-index: auto;
}

#floating-discord-container>* {
    pointer-events: auto;
}

.floating-discord-btn {
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 50%;
    background: #5865F2;
    border: 0.06rem solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-discord-btn svg {
    pointer-events: none;
}

.floating-discord-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(88, 101, 242, 0.8);
}

@media (max-width: 450px) {
    /* Discord Container position adjustments removed (handled by stack) */


    .floating-discord-btn {
        width: 50px;
        height: 50px;
    }
}

/* Mobile Adjustments */
@media (max-width: 450px) {
    .floating-menu-list {
        bottom: 65px;
        /* 50px + 15px */
        right: 65px;
    }


    .floating-menu-btn {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .menu-item {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    /* =========================================
   Modal Header Improvements
   ========================================= */
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 10px;
    }



    .modal-header h2 {
        margin: 0;
        border-bottom: none;
        padding-bottom: 0;
        font-size: 1.5rem;
    }

    /* Link Button Utility */
    .header-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: auto;
        /* Override action-btn default */
        flex: initial;
        /* Override action-btn default */
        display: flex;
        align-items: center;
        gap: 5px;
    }
}

/* Profile & Like Button Styles */
.like-button {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.like-button:active {
    transform: scale(0.9);
}

.like-button.liked {
    background: rgba(233, 30, 99, 0.2);
    border-color: #e91e63;
}

.like-button.liked span {
    transform: scale(1.1);
}

.clickable-name {
    cursor: pointer;
    color: #448aff;
    text-decoration: underline;
    transition: color 0.2s;
}

.clickable-name:hover {
    color: #82b1ff;
}

.profile-header {
    padding: 10px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 100%);
    border-radius: 8px;
}

.equip-card {
    background: rgba(30, 30, 40, 0.9);
    border: 30px solid transparent;
    border-image: url('../images/UI/ui_window_frame.webp') 150 stretch;
    border-radius: 0;
    padding: 8px;
    transition: border-color 0.2s, filter 0.2s;
    min-height: 80px;
}

.equip-card:hover {
    border-color: rgba(255, 255, 255, 0.3);
}




/* === チュートリアルシステム === */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    pointer-events: none;
    /* クリックを透過させる */
}

.tutorial-highlight {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    border: 3px solid var(--accent-color);
    transition: all 0.3s ease;
    pointer-events: none;
    animation: tutorialPulse 2s ease-in-out infinite;
}

@keyframes tutorialPulse {

    0%,
    100% {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75), 0 0 10px var(--accent-color);
    }

    50% {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.75), 0 0 20px var(--primary-color);
    }
}

.tutorial-tooltip {
    position: absolute;
    max-width: 320px;
    min-width: 280px;
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.98), rgba(20, 20, 30, 0.98));
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    animation: tooltipFadeIn 0.3s ease;
    pointer-events: auto;
    /* ボタンをクリック可能に */
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tooltip-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--accent-color);
}

.tooltip-progress {
    font-size: 0.8rem;
    color: #888;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
}

.tooltip-content {
    color: var(--text-color);
    line-height: 1.6;
    margin-bottom: 16px;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.tooltip-controls {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.tooltip-controls .action-btn {
    min-width: auto;
    max-width: none;
    padding: 10px 20px;
}

/* ハイライト対象のz-index調整 */
.tutorial-target {
    position: relative;
    z-index: 10001 !important;
    pointer-events: auto !important;
}

/* モバイル対応 */
@media (max-width: 600px) {
    .tutorial-tooltip {
        max-width: calc(100vw - 40px);
        min-width: 260px;
        padding: 16px;
    }

    .tooltip-title {
        font-size: 1.05rem;
    }

    .tooltip-content {
        font-size: 0.9rem;
    }

    .tooltip-controls .action-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

/* --- Fishing Animations --- */
@keyframes floatBob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes fishShake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

@keyframes rippleEffect {
    0% {
        transform: scale(0.1);
        opacity: 1;
    }

    100% {
        transform: scale(2.0);
        opacity: 0;
    }
}

@keyframes particleFade {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(0);
        opacity: 0;
    }
}

.fishing-float {
    font-size: 4rem;
    display: inline-block;
    position: relative;
    z-index: 10;
    transition: all 0.3s;
}

.fishing-float.is-floating {
    animation: floatBob 2s ease-in-out infinite;
}

.fishing-float.is-hit {
    animation: fishShake 0.5s cubic-bezier(.36, .07, .19, .97) both infinite;
    color: #ff5252;
    transform-origin: center bottom;
}

.fishing-scene {
    position: relative;
    overflow: hidden;
    display: flex;
    /* Center content */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fishing-particle {
    position: absolute;
    pointer-events: none;
    font-size: 1.5rem;
    animation: particleFade 1s ease-out forwards;
    z-index: 20;
}

.fishing-ripple {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    top: 50%;
    left: 50%;
    margin-left: -30px;
    margin-top: -30px;
    animation: rippleEffect 1.5s ease-out infinite;
    pointer-events: none;
    z-index: 5;
}

/* Keiba Animation & Scrolling Track (Treadmill Layout) */
.track-window {
    width: 100%;
    height: 500px;
    /* Significantly increased height */
    overflow-y: auto !important;
    overflow-x: hidden;
    position: relative;
    background: #87CEEB;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* --- Keiba Scroll & Visibility Improvements --- */

/* 1. Horse List Scroll */
.horse-list-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.horse-list-container::-webkit-scrollbar {
    width: 6px;
}

.horse-list-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.horse-list-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* 2. Text Visibility (Horse List) */
#horse-list td {
    color: #e0e0e0;
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        -1px 1px 0 #000,
        1px -1px 0 #000;
}

/* --- Mutation Ability Tree --- */
.ability-tree-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #0a001a 0%, #000 100%);
    overflow: hidden;
    color: white;
}

.ability-tree-header {
    padding: 15px 20px;
    background: rgba(41, 0, 71, 0.5);
    border-bottom: 1px solid rgba(156, 39, 176, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.ability-tree-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#ability-tree-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#ability-tree-canvas:active {
    cursor: grabbing;
}

.ability-ui-header {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    text-shadow: 0 0 10px #ff00ff;
}

.ap-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffd700;
}

.ability-tree-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    pointer-events: none;
    z-index: 5;
}

.control-hint {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 20px;
}

.ability-detail-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 280px;
    max-height: calc(100% - 40px);
    padding: 20px;
    border: 1px solid #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
    background: rgba(10, 0, 20, 0.9);
    z-index: 20;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    border-radius: 8px;
}

@keyframes mutatePulse {
    0% {
        border-color: #4a148c;
        box-shadow: 0 0 10px #4a148c;
    }

    100% {
        border-color: #ff00ff;
        box-shadow: 0 0 30px #ff00ff;
    }
}

.node-detail-status {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 0.9em;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2px;
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
}

/* 3. Mobile Adjustments for Keiba */
@media (max-width: 600px) {
    .horse-list-container {
        max-height: 40vh;
    }

    .track-window {
        height: 60vh;
    }
}

.track-container {
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: none;
    will-change: transform;
    z-index: 10;
    overflow: hidden;
    padding-top: 150px;
    /* Ample sky/mountain space */
    box-sizing: border-box;
}

/* Parallax Backgrounds */
.track-bg-sky {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 100%);
    z-index: 1;
}

.track-bg-mountains {
    position: absolute;
    bottom: 70%;
    /* Sit on horizon */
    left: 0;
    width: 100%;
    height: 50%;
    background:
        linear-gradient(135deg, transparent 50%, #5D4037 50%),
        linear-gradient(225deg, transparent 50%, #5D4037 50%);
    background-position: 0 bottom;
    background-size: 100px 100px;
    background-repeat: repeat-x;
    opacity: 0.8;
    z-index: 2;
}

.track-bg-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    /* Covers bottom 350px */
    background: #2e7d32;
    border-top: 5px solid #1b5e20;
    z-index: 5;
    background-image: repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0, 0, 0, 0.1) 40px, rgba(0, 0, 0, 0.1) 80px);
    background-size: 80px 100%;
    background-repeat: repeat-x;
}

.lane {
    position: relative;
    height: 40px;
    /* Increased lane height slightly */
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    width: 100%;
}

.horse-runner {
    position: absolute;
    z-index: 20;
    font-size: 2.5rem;
    /* Larger horses */
    filter: drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5));
}

@keyframes gallop {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-3px) rotate(-5deg);
    }

    50% {
        transform: translateY(0) rotate(0deg);
    }

    75% {
        transform: translateY(-1px) rotate(5deg);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

.horse-runner.running {
    animation: gallop 0.4s infinite linear;
}

.goal-line {
    position: absolute;
    width: 10px;
    background: repeating-linear-gradient(45deg, #fff, #fff 10px, #000 10px, #000 20px);
    height: 100%;
    top: 0;
}

/* --- Keiba Betting Screen Visuals --- */
.waku-1 {
    background-color: #f0f0f0;
    color: #222;
    border-left: 5px solid #fff;
}

/* White */
.waku-2 {
    background-color: #222;
    color: #fff;
    border-left: 5px solid #000;
}

/* Black */
.waku-3 {
    background-color: #ffebee;
    color: #222;
    border-left: 5px solid #d32f2f;
}

/* Red */
.waku-4 {
    background-color: #e3f2fd;
    color: #222;
    border-left: 5px solid #1976d2;
}

/* Blue */
.waku-5 {
    background-color: #fffde7;
    color: #222;
    border-left: 5px solid #fbc02d;
}

/* Yellow */
.waku-6 {
    background-color: #e8f5e9;
    color: #222;
    border-left: 5px solid #388e3c;
}

/* Green */
.waku-7 {
    background-color: #fff3e0;
    color: #222;
    border-left: 5px solid #f57c00;
}

/* Orange */
.waku-8 {
    background-color: #fce4ec;
    color: #222;
    border-left: 5px solid #c2185b;
}

/* Pink */

.prediction-mark {
    font-weight: bold;
    font-size: 1.2em;
}

.pred-◎ {
    color: #d32f2f;
}

/* Red */
.pred-〇 {
    color: #1976d2;
}

/* Blue */
.pred-▲ {
    color: #388e3c;
}

/* Green */
.pred-△ {
    color: #757575;
}

/* Gray */

.history-container {
    display: flex;
    gap: 2px;
    font-size: 0.8em;
}

.history-box {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    background: #444;
    color: #ccc;
}

/* Adjust History Box colors for better visibility on light BGs if needed, but they are decent */
.hist-1 {
    background: #fbc02d;
    color: #000;
    font-weight: bold;
}

/* 1st Gold */
.hist-2 {
    background: #e0e0e0;
    color: #000;
    font-weight: bold;
}

/* 2nd Silver */
.hist-3 {
    background: #bcaaa4;
    color: #000;
    font-weight: bold;
}

/* 3rd Bronze */
.hist-out {
    background: #555;
    color: #ccc;
}

/* 4th+ */

.horse-row {
    cursor: pointer;
    transition: background 0.2s;
}

.horse-row:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Darken on hover for light BGs */
.horse-row.selected {
    background: rgba(255, 215, 0, 0.4);
    border: 1px solid #b8860b;
}

.horse-meta {
    display: flex;
    flex-direction: column;
    font-size: 0.85em;
    color: inherit;
    opacity: 0.8;
}

.horse-name-cell {
    font-weight: bold;
    font-size: 1.1em;
    color: inherit;
}

/* Auto Sell Settings */
#auto-sell-options label {
    transition: background-color 0.2s;
    border-radius: 4px;
}

#auto-sell-options label:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#auto-sell-options input[type="checkbox"] {
    accent-color: var(--primary-color);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Pet Icon Inline */
.pet-icon-inline {
    width: 2.0em;
    /* Increased from 1.2em */
    height: 2.0em;
    /* Increased from 1.2em */
    vertical-align: middle;
    margin-bottom: 0.2em;
    object-fit: contain;
    transition: transform 0.1s;
}

.pet-icon-inline:active {
    transform: scale(0.9);
}

/* Modal UI Improvements */
.large-modal-btn {
    min-width: 150px !important;
    padding: 15px 30px !important;
    font-size: 1.1rem !important;
    margin-top: 10px;
}

/* Range Slider Customization */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

/* Chrome, Safari, Opera */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #facc15;
    cursor: pointer;
    border-radius: 50%;
    margin-top: -6px;
    /* Adjust based on track height */
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #4b5563;
    border-radius: 2px;
}

/* Firefox */
input[type=range]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #facc15;
    cursor: pointer;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

/* ダンジョンへボタンの個別寸法指定を完全に排除 */




input[type=range]::-moz-range-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #4b5563;
    border-radius: 2px;
}

/* ==================== Pet Care Modal Styles ==================== */
.pet-care-panel {
    max-width: 600px;
    text-align: center;
}

.care-status-bar {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.care-stat {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.care-label {
    font-size: 0.8rem;
    color: var(--sub-text-color);
}

#care-fullness-display,
#care-affection-display {
    font-size: 1.2rem;
}

/* ペットルームエリア */
.pet-room-area {
    height: 300px;
    background: linear-gradient(135deg, rgba(100, 200, 100, 0.15), rgba(50, 150, 200, 0.15));
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.15);
    padding-top: 60px;
    /* Space for dialogue */
}

/* ペットアイコン - position: absolute で移動可能 */
.care-pet-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    cursor: pointer;
    user-select: none;
    /* 滑らかな移動：left/topの変化を2.5秒かけてアニメーション */
    transition: left 2.5s cubic-bezier(0.4, 0, 0.2, 1),
        top 2.5s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    /* 常時ふわふわ浮遊 */
    animation: petFloat 3s ease-in-out infinite;
    z-index: 2;
}

.care-pet-icon img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    pointer-events: none;
}

/* ふわふわ浮遊アニメーション */
@keyframes petFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-12px);
    }
}

/* バウンス (ごはんのリアクション) */
.care-pet-icon.bounce {
    animation: petBounce 0.6s ease !important;
}

@keyframes petBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    25% {
        transform: translateY(-25px);
    }

    50% {
        transform: translateY(0);
    }

    75% {
        transform: translateY(-10px);
    }
}

/* シェイク (かまうのリアクション) */
.care-pet-icon.shake {
    animation: petShake 0.5s ease !important;
}

@keyframes petShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px) rotate(-5deg);
    }

    40% {
        transform: translateX(8px) rotate(5deg);
    }

    60% {
        transform: translateX(-5px) rotate(-3deg);
    }

    80% {
        transform: translateX(5px) rotate(3deg);
    }
}

/* (Duplicate definition removed, integrated into line 1997) */

/* ボタンコントロール */
.care-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.care-controls .action-btn {
    min-width: 160px;
}

/* お世話通知バッジ */
.care-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    animation: badgePulse 1s infinite;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

/* 変異アビリティボタン専用スタイル */
.btn-mutation {
    background-image: url('../images/UI/ui_btn_primary_n.webp') !important;
    background-color: transparent !important;
    background-size: 100% 100% !important;
    filter: hue-rotate(60deg) saturate(1.2) !important;
    transition: all 0.3s ease;
    border: none !important;
}

.btn-mutation:hover:not(:disabled) {
    background-image: url('../images/UI/ui_btn_primary_h.webp') !important;
    filter: hue-rotate(60deg) saturate(1.5) brightness(1.2) !important;
    transform: translateY(-2px);
}


.btn-mutation:disabled {
    filter: grayscale(1) opacity(0.5) !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

/* ==================== ツールチップの高度化 ==================== */
.tooltip-stat {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.tooltip-stat .stat-values {
    display: flex;
    gap: 8px;
    align-items: center;
}

.diff-up {
    color: #4ade80;
    font-size: 0.85em;
    font-weight: bold;
}

.diff-down {
    color: #f87171;
    font-size: 0.85em;
    font-weight: bold;
}

.diff-eq {
    color: #9ca3af;
    font-size: 0.85em;
}

/* ==================== コンテクストアクションバー ==================== */
.context-action-bar {
    position: fixed;
    bottom: 140px;
    left: 0;   /* 25pxから0へ調整（Discordボタンに揃える） */
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 12px;
    z-index: 9000;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.context-action-bar.hidden {
    display: none !important;
}

/* 格納時のスタイル */
.context-action-bar.collapsed {
    gap: 8px;
}

.context-action-bar .action-btn {
    pointer-events: auto;
    border-radius: 25px !important;
    padding: 12px 24px !important;
    font-size: 1rem !important;
    font-weight: bold;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    border-image: none !important;
    min-width: 160px;
    text-align: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    white-space: nowrap;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s;
}

/* 格納時：ボタンを円形にし、文字を消す */
.context-action-bar.collapsed .action-btn {
    min-width: 50px !important;
    width: 50px !important;
    height: 50px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    font-size: 0 !important; /* テキスト隠蔽 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 1番上（下から積むためDOM的には最後の要素）を赤の透過 */
.context-action-bar .action-btn:nth-last-child(1) {
    background-color: rgba(220, 38, 38, 0.25) !important;
    border-color: rgba(252, 165, 165, 0.4) !important;
}
.context-action-bar .action-btn:nth-last-child(1):hover {
    background-color: rgba(220, 38, 38, 0.4) !important;
}

/* 2番目を青の透過 */
.context-action-bar .action-btn:nth-last-child(2) {
    background-color: rgba(37, 99, 235, 0.25) !important;
    border-color: rgba(147, 197, 253, 0.4) !important;
}
.context-action-bar .action-btn:nth-last-child(2):hover {
    background-color: rgba(37, 99, 235, 0.4) !important;
}

/* 3番目を緑の透過 */
.context-action-bar .action-btn:nth-last-child(3) {
    background-color: rgba(22, 163, 74, 0.25) !important;
    border-color: rgba(134, 239, 172, 0.4) !important;
}
.context-action-bar .action-btn:nth-last-child(3):hover {
    background-color: rgba(22, 163, 74, 0.4) !important;
}

/* トグルボタンのスタイル */
.toolbar-toggle-container {
    position: fixed;
    bottom: 90px;
    left: 0;   /* 25pxから0へ調整（Discordボタンに揃える） */
    z-index: 9001;
    pointer-events: auto;
}

.toolbar-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    backdrop-filter: blur(4px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.toolbar-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

@keyframes bounceIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==================== 図鑑カードUI化 ==================== */
#monster-book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 15px;
    padding: 10px;
}

.monster-card {
    background: rgba(255, 255, 255, 0.05); /* デフォルト */
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* レアリティ／属性別ボーダー */
.monster-card.type-boss {
    background: linear-gradient(135deg, rgba(255, 215, 64, 0.1) 0%, rgba(30, 30, 30, 0.8) 100%);
    border: 1px solid rgba(255, 215, 64, 0.4);
    box-shadow: 0 0 10px rgba(255, 215, 64, 0.1);
}

.monster-card.type-mob {
    background: linear-gradient(135deg, rgba(150, 150, 150, 0.1) 0%, rgba(30, 30, 30, 0.6) 100%);
}

.monster-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
}

.monster-card.type-boss:hover {
    background: linear-gradient(135deg, rgba(255, 215, 64, 0.2) 0%, rgba(30, 30, 30, 0.9) 100%);
    box-shadow: 0 0 15px rgba(255, 215, 64, 0.3);
}

.monster-card.unknown {
    cursor: default;
    opacity: 0.7;
}

.monster-card.unknown:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.05);
}

/* Flipアニメーション */
.monster-card.flip-in {
    animation: cardFlip 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cardFlip {
    0% { transform: perspective(400px) rotateY(90deg); opacity: 0; }
    40% { transform: perspective(400px) rotateY(-10deg); }
    70% { transform: perspective(400px) rotateY(10deg); }
    100% { transform: perspective(400px) rotateY(0deg); opacity: 1; }
}

.card-image-container {
    width: 64px;
    height: 64px;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.monster-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.silhouette {
    filter: brightness(0) invert(0.2);
    opacity: 0.5;
}

.card-info {
    width: 100%;
}

.card-header {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-count {
    font-size: 0.8em;
    color: var(--sub-text-color);
}

.card-buff {
    font-size: 0.75em;
    color: #ffd740;
    margin-top: 4px;
    background: rgba(255, 215, 64, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
}

/* 新規発見モーダル */
#modal-monster-discovery .modal-content {
    background: linear-gradient(to bottom, rgba(20, 20, 40, 0.95), rgba(0, 0, 0, 0.98));
    border: 2px solid #ffd740;
    box-shadow: 0 0 40px rgba(255, 215, 64, 0.3);
    text-align: center;
    position: relative;
    padding-top: 40px;
}

.discovery-badge {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #ff007f, #ffaa00);
    padding: 5px 30px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(255, 170, 0, 0.5);
    animation: bounceIn 0.5s ease;
    white-space: nowrap;
}

/* ==================== モーダルパンくずリスト (Modal Breadcrumb) ==================== */
.global-breadcrumb {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    background: rgba(15, 20, 30, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    padding: 0 15px;
    color: #a0aec0;
    font-size: 0.95rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-breadcrumb:hover {
    color: #e2e8f0;
    background: rgba(20, 25, 35, 0.98);
}

.global-breadcrumb .bc-sep {
    margin: 0 8px;
    font-size: 0.8em;
}

.global-breadcrumb.hidden {
    display: none !important;
}

/* スマホ表示時のパンくずリスト連動マージン */
@media (max-width: 640px) {
    body.has-modal-breadcrumb .modal-content.fullscreen-sheet {
        padding-top: 50px !important; /* パンくずの分のトップ余白を確保 */
    }
    
    /* スワイプダウンできることを示すヒントバーを上部に追加 */
    body.has-modal-breadcrumb .modal-content.fullscreen-sheet::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 5px;
        z-index: 10;
        pointer-events: none;
    }
}

/* ==================== ペットアバターウィジェット ==================== */
.pet-widget {
    position: fixed;
    bottom: 160px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
}

.pet-widget.hidden {
    display: none !important;
}

.pet-widget-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}

.pet-widget-bubble {
    position: absolute;
    bottom: 60px;
    right: -10px; /* ウィジェットより少し右にはみ出させる（画面端マージン確保） */
    max-width: min(250px, 80vw);
    width: max-content;
    background: white;
    color: black;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    white-space: pre-wrap; /* テキストの折り返しを許可 */
    word-break: break-word; /* 英語等の長い単語も必要に応じて折り返す */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 101;
    line-height: 1.4;
}

.pet-widget-bubble.hidden {
    display: none !important;
}

.pet-widget-bubble::after {
    content: '';
    position: absolute;
    bottom: -5px;
    right: 35px; /* 親の右端からのオフセット。ペットアイコンの中央あたりを指す */
    border-width: 5px 5px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

/* Animations */
.anim-float {
    animation: petFloat 3s ease-in-out infinite;
}

.anim-bounce {
    animation: petBounce 0.5s ease;
}

.anim-shake {
    animation: petShake 0.4s ease;
}

.anim-spin {
    animation: petSpin 1s ease;
}

@keyframes petFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes petBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes petShake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes petSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* =========================================
   UI Deluxe Features (Image Decorations)
   ========================================= */

/* Modal Header Divider */
.modal-header, .section-title {
    border-bottom: none !important;
    position: relative;
    padding-bottom: 20px !important;
    margin-bottom: 10px;
}

.modal-header::after, .section-title::after {
    content: '';
    display: block;
    position: absolute;
    bottom: 0;
    left: 5%;
    width: 90%;
    height: 12px;
    background-image: url('../images/UI/ui_divider.webp');
    background-size: contain;
    background-repeat: repeat-x;
    background-position: center;
    opacity: 0.8;
}

/* Item & Monster Icon Frames */
.inventory-item img, 
.shop-item img, 
.fishing-card img, 
.monster-image, 
.equipment-slot img,
#pet-detail-icon {
    box-sizing: border-box;
    padding: 8px; /* Give space */
    /* background-image: url('../images/UI/ui_icon_frame.webp'); Removed ui_icon_frame */
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
}

/* ==================== タイトルロゴ動的縮小 ==================== */
.title-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 0.5rem;
    animation: shrinkContainer 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) 1.5s forwards;
}

.title-logo-img-dynamic {
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(156, 39, 176, 0.6));
    animation: shrinkLogo 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) 1.5s forwards;
    max-height: 200px;
}

@media (min-width: 768px) {
    .title-logo-img-dynamic {
        max-height: 240px;
        animation: shrinkLogoMd 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) 1.5s forwards;
    }
}

@keyframes shrinkContainer {
    from {
        padding-top: 1rem;
        padding-bottom: 1rem;
        margin-bottom: 0.5rem;
    }
    to {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
        margin-bottom: 0px;
    }
}

@keyframes shrinkLogo {
    from { max-height: 200px; }
    to { max-height: 60px; }
}

@keyframes shrinkLogoMd {
    from { max-height: 240px; }
    to { max-height: 70px; }
}

/* =========================================
   フェーズ13: ダンジョン探索画面のレイアウト最適化
   ========================================= */

/* タウン画面等でレイアウト干渉させないためのデフォルト設定 */
.dungeon-col-left,
.dungeon-col-right {
    display: contents;
}

/* PC向け (広画面): 2カラムグリッドレイアウト（ラッパー利用） */
@media (min-width: 800px) {
    /* PCの全幅を生かすための拡張 */
    body.dungeon-active .app-container {
        max-width: 1200px;
    }

    body.dungeon-active .main-content {
        display: grid;
        grid-template-columns: 340px minmax(0, 1fr);
        gap: 15px;
        align-items: start; /* Grid Itemの高さを中身に合わせる。これによりStickyが移動可能な余白が生まれる */
        max-width: 1200px;
        margin: 0 auto;
    }

    body.dungeon-active .dungeon-col-left {
        display: flex;
        flex-direction: column;
        gap: 15px;
        position: sticky;
        top: 20px; /* 左カラム全体をまとめたままスクロールに追従させる */
    }

    body.dungeon-active .dungeon-col-right {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    /* 左カラム上部 */
    body.dungeon-active #status-panel {
        margin-bottom: 0;
    }

    /* 左上のペット名の改行を防ぎ、中央揃えで2段に再構成 */
    body.dungeon-active #status-panel > div:first-child {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    body.dungeon-active #pet-name {
        width: 100%;
        /* レイアウト変更: JS側でflex-colを用いてアイコンと名前を2行に分け、
           文字数に応じたサイズ縮小と省略を動的付与するようにしたため、ここの固定省略指定は削除 */
    }

    /* 左カラムが狭いため、ステータスは4列ではなく2列にする */
    body.dungeon-active #status-panel .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* 左カラム下部のアクションボタン */
    body.dungeon-active #dungeon-controls-area {
        margin-bottom: 0;
        /* 左カラム自体がStickyになったため、個別の子要素のStickyは解除 */
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    body.dungeon-active #dungeon-controls-area .action-btn {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    /* 右カラム要素 (ゲーム画面・ログ領域) */
    body.dungeon-active #game-screen,
    body.dungeon-active .log-panel {
        margin-bottom: 0;
        width: auto;
    }
}

/* スマホ向け (狭画面): スクロール対策と情報圧縮 */
@media (max-width: 799px) {
    /* アクションボタンを画面下部に追従（Sticky化してログ閲覧を容易にする） */
    body.dungeon-active #dungeon-controls-area {
        position: sticky;
        bottom: 15px;
        z-index: 50;
        padding: 5px;
        background: rgba(0, 0, 0, 0.4); /* 背景と混ざらないよう少し暗くする */
        border-radius: 10px;
        backdrop-filter: blur(4px);
        margin-bottom: 0; /* マージンを詰める */
    }
    
    /* ステータスパネルの余白を削ってファーストビューに余裕を持たせる */
    body.dungeon-active #status-panel.glass-panel {
        padding: 24px 15px 15px; /* 元の装飾枠のため、上部は24px程度必要 */
        margin-bottom: 10px;
    }
    
    body.dungeon-active .stat-item {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
}

/* =========================================
   Asset Theme (Cute) - Detailed Overrides
   ========================================= */

/* --- Common Buttons & specific IDs --- */
.asset-theme-cute #btn-pet-expedition,
.asset-theme-cute #btn-train-fp,
.asset-theme-cute #btn-train-pt,
.asset-theme-cute #btn-max-train,
.asset-theme-cute #btn-open-transcendence,
.asset-theme-cute #btn-cache-clear,
.asset-theme-cute #btn-sell-selected,
.asset-theme-cute #btn-use-potion {
    border-image-source: url('../images/UI(cute)/ui_btn_primary_n.webp') !important;
    filter: none !important; /* 青色化フィルタを強制解除 */
}

/* Warning color buttons base asset change */
.asset-theme-cute .action-btn.warning {
    border-image-source: url('../images/UI(cute)/ui_btn_secondary_n.webp') !important;
}

/* --- Item Cards & Slots (Inventory, Transcendence, blacksmith) --- */
.asset-theme-cute .item-card,
.asset-theme-cute .trans-protection-item,
.asset-theme-cute .syn-slot,
.asset-theme-cute .inventory-item-card, /* Additional selector if present */
.asset-theme-cute .slot-item-card {
    border-image: url('../images/UI(cute)/ui_window_frame.webp') 150 stretch !important;
    background: rgba(255, 182, 193, 0.1) !important; /* Soft Pink tint */
    border-radius: 0 !important; /* Spite-based border needs square corners */
}

/* Grid layout items padding adjustment for sprite frame */
.asset-theme-cute .inventory-grid > div,
.asset-theme-cute .item-grid-small > div {
    padding: 8px !important;
}

/* --- Mutation Ability Button (Special) --- */
.asset-theme-cute .btn-mutation {
    background-image: url('../images/UI(cute)/ui_btn_primary_n.webp') !important;
    filter: none !important; /* Remove the blue hue-rotate filter */
    background-color: transparent !important;
    border: none !important;
    background-size: 100% 100% !important; /* One-phase button image usually */
    background-position: center !important;
}

.asset-theme-cute .btn-mutation:hover:not(:disabled) {
    filter: brightness(1.2) !important;
    transform: translateY(-2px);
}

/* --- Additional Elements identified --- */
.asset-theme-cute .glass-panel.modal-content {
    border-image: url('../images/UI(cute)/ui_window_frame.webp') 150 stretch !important;
}

/* ==================== ペットのマイルーム ==================== */

/* ビジュアルエリア（背景＋ペット徘徊） */
#myroom-view-area {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 8px;
    min-height: 200px;
    background: #1a1a2e;
}

/* ペットアイコン（徘徊用） */
#myroom-pet {
    position: absolute;
    width: 48px;
    height: 48px;
    cursor: pointer;
    transition: left 2s ease-in-out, top 2s ease-in-out;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

#myroom-pet:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 4px 8px rgba(255, 200, 50, 0.6));
}

#myroom-pet:active {
    transform: scale(0.95);
}

/* 設備カード */
.myroom-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.myroom-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* リンクバナー */
.myroom-banner {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 10px;
    background: rgba(0, 80, 120, 0.6);
    border-radius: 6px;
    color: #8cf;
    font-size: 0.75rem;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.myroom-banner:hover {
    background: rgba(0, 120, 180, 0.8);
    color: #bef;
}

/* QOLパーティクル演出 */
.qol-particle {
    position: absolute;
    color: #ffd700;
    font-weight: bold;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 20;
    animation: qolFloat 1s ease-out forwards;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
}

@keyframes qolFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1.3);
    }
}

/* ペットの吹き出しセリフ */
.myroom-pet-bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    max-width: 200px;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    z-index: 15;
    pointer-events: none;
    transform: translateX(-50%) translateY(-100%);
    opacity: 1;
    transition: opacity 0.5s ease;
    line-height: 1.4;
}

/* 吹き出しの三角矢印 */
.myroom-pet-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.95) transparent transparent transparent;
}

/* ============================================================
   邪神界ゲテモニアム — フルスクリーンモーダルUI
   ============================================================ */

/* フルスクリーンモーダル */
.gehemonium-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important; /* Fallback */
    height: 100dvh !important; /* iOS Safari等のアドレスバー考慮対応 */
    z-index: 2500 !important;
    background: linear-gradient(135deg, #0d001a 0%, #1a0028 30%, #2d0035 60%, #140020 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
}

.gehemonium-fullscreen.hidden {
    display: none !important;
}

.gehemonium-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 50px 70px 20px 70px; /* 上部(メニュー用), 左右(フロート用), 下部 余白 */
    box-sizing: border-box;
    overflow: hidden;
}

/* ヘッダー */
.gehemonium-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(90deg, rgba(120, 0, 80, 0.6), rgba(60, 0, 120, 0.4));
    border: 1px solid rgba(200, 100, 255, 0.3);
    border-radius: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.gehemonium-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e0b0ff;
    text-shadow: 0 0 10px rgba(200, 100, 255, 0.5);
}

.gehemonium-floor {
    font-size: 1rem;
    color: #ff80ab;
    margin-left: 8px;
}

.gehemonium-best {
    font-size: 0.85rem;
    color: #ffd740;
    opacity: 0.8;
}

/* Canvas演出エリア */
.gehemonium-canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(150, 50, 200, 0.3);
    background: #0a0014;
}

#gehemonium-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* モンスター画像 */
.gehemonium-monster-img {
    position: absolute;
    bottom: calc(35% + 13px); /* ログの最大高さ(35%) + ログのbottom(8px) + マージン(5px) */
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-height: calc(65% - 23px); /* 画面上部にはみ出さないように制限 */
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(200, 50, 100, 0.6));
    transition: opacity 0.5s ease;
    z-index: 10;
}

.gehemonium-monster-img.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ゲテモニアム アニメーション定義 */
@keyframes gmFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1.0); }
}

@keyframes gmBossShake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25%      { transform: translate(-48%, -52%) rotate(-1deg); }
    50%      { transform: translate(-52%, -48%) rotate(1deg); }
    75%      { transform: translate(-50%, -52%) rotate(-0.5deg); }
}

@keyframes gmShakeScreen {
    0%, 100% { transform: translateX(0); }
    10%      { transform: translateX(-6px); }
    20%      { transform: translateX(6px); }
    30%      { transform: translateX(-4px); }
    40%      { transform: translateX(4px); }
    50%      { transform: translateX(-2px); }
    60%      { transform: translateX(2px); }
}

@keyframes gmFlashGold {
    0%   { background: rgba(255, 215, 0, 0); }
    30%  { background: rgba(255, 215, 0, 0.3); }
    100% { background: rgba(255, 215, 0, 0); }
}

@keyframes gmFlashRainbow {
    0%   { background: rgba(255, 0, 100, 0); }
    15%  { background: rgba(255, 0, 100, 0.25); }
    30%  { background: rgba(0, 200, 255, 0.25); }
    50%  { background: rgba(100, 255, 100, 0.25); }
    70%  { background: rgba(200, 100, 255, 0.25); }
    85%  { background: rgba(255, 200, 0, 0.25); }
    100% { background: rgba(255, 0, 100, 0); }
}

.gehemonium-monster-img.boss-shake {
    animation: gmBossShake 0.6s ease infinite;
}

/* 戦闘ログオーバーレイ */
.gehemonium-battle-log {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    max-height: 35%;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.78rem;
    line-height: 1.5;
    color: #ddd;
    z-index: 5;
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 100, 255, 0.3) transparent;
}

.gehemonium-battle-log::-webkit-scrollbar {
    width: 4px;
}

.gehemonium-battle-log::-webkit-scrollbar-thumb {
    background: rgba(200, 100, 255, 0.3);
    border-radius: 4px;
}

.gehemonium-battle-log .log-entry {
    margin-bottom: 2px;
    padding: 1px 0;
}

/* ステータスバー */
.gehemonium-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(30, 0, 50, 0.8);
    border: 1px solid rgba(150, 50, 200, 0.25);
    border-radius: 6px;
    margin-top: 6px;
    flex-shrink: 0;
}

.gehemonium-hp-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.gehemonium-hp-label {
    font-size: 0.85rem;
    color: #ff6b6b;
    font-weight: bold;
    flex-shrink: 0;
}

.gehemonium-hp-bar-outer {
    flex: 1;
    height: 16px;
    background: rgba(60, 0, 0, 0.5);
    border-radius: 8px;
    border: 1px solid rgba(255, 100, 100, 0.3);
    overflow: hidden;
}

.gehemonium-hp-bar-inner {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6b6b, #ff8888);
    border-radius: 8px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 100, 100, 0.4);
}

.gehemonium-hp-text {
    font-size: 0.75rem;
    color: #ffaaaa;
    flex-shrink: 0;
    min-width: 80px;
    text-align: right;
}

.gehemonium-potion-section {
    font-size: 0.85rem;
    color: #80e0a0;
    flex-shrink: 0;
    margin-left: 12px;
}

/* 探索ログ */
.gehemonium-log {
    max-height: 80px;
    overflow-y: auto;
    padding: 6px 10px;
    background: rgba(10, 0, 20, 0.6);
    border-radius: 6px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: #bfa0e0;
    line-height: 1.4;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 80, 200, 0.3) transparent;
}

.gehemonium-log::-webkit-scrollbar {
    width: 3px;
}

.gehemonium-log::-webkit-scrollbar-thumb {
    background: rgba(150, 80, 200, 0.3);
    border-radius: 3px;
}

/* 操作ボタン */
.gehemonium-controls {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    justify-content: center;
    flex-shrink: 0;
}

.gehemonium-btn {
    flex: 1;
    max-width: 200px;
    font-size: 0.95rem;
}

/* リザルトパネル */
.gehemonium-result {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: linear-gradient(135deg, rgba(20, 0, 40, 0.95), rgba(40, 0, 60, 0.95));
    border: 2px solid rgba(200, 100, 255, 0.5);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    z-index: 20;
    box-shadow: 0 0 40px rgba(150, 50, 200, 0.3);
}

.gehemonium-result.hidden {
    display: none !important;
}

.gehemonium-result-title {
    font-size: 1.3rem;
    color: #e0b0ff;
    margin-bottom: 16px;
    text-shadow: 0 0 15px rgba(200, 100, 255, 0.5);
}

.gehemonium-result-stats {
    text-align: left;
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.8;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.gehemonium-result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* カットインオーバーレイ */
.gehemonium-cutin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2600;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gehemonium-cutin-overlay.hidden {
    display: none !important;
}

.gehemonium-cutin-overlay .cutin-text {
    font-size: 2rem;
    font-weight: bold;
    color: #ff4040;
    text-shadow: 0 0 20px rgba(255, 0, 0, 0.8), 0 0 40px rgba(200, 0, 0, 0.4);
    animation: gmCutinPulse 0.8s ease;
}

/* アニメーション */
@keyframes gmBossShake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-51%, -49%) rotate(-0.5deg); }
    75% { transform: translate(-49%, -51%) rotate(0.5deg); }
}

@keyframes gmShakeScreen {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px); }
    20% { transform: translateX(8px); }
    30% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

@keyframes gmCutinPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes gmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gmFlashGold {
    0% { background: rgba(255, 215, 0, 0.4); }
    100% { background: transparent; }
}

@keyframes gmFlashRainbow {
    0% { background: rgba(255, 0, 0, 0.3); }
    16% { background: rgba(255, 165, 0, 0.3); }
    33% { background: rgba(255, 255, 0, 0.3); }
    50% { background: rgba(0, 255, 0, 0.3); }
    66% { background: rgba(0, 0, 255, 0.3); }
    83% { background: rgba(128, 0, 128, 0.3); }
    100% { background: transparent; }
}

/* 高速進行モード時のログ非表示 */
.gehemonium-minimal .gehemonium-battle-log {
    display: none !important;
}

/* レスポンシブ */
@media (max-width: 640px) {
    .gehemonium-container {
        padding: 40px 10px 85px 10px; /* 上部40px(ブラウザの戻る挙動等回避), 左右10px, 下部85px(各ボタンと重ならないように余裕を持たせる) */
    }
    .gehemonium-header {
        padding: 6px 10px;
        flex-wrap: wrap;
    }
    .gehemonium-title {
        font-size: 0.95rem;
    }
    .gehemonium-hp-text {
        display: none;
    }
    .gehemonium-btn {
        font-size: 0.85rem;
        padding: 8px 4px;
    }
}

@media (max-width: 500px) {
    .gehemonium-container {
        padding: 30px 8px 75px 8px; /* 少し狭い余白にしてコンテンツ領域を確保 */
    }
    .gehemonium-title {
        font-size: 0.85rem;
    }
    .gehemonium-floor {
        font-size: 0.85rem;
    }
    .gehemonium-monster-img {
        max-height: calc(55% - 20px); /* 画面の高さが低い端末向けにモンスター画像を小さくする設定 */
        bottom: calc(40% + 10px);
    }
    .gehemonium-battle-log {
        max-height: 40%;
        font-size: 0.72rem;
    }
    .gehemonium-btn {
        font-size: 0.75rem;
        padding: 6px 2px;
    }
    .gehemonium-hp-label {
        font-size: 0.75rem;
    }
}

/* ============================================================
   アーティファクト蒐集UI
   ============================================================ */

.artifact-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(30, 0, 50, 0.6);
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #ddd;
    border: 1px solid rgba(150, 50, 200, 0.25);
}

.artifact-summary strong {
    color: #e0b0ff;
}

.artifact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 80, 200, 0.3) transparent;
}

.artifact-grid::-webkit-scrollbar {
    width: 4px;
}

.artifact-grid::-webkit-scrollbar-thumb {
    background: rgba(150, 80, 200, 0.3);
    border-radius: 4px;
}

.artifact-card {
    background: rgba(20, 0, 40, 0.7);
    border: 1px solid rgba(100, 50, 150, 0.4);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

.artifact-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(150, 50, 200, 0.3);
}

.artifact-card.artifact-locked {
    opacity: 0.35;
    filter: grayscale(0.8);
}

.artifact-card.artifact-superrare {
    border-color: rgba(255, 150, 255, 0.6);
    background: linear-gradient(135deg, rgba(80, 0, 80, 0.5), rgba(40, 0, 60, 0.7));
}

.artifact-card.artifact-rare {
    border-color: rgba(255, 215, 0, 0.5);
    background: linear-gradient(135deg, rgba(60, 40, 0, 0.5), rgba(30, 20, 0, 0.7));
}

.artifact-card.artifact-normal {
    border-color: rgba(150, 150, 150, 0.3);
}

.artifact-card-icon {
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.artifact-card-name {
    font-size: 0.7rem;
    color: #ddd;
    line-height: 1.3;
    min-height: 2em;
    word-break: break-all;
}

.artifact-card-stats {
    font-size: 0.6rem;
    color: #aaa;
    margin-top: 2px;
}

.artifact-card-count {
    font-size: 0.7rem;
    color: #80e0a0;
    margin-top: 3px;
    font-weight: bold;
}