GNU/_PAGE/data/upbit/whale/extinction_table.php
<?php
require_once '/home/www/GNU/_PAGE/head.php';
require_once '/home/www/DB/db_upbit.php'; 

if (!isset($db_upbit) && isset($pdo)) { $db_upbit = $pdo; }

$market_name = 'KRW-BTC'; 

// [변수 초기화]
$pos52 = 0; $pos75 = 0; $pos5 = 0;
$h52 = 0; $l52 = 0; $acc24 = "0M";
$h15 = 0; $l15 = 0; $vol75 = "0M";
$h5 = 0; $l5 = 0; $vol5 = "0M";

try {
    // 1. [상태] 사회적 위치 (52주)
    $sql_status = "SELECT * FROM daemon_upbit_Ticker WHERE market = '$market_name' ORDER BY id DESC LIMIT 1";
    $row_status = $db_upbit->query($sql_status)->fetch(PDO::FETCH_ASSOC);
    
    $current_price = $row_status['trade_price'];
    $h52 = $row_status['highest_52_week_price'];
    $l52 = $row_status['lowest_52_week_price'];
    $acc24 = number_format(round($row_status['acc_trade_price_24h'] / 1000000)) . "M";
    $pos52 = ($h52 - $l52 != 0) ? round((($current_price - $l52) / ($h52 - $l52)) * 100, 2) : 0;

    // 2. [활력] 근육 탄력 (75분)
    $sql_75m = "SELECT high_price, low_price, acc_trade_price FROM daemon_upbit_coin_5m 
                WHERE market = '$market_name' ORDER BY id DESC LIMIT 15";
    $rows_75m = $db_upbit->query($sql_75m)->fetchAll(PDO::FETCH_ASSOC);
    
    if (count($rows_75m) > 0) {
        $h15 = max(array_column($rows_75m, 'high_price'));
        $l15 = min(array_column($rows_75m, 'low_price'));
        $vol75 = number_format(round(array_sum(array_column($rows_75m, 'acc_trade_price')) / 1000000)) . "M";
        $pos75 = ($h15 - $l15 != 0) ? round((($current_price - $l15) / ($h15 - $l15)) * 100, 2) : 0;
    }

    // 3. [심박] 실시간 반응 (5분)
    $sql_5m = "SELECT high_price, low_price, acc_trade_price FROM daemon_upbit_coin_5m 
               WHERE market = '$market_name' ORDER BY id DESC LIMIT 1";
    $row_5m = $db_upbit->query($sql_5m)->fetch(PDO::FETCH_ASSOC);
    
    if ($row_5m) {
        $h5 = $row_5m['high_price'];
        $l5 = $row_5m['low_price'];
        $vol5 = number_format(round($row_5m['acc_trade_price'] / 1000000), 1) . "M";
        $pos5 = ($h5 - $l5 != 0) ? round((($current_price - $l5) / ($h5 - $l5)) * 100, 2) : 0;
    }

} catch (Exception $e) { }

// ==========================================================
// [점수 계산 로직]
// ==========================================================
$weight_52w = 0.4; 
$weight_75m = 0.4; 
$weight_5m  = 0.2; 

// 기여 점수 (화면에 표시할 값)
$score_part_52w = $pos52 * $weight_52w;
$score_part_75m = $pos75 * $weight_75m;
$score_part_5m  = $pos5  * $weight_5m;

$body_score_100 = $score_part_52w + $score_part_75m + $score_part_5m;
// ==========================================================

// 테마 및 컬러
$theme_52w = "#38bdf8"; 
$theme_75m = "#fb923c"; 
$theme_5m  = "#f472b6"; 

$color_52w = ($pos52 < 15) ? "#ef4444" : $theme_52w; 
$color_75m = ($pos75 > 80) ? "#22c55e" : (($pos75 < 20) ? "#ef4444" : $theme_75m); 
$color_5m  = ($pos5 > 90) ? "#a855f7" : (($pos5 < 10) ? "#ef4444" : $theme_5m);

$score_color = ($body_score_100 >= 80) ? "#22c55e" : (($body_score_100 <= 20) ? "#ef4444" : "#ffffff");
?>

