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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 5px;
    font-size: var(--base-font-size, 16px);
}

@media (max-width: 768px) {
    body {
        padding: 3px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 2px;
        font-size: 15px;
    }
}

:root {
    --base-font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    padding: 20px;
    min-height: calc(100vh - 10px);
    display: flex;
    flex-direction: column;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        border-radius: 10px;
        min-height: auto;
    }
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 15px;
    font-size: 2em;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
}

.header-info {
    display: flex;
    justify-content: space-around;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .header-info {
        padding: 10px;
        gap: 8px;
    }
}

.info-box {
    text-align: center;
    flex: 1;
    min-width: 120px;
}

.info-box h3 {
    font-size: 0.8em;
    color: #666;
    margin-bottom: 5px;
}

.info-box p {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}

@media (max-width: 768px) {
    .info-box {
        min-width: 90px;
    }

    .info-box h3 {
        font-size: 0.7em;
    }

    .info-box p {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .header-info {
        padding: 8px;
        gap: 6px;
        flex-direction: row;
    }

    .info-box {
        min-width: 0;
        flex: 1;
    }

    .info-box h3 {
        font-size: 0.65em;
        margin-bottom: 3px;
    }

    .info-box p {
        font-size: 0.85em;
    }
}

.market-open {
    color: #28a745 !important;
}

.market-closed {
    color: #dc3545 !important;
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

.stocks-section, .player-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 768px) {
    .stocks-section, .player-section {
        padding: 12px;
    }
}

.section-title {
    font-size: 1.3em;
    margin-bottom: 10px;
    color: #333;
    border-bottom: 3px solid #667eea;
    padding-bottom: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .section-title {
        font-size: 1.1em;
        margin-bottom: 8px;
        padding-bottom: 6px;
        border-bottom-width: 2px;
    }
}

.stock-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}

@media (max-width: 768px) {
    .stock-list {
        gap: 8px;
    }
}

.stock-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .stock-item {
        padding: 10px;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .stock-item {
        padding: 8px;
        flex-direction: column;
        align-items: stretch;
    }
}

.stock-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media (hover: none) {
    .stock-item:hover {
        transform: none;
    }
}

.stock-item.delisted {
    opacity: 0.5;
    background: #f5f5f5;
}

.stock-info {
    flex: 1;
}

.stock-name {
    font-weight: bold;
    font-size: 1em;
    color: #333;
    margin-bottom: 3px;
}

.stock-price {
    font-size: 1.1em;
    color: #28a745;
    font-weight: bold;
}

@media (max-width: 768px) {
    .stock-name {
        font-size: 0.9em;
    }

    .stock-price {
        font-size: 1em;
    }
}

.stock-price.negative {
    color: #dc3545;
}

