* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Calibri, sans-serif;
    user-select: none; /* Prevent text selection to look more like an app */
}

body {
    background-color: #fff;
    color: #333;
    font-size: 14px;
    overflow: hidden;
}

#excel-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Ribbon Menu */
.ribbon {
    background-color: #f3f2f1;
    border-bottom: 1px solid #d2d0ce;
}

.ribbon-top {
    display: flex;
    justify-content: space-between;
    background-color: #217346;
    color: white;
    padding: 4px 10px;
    font-size: 12px;
}

.window-controls span {
    margin-left: 15px;
    cursor: pointer;
}

.menu-tabs {
    display: flex;
    padding-top: 5px;
    background-color: #f3f2f1;
}

.menu-tab {
    padding: 4px 15px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
}

.menu-tab.active {
    background-color: #fff;
    border-color: #d2d0ce;
    color: #217346;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
    z-index: 1;
}

.toolbar {
    background-color: #fff;
    padding: 8px 10px;
    display: flex;
    gap: 15px;
    border-bottom: 1px solid #e1dfdd;
    align-items: center;
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 5px;
    border-right: 1px solid #e1dfdd;
    padding-right: 15px;
}

.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 2px;
}

.tool-btn:hover {
    background-color: #f3f2f1;
    border-color: #c8c6c4;
}

/* Formula Bar */
.formula-bar {
    display: flex;
    align-items: center;
    padding: 4px 10px;
    background-color: #fff;
    border-bottom: 1px solid #d2d0ce;
}

.name-box {
    width: 100px;
    border: 1px solid #c8c6c4;
    padding: 2px 5px;
    text-align: center;
    font-size: 12px;
}

.fx-icon {
    color: #666;
    font-style: italic;
    font-weight: bold;
    margin: 0 10px;
}

.formula-input {
    flex-grow: 1;
    border: 1px solid #c8c6c4;
    padding: 2px 5px;
    outline: none;
    font-size: 13px;
}

/* Spreadsheet Area */
.spreadsheet-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.spreadsheet-body {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.corner-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 25px;
    background-color: #f3f2f1;
    border-right: 1px solid #c8c6c4;
    border-bottom: 1px solid #c8c6c4;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: #a19f9d;
}

.column-headers {
    display: flex;
    margin-left: 30px;
    background-color: #f3f2f1;
    border-bottom: 1px solid #c8c6c4;
    overflow: hidden;
}

.col-header {
    width: 80px; /* Default cell width */
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px solid #c8c6c4;
    font-size: 12px;
    color: #333;
    flex-shrink: 0;
}

.grid-content {
    display: flex;
    flex-grow: 1;
    overflow: auto;
    position: relative;
}

.row-headers {
    display: flex;
    flex-direction: column;
    width: 30px;
    background-color: #f3f2f1;
    border-right: 1px solid #c8c6c4;
    overflow: hidden;
    flex-shrink: 0;
}

.row-header {
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #c8c6c4;
    font-size: 12px;
    color: #333;
}

/* Game Grids positioned like Excel cells */
.sheet-view {
    position: absolute;
    top: 0;
    left: 0;
    /* We align the games inside the dummy grid by just rendering them as grids */
}

.game-grid {
    display: grid;
    background-color: #fff;
    border-top: 1px solid #e1dfdd;
    border-left: 1px solid #e1dfdd;
}

/* Base cell styling to look like Excel */
.excel-cell {
    width: 80px;
    height: 25px;
    border-right: 1px solid #e1dfdd;
    border-bottom: 1px solid #e1dfdd;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Numbers right-aligned */
    padding: 0 4px;
    font-size: 14px;
    position: relative;
    cursor: cell;
}

.excel-cell.selected {
    border: 2px solid #217346;
    z-index: 10;
}

/* -------------------
   SUDOKU STYLES
   ------------------- */
.sudoku {
    grid-template-columns: repeat(9, 80px);
    grid-template-rows: repeat(9, 25px);
}

.sudoku .excel-cell {
    justify-content: center; /* Center Sudoku numbers */
    font-weight: normal;
    color: #000;
}

.sudoku .excel-cell.fixed {
    color: #333; /* Darker for fixed numbers */
}

.sudoku .excel-cell.user-input {
    color: #0052cc; /* Blue for user input */
    font-weight: bold;
}