<style>
    @import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

    body { background-color: #020617;  }
    
    .radar-wrapper { 
        padding: 40px 10px; 
        font-family: 'Pretendard', sans-serif; 
        color: #fff;
    }

    .radar-container { 
        max-width: 1100px; 
        margin: 0 auto; 
        background: rgba(15, 23, 42, 0.4); 
        border: 1px solid rgba(255, 255, 255, 0.08); 
        border-radius: 24px; 
        backdrop-filter: blur(10px); 
        overflow: hidden;
    }
    
    .top-price-bar { 
        padding: 30px 40px; 
        display: flex; 
        justify-content: space-between; 
        align-items: center; 
        background: rgba(15, 23, 42, 0.8);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    .market-label { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-weight: 700; font-size: 14px; }
    .pulse-dot { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; box-shadow: 0 0 10px #22c55e; animation: blink 2s infinite; }
    @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
    
    .main-price { font-size: 40px; font-weight: 900; color: #fff; line-height: 1; }
    .main-price small { font-size: 18px; color: #475569; margin-left: 5px; font-weight: 500; }
    
    .score-container {
        text-align: right;
        background: rgba(0, 0, 0, 0.3);
        padding: 10px 20px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(4px);
    }
    .score-label {
        display: block; font-size: 13px; color: #94a3b8; font-weight: 700; margin-bottom: 2px;
        text-transform: uppercase; letter-spacing: 1px;
    }
    .score-value {
        font-size: 42px; font-weight: 900; line-height: 1;
        text-shadow: 0 0 20px currentColor; font-family: 'Inter', sans-serif;
    }
    .score-total { font-size: 16px; color: #64748b; font-weight: 600; vertical-align: super; }

    .triple-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
    .status-card { 
        padding: 35px; border-right: 1px solid rgba(255, 255, 255, 0.05); 
        display: flex; flex-direction: column;
    }
    .status-card:last-child { border-right: none; }

    .card-title { 
        font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 4px; 
        display: inline-block; margin-bottom: 25px; width: fit-content;
    }
    .title-52w { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
    .title-75m { background: rgba(251, 146, 60, 0.15); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.3); }
    .title-5m  { background: rgba(244, 114, 182, 0.15); color: #f472b6; border: 1px solid rgba(244, 114, 182, 0.3); }

    .data-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 30px; }
    .data-row small { font-size: 11px; color: #64748b; font-weight: 600; margin-bottom: 5px; display: block; }
    .data-row b { font-size: 13.5px; color: #e2e8f0; font-family: 'Inter', sans-serif; }

    .gauge-box { 
        background: rgba(0, 0, 0, 0.2); padding: 22px; border-radius: 18px; margin-top: auto;
    }
    .gauge-info { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
    
    .gauge-left { display: flex; flex-direction: column; gap: 4px; }
    .gauge-left span { font-size: 13px; color: #94a3b8; font-weight: 600; }
    .gauge-point { font-size: 12px; color: #cbd5e1; font-family: 'Inter', sans-serif; }
    .gauge-point b { font-weight: 800; color: #fff; font-size: 13px; }
    
    .gauge-right b { font-size: 26px; font-weight: 900; display:block; text-align:right; }

    .bar-bg { width: 100%; height: 7px; background: #0f172a; border-radius: 10px; overflow: hidden; }
    .bar-fill { height: 100%; border-radius: 10px; transition: width 1s ease-in-out; }

    /* 활용 가이드 섹션 스타일 */
    .usage-guide-section {
        padding: 30px 40px;
        background: rgba(15, 23, 42, 0.6);
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }
    .guide-header {
        font-size: 14px; font-weight: 800; color: #818cf8; margin-bottom: 15px; display: block;
        letter-spacing: 1px;
    }
    .guide-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
    .guide-list li { font-size: 13px; color: #94a3b8; line-height: 1.6; }
    .guide-list li strong { color: #e2e8f0; font-weight: 700; }

    @media (max-width: 1024px) {
        .triple-grid { grid-template-columns: 1fr; }
        .status-card { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.05); }
    }

    /* 전체 스크롤바 스타일 */
    ::-webkit-scrollbar { width: 10px; }
    ::-webkit-scrollbar-track { background: #0d1117; }
    ::-webkit-scrollbar-thumb { background: #30363d; border-radius: 7px; border: 2px solid #0d1117; }
    ::-webkit-scrollbar-thumb:hover { background: #8b949e; }
</style>

<div class="radar-wrapper">
    <div class="radar-container">
        <div class="top-price-bar">
            <div class="market-label">
                <div class="pulse-dot"></div>
                실시간 시장 터미널 · <?=$market_name?>
            </div>
            
            <div class="main-price">
                <?=number_format($current_price)?><small>KRW</small>
            </div>

            <div class="score-container" style="border-color: <?=$score_color?>44;">
                <span class="score-label">Vitality Score</span>
                <div class="score-value" style="color: <?=$score_color?>;">
                    <?=number_format($body_score_100, 1)?>
                    <span class="score-total">/100</span>
                </div>
            </div>
        </div>

        <div class="triple-grid">
            <div class="status-card" style="border-top: 2px solid <?=$theme_52w?>22;">
                <div class="card-title title-52w">사회적 위치 (52주)</div>
                <div class="data-row">
                    <div><small>52주 최고</small><b><?=number_format($h52)?></b></div>
                    <div><small>52주 최저</small><b><?=number_format($l52)?></b></div>
                    <div><small>24H 대금</small><b><?=$acc24?></b></div>
                </div>
                <div class="gauge-box" style="border: 1px solid <?=$color_52w?>33;">
                    <div class="gauge-info">
                        <div class="gauge-left">
                            <span>현재 노화 정도</span>
                            <span class="gauge-point">기여: <b style="color:<?=$theme_52w?>">+<?=number_format($score_part_52w, 1)?>점</b></span>
                        </div>
                        <div class="gauge-right">
                            <b style="color:<?=$color_52w?>; text-shadow: 0 0 10px <?=$color_52w?>44;"><?=$pos52?>%</b>
                        </div>
                    </div>
                    <div class="bar-bg">
                        <div class="bar-fill" style="width:<?=$pos52?>%; background:<?=$color_52w?>; box-shadow: 0 0 8px <?=$color_52w?>88;"></div>
                    </div>
                </div>
            </div>

            <div class="status-card" style="border-top: 2px solid <?=$theme_75m?>22;">
                <div class="card-title title-75m">근육 탄력 (75분)</div>
                <div class="data-row">
                    <div><small>75M 최고</small><b><?=number_format($h15)?></b></div>
                    <div><small>75M 최저</small><b><?=number_format($l15)?></b></div>
                    <div><small>75M 대금</small><b><?=$vol75?></b></div>
                </div>
                <div class="gauge-box" style="border: 1px solid <?=$color_75m?>33;">
                    <div class="gauge-info">
                        <div class="gauge-left">
                            <span>현재 탄력 지수</span>
                            <span class="gauge-point">기여: <b style="color:<?=$theme_75m?>">+<?=number_format($score_part_75m, 1)?>점</b></span>
                        </div>
                        <div class="gauge-right">
                            <b style="color:<?=$color_75m?>; text-shadow: 0 0 10px <?=$color_75m?>44;"><?=$pos75?>%</b>
                        </div>
                    </div>
                    <div class="bar-bg">
                        <div class="bar-fill" style="width:<?=$pos75?>%; background:<?=$color_75m?>; box-shadow: 0 0 8px <?=$color_75m?>88;"></div>
                    </div>
                </div>
            </div>

            <div class="status-card" style="border-top: 2px solid <?=$theme_5m?>22;">
                <div class="card-title title-5m">현재 심박 (5분)</div>
                <div class="data-row">
                    <div><small>5M 최고</small><b><?=number_format($h5)?></b></div>
                    <div><small>5M 최저</small><b><?=number_format($l5)?></b></div>
                    <div><small>5M 대금</small><b><?=$vol5?></b></div>
                </div>
                <div class="gauge-box" style="border: 1px solid <?=$color_5m?>44;">
                    <div class="gauge-info">
                        <div class="gauge-left">
                            <span>실시간 반응도</span>
                            <span class="gauge-point">기여: <b style="color:<?=$theme_5m?>">+<?=number_format($score_part_5m, 1)?>점</b></span>
                        </div>
                        <div class="gauge-right">
                            <b style="color:<?=$color_5m?>; text-shadow: 0 0 10px <?=$color_5m?>44;"><?=$pos5?>%</b>
                        </div>
                    </div>
                    <div class="bar-bg">
                        <div class="bar-fill" style="width:<?=$pos5?>%; background:<?=$color_5m?>; box-shadow: 0 0 12px <?=$color_5m?>;"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 하단 활용법 (데이터 정의) 섹션 -->
        <div class="usage-guide-section">
            <span class="guide-header">[데이타 정의]</span>
            <ul class="guide-list">
                <li><strong>고래의 정의:</strong> 고래의 유입은 해당 코인의 가치나 영속성을 보장하는 증거가 아니며, 수탈 가능한 <strong>‘에너지 방출의 증거’</strong>로만 인식한다.</li>
                <li><strong>지표의 근거:</strong> 현재 데이터는 코인의 원천적 생명력을 판단하는 지수가 아니며, 고래의 <strong>‘분포도(Distribution)’</strong>를 기반으로 한 물리적 통계이다.</li>
                <li><strong>지표의 방향성:</strong> 본 지표는 생사의 갈림길을 판단하는 상하방 균형 지표가 아니며, ‘생(生)’을 전제로 한 상방향 에너지의 강도만을 분석한 지표이다.</li>
                <li><strong>활용 가이드:</strong> 해당 데이터는 '오늘 살아있다'는 전제하에 그 힘의 분포와 응축된 강도를 상황적으로 파악하기 위한 도구이며, 결코 절대적인 생존을 보장하지 않는다.</li>
            </ul>
        </div>
    </div>
</div>

<?php require_once '/home/www/GNU/_PAGE/tail.php'; ?>