.stock-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .stock-actions {
        gap: 5px;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .stock-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .stock-actions button {
        font-size: 0.8em;
        padding: 8px 10px;
    }

    .stock-actions button:first-child {
        grid-column: 1 / -1;
    }
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85em;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    button {
        padding: 6px 12px;
        font-size: 0.75em;
    }
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.buy-btn {
    background: #28a745;
    color: white;
}

.buy-btn:hover:not(:disabled) {
    background: #218838;
}

.sell-btn {
    background: #dc3545;
    color: white;
}

.sell-btn:hover:not(:disabled) {
    background: #c82333;
}

.loan-btn {
    background: #ffc107;
    color: #333;
    width: 100%;
    margin-top: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .loan-btn {
        margin-top: 5px;
    }
}

.loan-btn:hover:not(:disabled) {
    background: #e0a800;
}

.repay-btn {
    background: #17a2b8;
    color: white;
}

.repay-btn:hover:not(:disabled) {
    background: #138496;
}

.player-info {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.player-info h4 {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.player-info p {
    font-size: 1.1em;
    font-weight: bold;
    color: #333;
}

@media (max-width: 768px) {
    .player-info {
        padding: 10px;
        margin-bottom: 8px;
    }

    .player-info h4 {
        font-size: 0.75em;
        margin-bottom: 4px;
    }

    .player-info p {
        font-size: 1em;
    }
}

.holdings-list {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.holdings-list h4 {
    margin-bottom: 8px;
    color: #666;
    font-size: 0.85em;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .holdings-list {
        padding: 10px;
        margin-top: 8px;
    }

    .holdings-list h4 {
        font-size: 0.75em;
        margin-bottom: 6px;
    }
}

#holdings-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.holding-item {
    padding: 8px;
    background: #f8f9fa;
    margin-bottom: 6px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    font-size: 0.9em;
    gap: 8px;
}

.holding-info {
    flex: 1;
    min-width: 0;
}

.holding-value {
    text-align: right;
    flex-shrink: 0;
}

.holding-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.sell-btn-small {
    padding: 4px 8px;
    font-size: 0.8em;
}

.empty-holdings {
    color: #999;
    text-align: center;
    font-size: 0.85em;
    padding: 10px;
}

@media (max-width: 768px) {
    .holding-item {
        padding: 8px;
        margin-bottom: 5px;
        font-size: 0.85em;
    }

    .holding-info {
        margin-bottom: 6px;
    }

    .holding-value {
        text-align: left;
        margin-bottom: 6px;
    }

    .holding-actions {
        display: flex;
        gap: 5px;
        width: 100%;
    }

    .holding-actions button {
        flex: 1;
    }

    .sell-btn-small {
        padding: 6px 8px;
        font-size: 0.8em;
    }

    .empty-holdings {
        font-size: 0.75em;
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .holding-item {
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .holding-info div:first-child {
        font-size: 0.95em;
        font-weight: bold;
        margin-bottom: 4px;
    }

    .holding-value {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 6px;
        background: #f8f9fa;
        border-radius: 4px;
    }

    .holding-value > div {
        font-size: 0.9em;
    }
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
}

@media (max-width: 480px) {
    .game-over-content {
        padding: 30px 20px;
        max-width: 90%;
        margin: 0 10px;
    }

    .game-over-content h2 {
        font-size: 2em;
        margin-bottom: 15px;
    }

    .game-over-content p {
        font-size: 1.1em;
        margin-bottom: 20px;
    }

    .restart-btn {
        padding: 12px 30px;
        font-size: 1em;
    }
}

.game-over-content h2 {
    color: #dc3545;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.game-over-content p {
    font-size: 1.3em;
    color: #666;
    margin-bottom: 30px;
}

.restart-btn {
    background: #667eea;
    color: white;
    padding: 15px 40px;
    font-size: 1.2em;
}

.restart-btn:hover {
    background: #5568d3;
}

.hidden {
    display: none !important;
}

.price-change {
    font-size: 0.9em;
    margin-left: 8px;
}

.price-up {
    color: #28a745;
}

.price-down {
    color: #dc3545;
}

.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.chart-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .chart-content {
        padding: 20px;
        width: 95%;
        max-height: 85vh;
        border-radius: 10px;
    }

    .chart-header {
        margin-bottom: 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .chart-title {
        font-size: 1.3em;
        flex: 1 1 100%;
    }

    .chart-close {
        padding: 6px 12px;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .chart-content {
        padding: 15px;
        width: 98%;
        max-height: 90vh;
    }

    .chart-title {
        font-size: 1.1em;
    }

    #price-chart {
        height: 300px;
    }
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-title {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
}

.chart-close {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.chart-close:hover {
    background: #c82333;
}

#price-chart {
    width: 100%;
    height: 400px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
}

.stock-info-clickable {
    cursor: pointer;
}

.stock-info-clickable:hover {
    background: #f0f0f0;
    border-radius: 5px;
}

/* 다크 모드 토글 버튼 */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.2em;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s;
}

@media (max-width: 768px) {
    .dark-mode-toggle {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 1em;
    }
}

/* 폰트 크기 조절 버튼 */
.font-size-controls {
    position: fixed;
    top: 70px;
    right: 20px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

@media (max-width: 768px) {
    .font-size-controls {
        top: 50px;
        right: 10px;
    }
}

.font-size-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.font-size-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .font-size-btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

/* 인생 리셋 버튼 */
.reset-controls {
    position: fixed;
    top: 110px;
    right: 20px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

@media (max-width: 768px) {
    .reset-controls {
        top: 85px;
        right: 10px;
    }
}

.reset-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.reset-btn:hover {
    background: #ee5a52;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .reset-btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

.dark-mode-toggle:hover {
    background: #555;
    transform: translateY(-2px);
}

/* 다크 모드 스타일 */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .container {
    background: #0f3460;
    color: #e0e0e0;
}

body.dark-mode h1 {
    color: #e0e0e0;
}

body.dark-mode .header-info {
    background: #16213e;
}

body.dark-mode .info-box h3 {
    color: #b0b0b0;
}

body.dark-mode .info-box p {
    color: #e0e0e0;
}

body.dark-mode .stocks-section,
body.dark-mode .player-section {
    background: #16213e;
}

body.dark-mode .section-title {
    color: #e0e0e0;
    border-bottom-color: #667eea;
}

body.dark-mode .stock-item {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .stock-item:hover {
    background: #212842;
}

body.dark-mode .stock-item.delisted {
    background: #2a2a3e;
}

body.dark-mode .stock-name {
    color: #e0e0e0;
}

body.dark-mode .player-info {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .player-info h4 {
    color: #b0b0b0;
}

body.dark-mode .player-info p {
    color: #e0e0e0;
}

body.dark-mode .holdings-list {
    background: #1a1a2e;
}

body.dark-mode .holding-item {
    background: #16213e;
}

body.dark-mode .holding-info div:first-child {
    color: #e0e0e0;
}

body.dark-mode .stock-info-clickable:hover {
    background: #2a2a3e;
}

body.dark-mode .chart-content {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .chart-title {
    color: #e0e0e0;
}

body.dark-mode #price-chart {
    background: #16213e;
    border-color: #333;
}

body.dark-mode .game-over-content {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .game-over-content h2 {
    color: #ff6b6b;
}

body.dark-mode .game-over-content p {
    color: #b0b0b0;
}

.dark-mode-toggle.dark-mode {
    background: #f8f9fa;
    color: #333;
}

.dark-mode-toggle.dark-mode:hover {
    background: #e0e0e0;
}

body.dark-mode .font-size-btn {
    background: #667eea;
}

body.dark-mode .font-size-btn:hover {
    background: #5568d3;
}

body.dark-mode .reset-btn {
    background: #ff6b6b;
}

body.dark-mode .reset-btn:hover {
    background: #ee5a52;
}

/* Market Tabs */
.market-tabs {
    display: flex;
    border-bottom: 2px solid #dee2e6;
    margin-bottom: 10px;
}

.tab-button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    font-size: 1.1em;
    font-weight: bold;
    color: #495057;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

@media (max-width: 480px) {
    .tab-button {
        padding: 8px 12px;
        font-size: 0.95em;
        flex: 1;
    }

    .market-tabs {
        margin-bottom: 8px;
    }
}

.tab-button:hover {
    background-color: #f8f9fa;
    color: #000;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-panel {
    display: none; /* Hide panels by default */
}

.tab-panel.active {
    display: block; /* Show active panel */
}

/* Dark Mode Tab Styles */
body.dark-mode .market-tabs {
    border-bottom-color: #343a40;
}

body.dark-mode .tab-button {
    color: #adb5bd;
}

body.dark-mode .tab-button:hover {
    background-color: #343a40;
    color: #fff;
}

body.dark-mode .tab-button.active {
    color: #829bff;
    border-bottom-color: #829bff;
}

/* New styles for player info grid and exchange */
.player-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

@media (max-width: 480px) {
    .player-info-grid {
        gap: 8px;
    }

    .player-info-grid .player-info {
        padding: 8px;
    }

    .player-info-grid .player-info h4 {
        font-size: 0.7em;
    }

    .player-info-grid .player-info p {
        font-size: 0.9em;
    }
}

.exchange-section {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.exchange-section h4 {
    color: #666;
    font-size: 0.85em;
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .exchange-section {
        padding: 10px;
        margin-bottom: 8px;
    }

    .exchange-rate-display {
        flex-wrap: wrap;
        gap: 4px;
    }

    .exchange-input-container {
        margin-bottom: 8px;
    }

    .exchange-input-container label {
        font-size: 0.85em;
    }

    .exchange-input-container input {
        font-size: 0.9em;
        padding: 6px;
    }
}

.exchange-rate-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}

.exchange-rate {
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
    margin: 0;
}

.rate-change {
    font-size: 0.85em;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f0f0f0;
    transition: all 0.3s;
}

.rate-change.up {
    color: #dc3545;
    background: #ffe5e5;
    animation: rateUp 0.5s ease;
}

.rate-change.down {
    color: #28a745;
    background: #e5ffe5;
    animation: rateDown 0.5s ease;
}

@keyframes rateUp {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes rateDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(5px); }
}

.exchange-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exchange-input-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.exchange-input-container input {
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 1em;
}

@media (max-width: 480px) {
    .exchange-input-container input {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
}

.slider-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
}

.amount-display {
    font-size: 1.1em;
    font-weight: bold;
    color: #007bff;
}

.krw-display {
    font-size: 0.9em;
    color: #666;
    font-weight: bold;
}

.quick-amount-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 8px;
}

.quick-btn {
    background: #6c757d;
    color: white;
    padding: 6px 10px;
    font-size: 0.8em;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

.quick-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.quick-btn:active {
    transform: translateY(0);
    background: #545b62;
}

.fee-display {
    background: #f8f9fa;
    padding: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    border: 1px solid #dee2e6;
}

.fee-label {
    color: #666;
    font-weight: 500;
}

.fee-amount {
    font-weight: bold;
    color: #dc3545;
}

.exchange-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

@media (max-width: 480px) {
    .exchange-buttons {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}

.exchange-btn {
    background: #007bff;
    color: white;
    transition: all 0.3s;
}

.exchange-btn:hover:not(:disabled) {
    background: #0056b3;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.exchange-btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* Dark mode for new elements */
body.dark-mode .exchange-section {
    background: #1a1a2e;
}

body.dark-mode .exchange-section h4 {
    color: #b0b0b0;
}

body.dark-mode .exchange-rate {
    color: #e0e0e0;
}

body.dark-mode .rate-change {
    background: #2a2a3e;
}

body.dark-mode .rate-change.up {
    background: #3d2828;
    color: #ff6b6b;
}

body.dark-mode .rate-change.down {
    background: #283d28;
    color: #51cf66;
}

body.dark-mode .slider-container input[type="range"] {
    background: #555;
}

body.dark-mode .slider-container input[type="range"]::-webkit-slider-thumb {
    background: #667eea;
}

body.dark-mode .slider-container input[type="range"]::-moz-range-thumb {
    background: #667eea;
}

body.dark-mode .amount-display {
    color: #667eea;
}

body.dark-mode .krw-display {
    color: #b0b0b0;
}

body.dark-mode .quick-btn {
    background: #495057;
}

body.dark-mode .quick-btn:hover {
    background: #5a6268;
}

body.dark-mode .quick-btn:active {
    background: #343a40;
}

body.dark-mode .fee-display {
    background: #16213e;
    border-color: #2a3a5e;
}

body.dark-mode .fee-label {
    color: #b0b0b0;
}

body.dark-mode .fee-amount {
    color: #ff6b6b;
}

/* 알림 토스트 */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #28a745;
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 2000;
    animation: toastSlideIn 0.4s ease-out forwards, toastFadeOut 0.4s ease-in 1.6s forwards;
}

@keyframes toastSlideIn {
    0% {
        top: -50px;
        opacity: 0;
    }
    100% {
        top: 20px;
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

body.dark-mode .toast-notification {
    background: #2d8653;
}

.toast-error {
    background: #dc3545 !important;
}

body.dark-mode .toast-error {
    background: #c82333 !important;
}

.toast-warning {
    background: #ffc107 !important;
    color: #333 !important;
}

body.dark-mode .toast-warning {
    background: #e0a800 !important;
}

@media (max-width: 768px) {
    .toast-notification {
        font-size: 0.9em;
        padding: 12px 20px;
        top: 10px;
    }
}

@media (max-width: 480px) {
    .toast-notification {
        font-size: 0.85em;
        padding: 10px 16px;
        top: 8px;
        max-width: 90%;
    }

    @keyframes toastSlideIn {
        0% {
            top: -50px;
            opacity: 0;
        }
        100% {
            top: 8px;
            opacity: 1;
        }
    }
}

/* 레버리지 컨트롤 */
.leverage-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.leverage-toggle-container {
    display: flex;
    align-items: center;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 8px;
}

.toggle-label input[type="checkbox"] {
    width: 40px;
    height: 20px;
    cursor: pointer;
    appearance: none;
    background: #ccc;
    border-radius: 10px;
    position: relative;
    transition: all 0.3s;
}

.toggle-label input[type="checkbox"]:checked {
    background: #667eea;
}

.toggle-label input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
}

.toggle-label input[type="checkbox"]:checked::before {
    left: 22px;
}

.toggle-text {
    font-weight: bold;
    font-size: 0.95em;
    color: #333;
}

.leverage-ratio-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leverage-direction-container,
.leverage-multiplier-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .leverage-controls {
        padding: 10px;
        gap: 8px;
    }

    .toggle-text {
        font-size: 0.9em;
    }

    .ratio-label {
        padding: 5px 10px;
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    .leverage-ratio-container {
        width: 100%;
        justify-content: space-between;
    }

    .ratio-label {
        flex: 1;
        justify-content: center;
        padding: 8px;
    }

    .ratio-label input[type="radio"] {
        margin: 0;
    }

    .ratio-label span {
        font-size: 0.9em;
    }
}

.ratio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    transition: all 0.3s;
}

.ratio-label:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.ratio-label input[type="radio"] {
    cursor: pointer;
}

.ratio-label input[type="radio"]:checked + span {
    font-weight: bold;
    color: #667eea;
}

.ratio-label span {
    font-size: 0.9em;
    color: #333;
}

/* 레버리지 포지션 배지 */
.leverage-badge {
    display: inline-block;
    background: #ffc107;
    color: #333;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    margin-left: 5px;
}

/* 숏 포지션 배지 */
.short-badge {
    background: #dc3545;
    color: white;
}

.leverage-position {
    border-left: 3px solid #ffc107;
}

.short-position {
    border-left: 3px solid #dc3545;
}

.liquidation-warning {
    background: #ffe5e5 !important;
    border-left-color: #dc3545 !important;
}

/* Dark mode for leverage controls */
body.dark-mode .leverage-controls {
    background: #1a1a2e;
}

body.dark-mode .toggle-text {
    color: #e0e0e0;
}

body.dark-mode .ratio-label {
    background: #16213e;
    border-color: #2a3a5e;
}

body.dark-mode .ratio-label:hover {
    background: #2a2a3e;
    border-color: #667eea;
}

body.dark-mode .ratio-label span {
    color: #e0e0e0;
}

body.dark-mode .ratio-label input[type="radio"]:checked + span {
    color: #829bff;
}

body.dark-mode .leverage-badge {
    background: #e0a800;
    color: #1a1a2e;
}

body.dark-mode .liquidation-warning {
    background: #3d2828 !important;
}

/* 추가 모바일 최적화 */
@media (max-width: 480px) {
    /* 스크롤 개선 */
    .stock-list,
    #holdings-container,
    #leverage-positions-container {
        -webkit-overflow-scrolling: touch;
    }

    /* 터치 영역 개선 */
    button,
    .tab-button,
    .stock-info-clickable {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 컨테이너 여백 최소화 */
    .container {
        padding: 10px;
        margin: 0;
    }

    h1 {
        font-size: 1.3em;
        margin-bottom: 8px;
    }

    /* 섹션 제목 크기 조정 */
    .section-title {
        font-size: 1em;
        padding-bottom: 5px;
    }

    /* 고정 버튼 위치 조정 */
    .dark-mode-toggle {
        top: 8px;
        right: 8px;
        padding: 6px 12px;
        font-size: 0.9em;
    }

    .font-size-controls {
        top: 45px;
        right: 8px;
    }

    .font-size-btn {
        padding: 5px 8px;
        font-size: 0.75em;
    }

    .reset-controls {
        top: 75px;
        right: 8px;
    }

    .reset-btn {
        padding: 5px 8px;
        font-size: 0.75em;
    }
}

/* 가로 모드 최적화 */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        min-height: auto;
    }

    .content-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    h1 {
        font-size: 1.2em;
        margin-bottom: 8px;
    }

    .header-info {
        padding: 8px;
        margin-bottom: 8px;
    }
}



/* 호가창 모달 스타일 */
.order-book-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.order-book-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.order-book-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.order-book-title {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

.order-book-close {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.order-book-close:hover {
    background: #c82333;
}

.ai-traders-info {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.ai-traders-info h4 {
    margin: 0 0 5px 0;
    color: #666;
    font-size: 0.9em;
}

.ai-traders-info p {
    margin: 0;
    font-size: 0.85em;
    color: #333;
}

.order-book-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.sell-orders-section,
.buy-orders-section {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.order-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 8px 12px;
    font-weight: bold;
    font-size: 0.85em;
}

.sell-header {
    background: #ffe5e5;
    color: #dc3545;
}

.buy-header {
    background: #e5ffe5;
    color: #28a745;
}

.header-price {
    text-align: left;
}

.header-quantity {
    text-align: right;
}

.orders-list {
    max-height: 150px;
    overflow-y: auto;
}

.order-row {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 6px 12px;
    font-size: 0.9em;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}

.order-row:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.02);
}

.order-row:last-child {
    border-bottom: none;
}

.order-row.sell {
    color: #dc3545;
}

.order-row.buy {
    color: #28a745;
}

.order-row .order-price {
    text-align: left;
    font-weight: bold;
    position: relative;
    z-index: 2;
}

.order-row .order-quantity {
    text-align: right;
    position: relative;
    z-index: 2;
}

/* 호가 수량 막대 그래프 */
.order-bar {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    opacity: 0.15;
    transition: all 0.3s;
    z-index: 1;
}

.order-row:hover .order-bar {
    opacity: 0.25;
}

.sell-bar {
    background: linear-gradient(to left, #dc3545, transparent);
}

.buy-bar {
    background: linear-gradient(to left, #28a745, transparent);
}

/* 스프레드 정보 섹션 */
.spread-section {
    background: #f8f9fa;
    padding: 10px 12px;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.spread-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.spread-label {
    font-size: 0.75em;
    color: #666;
    font-weight: 500;
}

.spread-value {
    font-size: 0.9em;
    font-weight: bold;
    color: #667eea;
}

.total-qty-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: right;
}

.total-qty-info span {
    font-size: 0.8em;
    font-weight: 500;
}

.sell-total {
    color: #dc3545;
}

.buy-total {
    color: #28a745;
}

.current-price-section {
    background: #667eea;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    color: white;
}

.current-price-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.current-price-label {
    font-size: 0.8em;
    opacity: 0.9;
}

.current-price-value {
    font-size: 1.3em;
    font-weight: bold;
}

.current-price-change {
    font-size: 0.85em;
}

.order-input-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.order-type-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.order-tab {
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    background: white;
    color: #666;
    transition: all 0.3s;
}

.order-tab.active {
    background: #667eea;
    color: white;
}

.order-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-method {
    display: flex;
    gap: 15px;
}

.order-method-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.9em;
}

.order-method-label input[type="radio"] {
    cursor: pointer;
}

.order-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.order-input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-input-group label {
    font-size: 0.85em;
    font-weight: bold;
    color: #666;
}

.order-input-group input {
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.95em;
}

.order-submit-btn {
    background: #28a745;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: all 0.3s;
}

.order-submit-btn:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.order-submit-btn.sell-mode {
    background: #dc3545;
}

.order-submit-btn.sell-mode:hover {
    background: #c82333;
}

.pending-orders-section,
.recent-trades-section {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.pending-orders-section h4,
.recent-trades-section h4 {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 0.9em;
}

.pending-orders-list,
.recent-trades-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.pending-order-item,
.trade-item {
    background: white;
    padding: 8px;
    border-radius: 5px;
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pending-order-item {
    border-left: 3px solid #667eea;
}

.pending-order-item.buy {
    border-left-color: #28a745;
}

.pending-order-item.sell {
    border-left-color: #dc3545;
}

.trade-item.buy {
    border-left: 3px solid #28a745;
}

.trade-item.sell {
    border-left: 3px solid #dc3545;
}

.cancel-order-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
}

.cancel-order-btn:hover {
    background: #5a6268;
}

.no-orders,
.no-trades {
    text-align: center;
    color: #999;
    font-size: 0.85em;
    padding: 10px;
}

/* 다크 모드 */
body.dark-mode .order-book-content {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.dark-mode .order-book-title {
    color: #e0e0e0;
}

body.dark-mode .ai-traders-info {
    background: #16213e;
}

body.dark-mode .ai-traders-info h4 {
    color: #b0b0b0;
}

body.dark-mode .ai-traders-info p {
    color: #e0e0e0;
}

body.dark-mode .sell-orders-section,
body.dark-mode .buy-orders-section {
    background: #16213e;
}

body.dark-mode .order-row {
    border-bottom-color: #2a3a5e;
}

body.dark-mode .order-row:hover {
    background: rgba(102, 126, 234, 0.2);
}

body.dark-mode .spread-section {
    background: #16213e;
}

body.dark-mode .spread-label {
    color: #b0b0b0;
}

body.dark-mode .spread-value {
    color: #829bff;
}

body.dark-mode .order-input-section {
    background: #16213e;
}

body.dark-mode .order-tab {
    background: #2a2a3e;
    color: #b0b0b0;
}

body.dark-mode .order-tab.active {
    background: #667eea;
    color: white;
}

body.dark-mode .order-input-group label {
    color: #b0b0b0;
}

body.dark-mode .order-input-group input {
    background: #2a2a3e;
    border-color: #3a4a6e;
    color: #e0e0e0;
}

body.dark-mode .pending-orders-section,
body.dark-mode .recent-trades-section {
    background: #16213e;
}

body.dark-mode .pending-order-item,
body.dark-mode .trade-item {
    background: #2a2a3e;
    color: #e0e0e0;
}

@media (max-width: 768px) {
    .order-book-content {
        width: 95%;
        padding: 15px;
    }

    .order-book-title {
        font-size: 1.2em;
    }

    .order-inputs {
        grid-template-columns: 1fr;
    }

    .spread-section {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .total-qty-info {
        text-align: left;
    }

    .order-row {
        font-size: 0.85em;
        padding: 8px 10px;
    }

    .order-row:hover {
        transform: none;
    }
}


/* 호가창 버튼 스타일 */
.order-book-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s;
    margin-right: 5px;
}

.order-book-btn:hover:not(:disabled) {
    background: #5568d3;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.order-book-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

body.dark-mode .order-book-btn {
    background: #5568d3;
}

body.dark-mode .order-book-btn:hover:not(:disabled) {
    background: #667eea;
}