/* Thicker borders for 3x3 blocks */
.sudoku .excel-cell:nth-child(3n) { border-right: 2px solid #a19f9d; }
.sudoku .excel-cell:nth-child(9n) { border-right: 1px solid #e1dfdd; } /* reset last col */
.sudoku .excel-cell:nth-child(n+19):nth-child(-n+27),
.sudoku .excel-cell:nth-child(n+46):nth-child(-n+54),
.sudoku .excel-cell:nth-child(n+73):nth-child(-n+81) {
    border-bottom: 2px solid #a19f9d;
}

/* -------------------
   2048 STYLES
   ------------------- */
.g2048 {
    grid-template-columns: repeat(4, 80px);
    grid-template-rows: repeat(4, 25px);
}

.g2048 .excel-cell {
    justify-content: right; /* Numbers right-aligned like money */
    font-weight: normal;
    transition: all 0.1s;
}

/* 2048 Colors disguised as financial data */
.val-2 { color: #333; }
.val-4 { color: #333; font-weight: bold; }
.val-8 { background-color: #fce4d6; } /* Light orange */
.val-16 { background-color: #f8cbad; }
.val-32 { background-color: #f4b084; color: white;}
.val-64 { background-color: #ed7d31; color: white; font-weight: bold;}
.val-128 { background-color: #fff2cc; } /* Light yellow */
.val-256 { background-color: #ffe699; }
.val-512 { background-color: #ffd966; }
.val-1024 { background-color: #e2efda; } /* Light green */
.val-2048 { background-color: #c6e0b4; font-weight: bold;}


/* Bottom Tabs */
.sheet-tabs {
    display: flex;
    flex-direction: column;
    background-color: #f3f2f1;
    border-top: 1px solid #c8c6c4;
}

.tabs-row {
    display: flex;
    align-items: center;
}

.tab-controls {
    padding: 0 10px;
    color: #666;
    font-size: 10px;
    cursor: pointer;
}

.tabs {
    display: flex;
    overflow-x: auto;
}

.tab {
    padding: 5px 20px;
    font-size: 12px;
    cursor: pointer;
    border-right: 1px solid #c8c6c4;
    background-color: #e1dfdd;
    color: #333;
}

.tab.active {
    background-color: #fff;
    color: #217346;
    font-weight: 500;
    border-bottom: 2px solid #217346;
}

.status-bar {
    display: flex;
    padding: 2px 10px;
    font-size: 11px;
    color: #333;
    background-color: #f3f2f1;
    border-top: 1px solid #e1dfdd;
    align-items: center;
}

/* Boss Key Mode (Safe Mode) */
.safe-mode .game-grid {
    display: none !important;
}
.safe-mode .dummy-grid {
    display: block !important;
}
.safe-mode .sheet-view { display: none !important; }

/* In normal mode, dummy grid is a background */
.dummy-grid {
    position: absolute;
    top: 0;
    left: 0; /* Offset removed since row-headers are outside */
    z-index: -1;
    width: 2000px;
    height: 1000px;
    background-image: 
        linear-gradient(to right, #e1dfdd 1px, transparent 1px),
        linear-gradient(to bottom, #e1dfdd 1px, transparent 1px);
    background-size: 80px 25px; /* Matches col/row size */
}

/* Fake Dashboard & Theme Toggle */
.window-controls { display: flex; align-items: center; }
.theme-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #0b5028;
    color: #fff;
    text-align: center;
    line-height: 20px;
    font-size: 10px;
    cursor: pointer;
    margin-left: 15px;
    user-select: none;
    border: 1px solid #114a29;
}
.sheet-layout {
    display: flex;
    gap: 80px; /* Aligns to exactly 1 column width */
    padding: 50px 80px; /* Aligns to exactly 2 rows down, 1 column right */
}
.fake-dashboard {
    display: flex;
    flex-direction: column;
    gap: 25px; /* Aligns to exactly 1 row height */
    width: 320px; /* Aligns to exactly 4 columns (80px * 4) */
    font-family: 'Segoe UI', sans-serif;
}
.fake-table {
    display: grid;
    grid-template-columns: 240px 80px; /* 3 cols + 1 col = 4 cols (320px) */
    background-color: transparent;
    font-size: 13px;
    border-top: 1px solid #e1dfdd;
    border-left: 1px solid #e1dfdd;
}
.fake-table-header {
    background-color: #dbe5f1; /* Pivot table blue */
    padding: 0 4px;
    font-weight: bold;
    grid-column: span 2;
    height: 25px;
    display: flex;
    align-items: center;
    border-right: 1px solid #e1dfdd;
    border-bottom: 1px solid #e1dfdd;
    color: #333;
}
.fake-table-cell {
    height: 25px;
    display: flex;
    align-items: center;
    padding: 0 4px;
    background-color: #fff;
    border-right: 1px solid #e1dfdd;
    border-bottom: 1px solid #e1dfdd;
    color: #333;
}
.fake-table-cell.label {
    background-color: #f2f2f2;
}
.fake-table-cell.value {
    justify-content: flex-end; /* Right-aligned numbers/values like Excel */
}
.fake-table-cell.total {
    font-weight: bold;
    background-color: #dbe5f1;
    border-top: 1px solid #95b3d7;
}

.fake-chart {
    background-color: #fff;
    border: 1px solid #e1dfdd;
    padding: 15px;
    /* Chart doesn't need to be cell-aligned, floating is fine */
}
.chart-title {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 15px;
}
.chart-bars {
    display: flex;
    justify-content: space-around;
    height: 120px;
    align-items: flex-end;
}
.bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    height: 100%;
    justify-content: flex-end;
}
.bar {
    width: 30px;
    background-color: #5b9bd5;
    border-radius: 2px 2px 0 0;
    transition: height 0.3s ease;
}
#fake-score-bar {
    background-color: #ed7d31;
}

/* Excel Data Validation Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: transparent; /* No dimming to look like a real OS window */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.excel-modal {
    background-color: #fff;
    border: 1px solid #aaa;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
    width: 350px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
}
.modal-header {
    background-color: #fff;
    padding: 5px 10px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #000;
}
.modal-close {
    cursor: pointer;
    font-size: 10px;
    padding: 2px 5px;
}
.modal-close:hover { background-color: #e81123; color: white; }
.modal-content {
    display: flex;
    padding: 20px;
    gap: 15px;
    align-items: center;
}
.modal-icon {
    font-size: 32px;
}
.modal-text {
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}
.modal-buttons {
    background-color: #f0f0f0;
    padding: 10px 15px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #dfdfdf;
}
.modal-btn {
    padding: 4px 15px;
    font-size: 12px;
    background-color: #e1e1e1;
    border: 1px solid #adadad;
    cursor: pointer;
}
.modal-btn:hover { background-color: #e5f1fb; border-color: #0078d7; }

/* Dark Mode Overrides */
body.dark-mode {
    background-color: #1e1e1e;
    color: #d4d4d4;
}
body.dark-mode .ribbon, body.dark-mode .menu-tabs, body.dark-mode .toolbar, body.dark-mode .formula-bar,
body.dark-mode .column-headers, body.dark-mode .row-headers, body.dark-mode .corner-header,
body.dark-mode .sheet-tabs, body.dark-mode .status-bar, body.dark-mode .game-grid {
    background-color: #2d2d2d;
    border-color: #444;
    color: #d4d4d4;
}
body.dark-mode .ribbon-top {
    background-color: #114a29;
}
body.dark-mode .menu-tab.active {
    background-color: #1e1e1e;
    color: #4CAF50;
    border-color: #444;
}
body.dark-mode .excel-cell, body.dark-mode .col-header, body.dark-mode .row-header {
    border-color: #444;
    color: #d4d4d4;
}
body.dark-mode .sudoku .excel-cell { color: #d4d4d4; }
body.dark-mode .sudoku .excel-cell.user-input { color: #64b5f6; }
body.dark-mode .tab {
    background-color: #333;
    color: #aaa;
    border-color: #444;
}
body.dark-mode .tab.active {
    background-color: #1e1e1e;
    color: #4CAF50;
}
body.dark-mode .dummy-grid {
    background-image: 
        linear-gradient(to right, #444 1px, transparent 1px),
        linear-gradient(to bottom, #444 1px, transparent 1px);
}
body.dark-mode .fake-table, body.dark-mode .fake-chart { background-color: transparent; border-color: #444; }
body.dark-mode .fake-table-header { background-color: #1a365d; border-color: #444; color: #d4d4d4; }
body.dark-mode .fake-table-cell { border-color: #444; background-color: #2d2d2d; color: #d4d4d4; }
body.dark-mode .fake-table-cell.label { background-color: #333; }
body.dark-mode .fake-table-cell.total { background-color: #1a365d; border-top: 1px solid #2b6cb0; }
body.dark-mode .excel-modal { background-color: #2d2d2d; border-color: #555; }
body.dark-mode .modal-header { background-color: #2d2d2d; color: #d4d4d4; }
body.dark-mode .modal-text { color: #d4d4d4; }
body.dark-mode .modal-buttons { background-color: #333; border-top-color: #555; }
body.dark-mode .modal-btn { background-color: #444; border-color: #666; color: #d4d4d4; }
body.dark-mode .modal-btn:hover { background-color: #555; border-color: #888; }

/* -------------------
   V2.0 STYLES
   ------------------- */
/* 로딩 화면 */
#loading-screen { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #f3f2f1; }
.logo { font-size: 24px; color: #217346; margin-bottom: 20px; font-weight: 600; }
.progress-container { width: 300px; height: 4px; background: #d2d0ce; margin-top: 20px; }
.progress-bar { width: 0%; height: 100%; background: #217346; animation: load 2.5s forwards ease-in-out; }
@keyframes load { 0% { width: 0%; } 20% { width: 10%; } 50% { width: 60%; } 80% { width: 80%; } 100% { width: 100%; } }
.momentum-text { font-size: 12px; color: #666; margin-top: 10px; }

/* 선언문 박스 (README) - 640px x 350px (8x14 cells) */
.declaration-box { 
    margin: 50px 80px; padding: 50px; border: 1px solid #d2d0ce; background: #fffdf0; 
    box-shadow: 3px 3px 0px #ccc; width: 640px; height: 350px; 
    position: relative;
    display: flex; flex-direction: column; justify-content: center;
}
.declaration-box h3 { color: #217346; margin-bottom: 30px; font-size: 18px; }
.declaration-box .kr { font-size: 15px; margin-bottom: 15px; line-height: 1.5; }
.declaration-box .en { font-style: italic; color: #666; font-size: 13px; line-height: 1.5; }
.declaration-box .stamp { position: absolute; bottom: 30px; right: 30px; border: 2px solid #b00; color: #b00; padding: 5px 10px; transform: rotate(-15deg); font-weight: bold; font-family: serif; letter-spacing: 2px; }

/* 다마고찌 UI (My_Pet) - 480px x 300px (6x12 cells) */
#pet-container { 
    margin: 50px 80px; padding: 40px; text-align: center; border: 1px solid #c8c6c4; background: #fff;
    width: 480px; height: 300px; 
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
#pet-avatar { font-size: 60px; margin-bottom: 30px; transition: transform 0.3s; }
#pet-dialogue { background: #f3f2f1; border: 1px solid #e1dfdd; padding: 20px; min-height: 80px; margin-bottom: 30px; border-radius: 4px; width: 100%; display: flex; align-items: center; justify-content: center; }
.pet-buttons { display: flex; justify-content: center; gap: 10px; }

/* 스텔스 광고 위젯 */
.stealth-ad { position: fixed; bottom: 50px; right: 20px; width: 240px; height: 150px; border: 1px solid #2b6cb0; background: #fff; font-size: 11px; z-index: 100; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.ad-header { background: #dbe5f1; padding: 5px 10px; font-weight: bold; border-bottom: 1px solid #2b6cb0; display: flex; justify-content: space-between; align-items: center; color: #333; }
.ad-header::after { content: 'i'; display: inline-block; width: 14px; height: 14px; border: 1px solid #2b6cb0; border-radius: 50%; text-align: center; line-height: 12px; font-size: 10px; color: #2b6cb0; cursor: pointer; }
.ad-content { display: flex; justify-content: center; align-items: center; height: 115px; color: #999; }

/* Dark Mode Overrides for V2 */
body.dark-mode #loading-screen { background: #1e1e1e; }
body.dark-mode .progress-container { background: #444; }
body.dark-mode .momentum-text { color: #aaa; }
body.dark-mode .declaration-box { background: #2d2d2d; border-color: #444; box-shadow: 3px 3px 0px #111; }
body.dark-mode .declaration-box h3 { color: #4CAF50; }
body.dark-mode .declaration-box .en { color: #888; }
body.dark-mode .declaration-box .stamp { border-color: #e57373; color: #e57373; }
body.dark-mode #pet-container { background: #2d2d2d; border-color: #444; }
body.dark-mode #pet-dialogue { background: #1e1e1e; border-color: #444; color: #d4d4d4; }
body.dark-mode .stealth-ad { background: #2d2d2d; border-color: #444; }
body.dark-mode .ad-header { background: #1a365d; border-color: #444; color: #d4d4d4; }
body.dark-mode .ad-header::after { border-color: #4CAF50; color: #4CAF50; }

/* =====================================================
   미니미 (셀구리) 서식지 스타일
   엑셀 셀(80×25px) 기준: 미니미는 20×20px 이하
   ===================================================== */

/* 시트 래퍼 */
.mini-pet-sheet-wrap {
    width: 100%;
    height: 100%;
    overflow: auto;
    background: #fff;
}

/* 서식지 전체 컨테이너 */
.mini-pet-habitat {
    display: flex;
    flex-direction: row;
    gap: 40px;
    padding: 25px 80px;
    position: relative;
    min-height: 600px;
}

/* ── 실적장표 (20행 × 5열) ─────────────────────── */
.mini-habitat-table {
    flex-shrink: 0;
    border-left: 1px solid #c8c6c4;
    border-top: 1px solid #c8c6c4;
    font-size: 11px;
    position: relative;
}

.mht-row {
    display: grid;
    grid-template-columns: 120px 60px 60px 60px 60px; /* 5열 */
}

.mht-header .mht-cell {
    background-color: #dbe5f1;
    font-weight: bold;
    color: #1f3864;
    justify-content: center;
}

.mht-cell {
    height: 25px; /* 정확히 엑셀 셀 1행 높이 */
    border-right: 1px solid #c8c6c4;
    border-bottom: 1px solid #c8c6c4;
    display: flex;
    align-items: center;
    padding: 0 4px;
    font-size: 11px;
    color: #333;
    white-space: nowrap;
}

.mht-num { justify-content: flex-end; }

.mht-even .mht-cell { background-color: #f9f9f9; }

/* ── 막대 그래프 ───────────────────────────────── */
.mini-habitat-chart {
    flex-shrink: 0;
    width: 260px;
    border: 1px solid #c8c6c4;
    background: #fff;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    margin-top: 0;
}

.mhc-title {
    font-size: 11px;
    font-weight: bold;
    color: #1f3864;
    margin-bottom: 10px;
    border-bottom: 1px solid #e1dfdd;
    padding-bottom: 6px;
}

.mhc-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px; /* 그래프 높이 = 미니미가 등반하는 영역 */
    padding-top: 20px;
    position: relative;
}

.mhc-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    height: 100%;
    gap: 3px;
    position: relative;
}

.mhc-bar {
    width: 100%;
    background: linear-gradient(to top, #2e75b6, #5b9bd5);
    border-radius: 2px 2px 0 0;
    transition: height 0.9s cubic-bezier(.17,.67,.4,1.1);
    position: relative;
}
.mhc-col:last-child .mhc-bar { background: linear-gradient(to top, #c55a11, #ed7d31); }
.mhc-col:nth-child(5) .mhc-bar { background: linear-gradient(to top, #375623, #70ad47); }

.mhc-val {
    font-size: 9px;
    color: #666;
    text-align: center;
    min-height: 12px;
}
.mhc-label {
    font-size: 10px;
    color: #555;
    font-weight: bold;
    text-align: center;
}

/* ── 미니미 캐릭터 (셀구리) ─────────────────── */
/* 전체 크기: body 16×16 + feet 4px = 약 20px
   엑셀 셀(80×25px) 보다 작음 ✅ */

.mini-pet-sprite {
    position: absolute;
    width: 20px;
    z-index: 100;
    pointer-events: none;
    transition: top 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                left 0.5s ease;
}

/* 몸통 */
.mps-body {
    width: 18px;
    height: 16px;
    background: radial-gradient(ellipse at 40% 35%, #a8e6cf, #6bc5a0);
    border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%;
    border: 1.5px solid #4a9e7a;
    position: relative;
    animation: mps-wiggle 0.9s ease-in-out infinite;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* 더듬이 */
.mps-antenna {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 6px;
    background: #4a9e7a;
    border-radius: 2px;
}
.mps-antenna::after {
    content: '';
    display: block;
    width: 4px;
    height: 4px;
    background: #ff6b6b;
    border-radius: 50%;
    position: absolute;
    top: -3px;
    left: -1px;
    animation: mps-antblink 2s ease-in-out infinite;
}

/* 눈 */
.mps-eyes {
    display: flex;
    justify-content: space-around;
    padding: 4px 3px 0;
}
.mps-eye {
    width: 4px;
    height: 4px;
    background: #1a1a2e;
    border-radius: 50%;
    position: relative;
    animation: mps-blink 3.5s ease-in-out infinite;
}
.mps-eye::after {
    content: '';
    width: 1.5px;
    height: 1.5px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 0.5px;
    left: 0.5px;
}

/* 볼 */
.mps-cheeks {
    display: flex;
    justify-content: space-between;
    padding: 1px 1px 0;
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
}
.mps-cheek {
    width: 5px;
    height: 3px;
    background: rgba(255, 150, 150, 0.5);
    border-radius: 50%;
}

/* 발 */
.mps-feet {
    display: flex;
    justify-content: space-around;
    margin-top: 1px;
}
.mps-foot {
    width: 6px;
    height: 4px;
    background: #4a9e7a;
    border-radius: 0 0 4px 4px;
    animation: mps-feet-step 0.9s ease-in-out infinite alternate;
}
.mps-foot:last-child {
    animation-delay: 0.45s;
}

/* ── 말풍선 ────────────────────────────────── */
.mini-pet-bubble {
    position: absolute;
    background: #fffbf0;
    border: 1px solid #c8c6c4;
    border-radius: 6px 6px 6px 0;
    padding: 3px 7px;
    font-size: 10px;
    color: #333;
    white-space: nowrap;
    z-index: 101;
    opacity: 0;
    transform: translateY(-4px) scale(0.9);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.1);
}
.mini-pet-bubble.visible {
    opacity: 1;
    transform: translateY(-24px) scale(1);
}

/* ── 애니메이션 키프레임 ──────────────────── */

/* 꼬물꼬물 기본 흔들림 */
@keyframes mps-wiggle {
    0%   { transform: scaleX(1)    scaleY(1)    rotate(-2deg); }
    25%  { transform: scaleX(1.08) scaleY(0.92) rotate(0deg);  }
    50%  { transform: scaleX(1)    scaleY(1)    rotate(2deg);  }
    75%  { transform: scaleX(0.93) scaleY(1.07) rotate(0deg);  }
    100% { transform: scaleX(1)    scaleY(1)    rotate(-2deg); }
}

/* 발 걷기 */
@keyframes mps-feet-step {
    from { transform: translateY(0) scaleX(1);   }
    to   { transform: translateY(1px) scaleX(0.8); }
}

/* 눈 깜빡임 */
@keyframes mps-blink {
    0%, 90%, 100% { transform: scaleY(1); }
    93%            { transform: scaleY(0.1); }
}

/* 더듬이 빛 */
@keyframes mps-antblink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(1.3); }
}

/* 낑낑 투쟁 */
.mps-struggle .mps-body {
    animation: mps-wiggle 0.25s ease-in-out infinite,
               mps-struggle-shake 0.25s ease-in-out infinite;
}
@keyframes mps-struggle-shake {
    0%   { margin-left: 0; }
    25%  { margin-left: -2px; }
    50%  { margin-left: 2px; }
    75%  { margin-left: -1px; }
    100% { margin-left: 0; }
}

/* 축하 점프 */
.mps-celebrate .mps-body {
    animation: mps-celebrate-jump 0.4s ease-in-out infinite alternate;
}
@keyframes mps-celebrate-jump {
    from { transform: translateY(0) scaleX(1)    scaleY(1);    }
    to   { transform: translateY(-5px) scaleX(1.1) scaleY(0.9); }
}

/* 미끄러짐 */
.mps-fall .mps-body {
    animation: mps-fall-spin 0.3s linear infinite;
}
@keyframes mps-fall-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* 다크모드 대응 */
body.dark-mode .mini-pet-sheet-wrap { background: #1e1e1e; }
body.dark-mode .mini-habitat-table { border-color: #444; }
body.dark-mode .mht-cell { border-color: #444; color: #d4d4d4; }
body.dark-mode .mht-even .mht-cell { background-color: #2a2a2a; }
body.dark-mode .mht-header .mht-cell { background-color: #1a365d; color: #90cdf4; }
body.dark-mode .mini-habitat-chart { background: #2d2d2d; border-color: #444; }
body.dark-mode .mhc-title { color: #90cdf4; border-color: #444; }
body.dark-mode .mhc-label { color: #aaa; }
body.dark-mode .mhc-val { color: #888; }
body.dark-mode .mini-pet-bubble { background: #2d2d2d; border-color: #555; color: #d4d4d4; }

/* =====================================================
   mp-* : 미니미 v3 신규 스타일 (CSS 수치 = JS 상수)
   PAD_T=20, PAD_L=40, ROW_H=25, TABLE_W=310, GAP=24
   ===================================================== */

/* 씬 컨테이너 - position:relative 필수 (스프라이트 절대 위치 기준) */
.mp-scene {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 24px;              /* JS: SCENE_GAP=24 */
    padding: 20px 40px;     /* JS: PAD_T=20, PAD_L=40 */
    min-height: 600px;
    background: #fff;
    overflow: auto;
}

/* ── 실적장표 ─────────────────────────────────────── */
.mp-table {
    flex-shrink: 0;
    border-left: 1px solid #c8c6c4;
    border-top:  1px solid #c8c6c4;
}

.mht-row {
    display: grid;
    grid-template-columns: 110px 50px 50px 50px 50px; /* 합계 = 310px = JS TABLE_W */
}

.mht-header .mht-cell {
    background: #dbe5f1;
    font-weight: bold;
    color: #1f3864;
    justify-content: center;
}

.mht-cell {
    height: 25px;           /* JS: ROW_H=25 - 반드시 일치 */
    border-right:  1px solid #c8c6c4;
    border-bottom: 1px solid #c8c6c4;
    display: flex;
    align-items: center;
    padding: 0 4px;
    font-size: 11px;
    color: #333;
    white-space: nowrap;
}
.mht-num { justify-content: flex-end; }
.mht-even .mht-cell { background: #f9f9f9; }

/* ── 차트 ─────────────────────────────────────────── */
.mp-chart {
    flex-shrink: 0;
    width: 220px;
    border: 1px solid #c8c6c4;
    background: #fff;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.mp-chart-title {
    font-size: 11px;
    font-weight: bold;
    color: #1f3864;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e1dfdd;
}

.mp-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;  /* JS: BAR_AREA_H (getBoundingClientRect 기준) */
    padding-top: 16px;
    flex: 1;
}

.mp-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
    height: 100%;
    gap: 2px;
}

.mp-bar {
    width: 100%;
    border-radius: 2px 2px 0 0;
    background: linear-gradient(to top, #2e75b6, #5b9bd5);
    transition: height 0.7s ease-out;
}
.mp-col:nth-child(5) .mp-bar { background: linear-gradient(to top, #375623, #70ad47); }
.mp-col:nth-child(6) .mp-bar { background: linear-gradient(to top, #c55a11, #ed7d31); }

.mp-val { font-size: 9px; color: #666; text-align: center; min-height: 11px; }
.mp-lbl { font-size: 10px; font-weight: bold; color: #555; }

/* ── 서식지 맵 ────────────────────────────────────── */
.mp-minimap {
    flex-shrink: 0;
    width: 160px;
    border: 1px solid #c8c6c4;
    background: #fff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.08);
}

.mp-minimap-title {
    font-size: 11px;
    font-weight: bold;
    color: #217346;
    border-bottom: 1px solid #e1dfdd;
    padding-bottom: 4px;
    margin-bottom: 2px;
}

#mp-map-canvas {
    border: 1px solid #e1dfdd;
    border-radius: 2px;
    display: block;
}

.mp-minimap-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 9px;
    color: #666;
}
.mml-table  { color: #5b9bd5; }
.mml-chart  { color: #ed7d31; }
.mml-pet    { color: #217346; font-weight: bold; }

/* ── 셀구리 스프라이트 ────────────────────────────── */
.mp-sprite {
    position: absolute;   /* .mp-scene 기준 */
    width: 20px;
    z-index: 100;
    pointer-events: none;
    transition: top  0.32s cubic-bezier(0.34, 1.56, 0.64, 1),
                left 0.45s ease;
}

.mps-body {
    width: 18px;
    height: 16px;
    background: radial-gradient(ellipse at 40% 35%, #a8e6cf, #6bc5a0);
    border-radius: 50% 50% 45% 45% / 55% 55% 45% 45%;
    border: 1.5px solid #4a9e7a;
    position: relative;
    animation: mps-wiggle 0.9s ease-in-out infinite;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.mps-antenna {
    position: absolute; top: -6px; left: 50%;
    transform: translateX(-50%);
    width: 2px; height: 6px;
    background: #4a9e7a; border-radius: 2px;
}
.mps-antenna::after {
    content: ''; display: block;
    width: 4px; height: 4px;
    background: #ff6b6b; border-radius: 50%;
    position: absolute; top: -3px; left: -1px;
    animation: mps-antblink 2s ease-in-out infinite;
}
.mps-eyes { display: flex; justify-content: space-around; padding: 4px 3px 0; }
.mps-eye  {
    width: 4px; height: 4px;
    background: #1a1a2e; border-radius: 50%;
    animation: mps-blink 3.5s ease-in-out infinite;
}
.mps-eye::after {
    content: ''; width: 1.5px; height: 1.5px;
    background: #fff; border-radius: 50%;
    position: absolute; top: 0.5px; left: 0.5px;
}
.mps-cheeks {
    display: flex; justify-content: space-between;
    padding: 1px 1px 0;
    position: absolute; bottom: 4px; left: 0; right: 0;
}
.mps-cheek { width: 5px; height: 3px; background: rgba(255,150,150,.5); border-radius: 50%; }
.mps-feet  { display: flex; justify-content: space-around; margin-top: 1px; }
.mps-foot  {
    width: 6px; height: 4px;
    background: #4a9e7a; border-radius: 0 0 4px 4px;
    animation: mps-feet-step 0.9s ease-in-out infinite alternate;
}
.mps-foot:last-child { animation-delay: 0.45s; }

/* ── 말풍선 ─────────────────────────────────────── */
.mp-bubble {
    position: absolute;
    background: #fffbf0;
    border: 1px solid #c8c6c4;
    border-radius: 6px 6px 6px 0;
    padding: 3px 7px;
    font-size: 10px; color: #333;
    white-space: nowrap;
    z-index: 101;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
    box-shadow: 1px 1px 4px rgba(0,0,0,0.1);
}
.mp-bubble.visible { opacity: 1; transform: scale(1); }

/* ── 키프레임 ────────────────────────────────────── */
@keyframes mps-wiggle {
    0%  { transform: scaleX(1)    scaleY(1)    rotate(-2deg); }
    25% { transform: scaleX(1.08) scaleY(0.92) rotate(0deg);  }
    50% { transform: scaleX(1)    scaleY(1)    rotate(2deg);  }
    75% { transform: scaleX(0.93) scaleY(1.07) rotate(0deg);  }
    100%{ transform: scaleX(1)    scaleY(1)    rotate(-2deg); }
}
@keyframes mps-feet-step {
    from { transform: translateY(0)   scaleX(1);   }
    to   { transform: translateY(1px) scaleX(0.8); }
}
@keyframes mps-blink {
    0%,90%,100% { transform: scaleY(1); }
    93%          { transform: scaleY(0.1); }
}
@keyframes mps-antblink {
    0%,100% { opacity:1; transform:scale(1);   }
    50%      { opacity:.4; transform:scale(1.3); }
}

.mps-struggle .mps-body {
    animation: mps-wiggle .22s ease-in-out infinite,
               mps-struggle-shake .22s ease-in-out infinite;
}
@keyframes mps-struggle-shake {
    0%  { margin-left: 0;  }
    25% { margin-left: -2px; }
    50% { margin-left: 2px; }
    75% { margin-left: -1px; }
    100%{ margin-left: 0;  }
}
.mps-celebrate .mps-body {
    animation: mps-celebrate-jump .4s ease-in-out infinite alternate;
}
@keyframes mps-celebrate-jump {
    from { transform: translateY(0)    scaleX(1)   scaleY(1);   }
    to   { transform: translateY(-5px) scaleX(1.1) scaleY(0.9); }
}
.mps-fall .mps-body {
    animation: mps-fall-spin .3s linear infinite;
}
@keyframes mps-fall-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── 다크모드 ─────────────────────────────────────── */
body.dark-mode .mp-scene { background: #1e1e1e; }
body.dark-mode .mp-table { border-color: #444; }
body.dark-mode .mht-cell { border-color: #444; color: #d4d4d4; }
body.dark-mode .mht-even .mht-cell { background: #2a2a2a; }
body.dark-mode .mht-header .mht-cell { background: #1a365d; color: #90cdf4; }
body.dark-mode .mp-chart  { background: #2d2d2d; border-color: #444; }
body.dark-mode .mp-chart-title { color: #90cdf4; border-color: #444; }
body.dark-mode .mp-lbl { color: #aaa; }
body.dark-mode .mp-val  { color: #888; }
body.dark-mode .mp-minimap { background: #2d2d2d; border-color: #444; }
body.dark-mode .mp-bubble  { background: #2d2d2d; border-color: #555; color: #d4d4d4; }
body.dark-mode #mp-map-canvas { border-color: #444; }
