:root, [data-theme="blue"] {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --buy-color: #ef4444; 
    --sell-color: #3b82f6; 
    --accent: #f59e0b;
    --input-bg: rgba(0,0,0,0.3);
    --input-color: #ffffff;
    --input-border: rgba(255,255,255,0.2);
}

[data-theme="black"] {
    --bg-color: #000000;
    --panel-bg: rgba(25, 25, 25, 0.8);
    --text-main: #ffffff;
    --text-muted: #888888;
    --primary: #666666;
    --buy-color: #ff3333; 
    --sell-color: #3388ff; 
    --accent: #ffcc00;
    --input-bg: rgba(255,255,255,0.1);
    --input-color: #ffffff;
    --input-border: rgba(255,255,255,0.2);
}

[data-theme="white"] {
    --bg-color: #f3f4f6;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --primary: #6366f1;
    --buy-color: #dc2626; 
    --sell-color: #2563eb; 
    --accent: #d97706;
    --input-bg: rgba(0,0,0,0.05);
    --input-color: #1f2937;
    --input-border: rgba(0,0,0,0.2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

#game-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(128,128,128,0.2);
    padding-bottom: 15px;
}
header h1 { font-weight: 900; color: var(--accent); }
.badge { background: var(--primary); padding: 5px 15px; border-radius: 20px; font-weight: bold; font-size: 0.9rem; color: white;}

.main-layout { display: flex; gap: 20px; align-items: flex-start; }
@media (max-width: 768px) { .main-layout { flex-direction: column; } }

.game-area { flex: 2; display: flex; flex-direction: column; gap: 20px; width: 100%; }
.leaderboard { flex: 1; min-width: 300px; height: 100%; min-height: 500px; width: 100%; }

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid rgba(128,128,128,0.1);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background 0.3s;
}
.glass-panel h2 { font-size: 1.2rem; color: var(--text-muted); margin-bottom: 15px; }

.market-board { text-align: center; }
.price { font-size: 3.5rem; font-weight: 900; margin: 10px 0; transition: color 0.3s ease; }
.price.up { color: var(--buy-color); }
.price.down { color: var(--sell-color); }
.change-rate { font-size: 1.2rem; font-weight: bold; }
.change-rate.up { color: var(--buy-color); }
.change-rate.down { color: var(--sell-color); }

.asset-grid { display: flex; flex-direction: column; gap: 15px; }
.asset-item { display: flex; justify-content: space-between; font-size: 1.1rem; }
.highlight-cash { color: #10b981; font-weight: bold; } 
.asset-item.total { margin-top: 10px; padding-top: 15px; border-top: 1px dashed rgba(128,128,128,0.2); font-size: 1.4rem; font-weight: bold; color: var(--text-muted); }
.highlight { color: var(--primary); font-size: 0.9em; }

/* Tabs */
.tabs { display: flex; gap: 10px; margin-bottom: 15px; }
.tabs input[type="radio"] { display: none; }
.tabs .tab {
    flex: 1; text-align: center; padding: 10px;
    background: rgba(128,128,128,0.2); border-radius: 8px;
    cursor: pointer; font-weight: bold; color: var(--text-muted); transition: 0.2s;
}
.tabs input[type="radio"]:checked + .tab { background: var(--primary); color: white; }

.trading-controls .input-group {
    display: flex; align-items: center; background: var(--input-bg); border-radius: 8px; padding: 10px; margin-bottom: 15px;
    border: 1px solid var(--input-border);
}
.trading-controls input { flex: 1; background: transparent; border: none; color: var(--input-color); font-size: 1.5rem; text-align: right; outline: none; }
.trading-controls .unit { margin-left: 10px; font-size: 1.2rem; color: var(--text-main); }

.button-group { display: flex; gap: 10px; }
.btn { flex: 1; padding: 15px; font-size: 1.2rem; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; transition: transform 0.1s, filter 0.2s; color: white; }
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.1); }
.buy-btn { background-color: var(--buy-color); }
.sell-btn { background-color: var(--sell-color); }
.primary { background-color: var(--primary); }

/* Pending Orders */
#pending-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
#pending-list li {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(128,128,128,0.1); padding: 12px 15px; border-radius: 8px; font-size: 0.95rem; border-left: 4px solid var(--text-muted);
}
#pending-list li.type-buy { border-left-color: var(--buy-color); }
#pending-list li.type-sell { border-left-color: var(--sell-color); }
#pending-list li .cancel-btn {
    background: rgba(128,128,128,0.3); color: var(--text-main); border: none; padding: 6px 12px; border-radius: 5px; cursor: pointer; font-weight: bold; transition: 0.2s;
}
#pending-list li .cancel-btn:hover { background: #ef4444; color: white; }

#ranking-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
#ranking-list li { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: rgba(128,128,128,0.1); border-radius: 8px; font-size: 0.95rem; }
#ranking-list li .rank { font-weight: bold; color: var(--accent); width: 25px; }
#ranking-list li .name { flex: 1; text-align: left; margin-left: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ranking-list li .asset { font-weight: bold; color: #10b981; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--panel-bg); backdrop-filter: blur(15px); padding: 40px; border-radius: 16px; text-align: center; border: 1px solid rgba(128,128,128,0.2); max-width: 400px; width: 90%; box-shadow: 0 10px 25px rgba(0,0,0,0.5); transition: background 0.3s; }
.modal-content h2 { color: var(--accent); margin-bottom: 15px; }
.modal-content input { width: 100%; padding: 15px; margin: 20px 0; font-size: 1.2rem; border-radius: 8px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--input-color); text-align: center; }
.modal-content input:focus { outline: 2px solid var(--primary); }
.modal-content .notice { margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.4; }
