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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0e27;
    color: #e0e0e0;
    padding: 20px;
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5em;
    color: #4fc3f7;
    margin-bottom: 10px;
}

.subtitle {
    color: #9e9e9e;
    font-size: 1.1em;
}

.game-info {
    display: flex;
    justify-content: space-around;
    background: #1a1f3a;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.info-item {
    text-align: center;
}

.info-item .label {
    display: block;
    font-size: 0.9em;
    color: #9e9e9e;
    margin-bottom: 5px;
}

.info-item .value {
    display: block;
    font-size: 1.3em;
    font-weight: bold;
    color: #4fc3f7;
}

#chart-container {
    height: 500px;
    background: #131722;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    position: relative;
    z-index: 0;
}

.controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-buy {
    background: #26a69a;
    color: white;
}

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

.btn-hold {
    background: #7e57c2;
    color: white;
}

.btn-reroll {
    background: #ff9800;
    color: white;
}

.btn-primary {
    background: #4fc3f7;
    color: white;
    padding: 15px 40px;
}

/* 로그인 화면 */
.login-box {
    max-width: 400px;
    margin: 60px auto 0;
    background: #1a1f3a;
    padding: 40px 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.login-box h2 {
    color: #4fc3f7;
    margin-bottom: 24px;
    font-size: 1.5em;
}

.login-box input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1.1em;
    border: 2px solid #2a3055;
    border-radius: 8px;
    background: #0a0e27;
    color: #e0e0e0;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.login-box input:focus {
    border-color: #4fc3f7;
}

.login-box .btn {
    width: 100%;
}

/* 로비 화면 */
.lobby-records {
    max-width: 500px;
    margin: 0 auto 24px;
    background: #1a1f3a;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.lobby-records h2 {
    color: #4fc3f7;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.4em;
}

.record-summary-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 12px;
}

.record-summary-row:last-child {
    margin-bottom: 20px;
}

.record-stat {
    text-align: center;
    flex: 1;
    min-width: 0;
}

.record-label {
    display: block;
    font-size: 0.9em;
    color: #9e9e9e;
    margin-bottom: 4px;
}

.record-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
}

.record-value.win {
    color: #26a69a;
}

.record-value.loss {
    color: #ef5350;
}

.record-list {
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #2a3055;
    padding-top: 12px;
}

.record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    background: #0a0e27;
}

.record-item .record-result {
    font-weight: bold;
    font-size: 0.95em;
}

.record-item .record-result.win {
    color: #26a69a;
}

.record-item .record-result.loss {
    color: #ef5350;
}

.record-item .record-turns {
    font-size: 0.85em;
    color: #9e9e9e;
    min-width: 36px;
    text-align: center;
}

.record-item .record-return {
    font-size: 0.9em;
    font-weight: bold;
    text-align: right;
}

.record-item .record-year {
    font-size: 0.75em;
    color: #7986cb;
    min-width: 32px;
    text-align: center;
}

.record-item .record-return.win {
    color: #26a69a;
}

.record-item .record-return.loss {
    color: #ef5350;
}

/* 연도별 승률 */
.yearly-stats {
    border-top: 1px solid #2a3055;
    padding-top: 12px;
    margin-bottom: 4px;
}

.yearly-title {
    font-size: 0.9em;
    color: #9e9e9e;
    margin-bottom: 8px;
    text-align: center;
}

.yearly-list {
    max-height: 120px;
    overflow-y: auto;
}

.yearly-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 12px;
    border-radius: 6px;
    margin-bottom: 3px;
    background: #0a0e27;
}

.yearly-year {
    font-size: 0.85em;
    color: #7986cb;
    font-weight: bold;
    min-width: 36px;
}

.yearly-record {
    font-size: 0.8em;
    color: #9e9e9e;
    flex: 1;
    text-align: center;
}

.yearly-winrate {
    font-size: 0.9em;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
}

.yearly-winrate.win {
    color: #26a69a;
}

.yearly-winrate.loss {
    color: #ef5350;
}

.lobby-start-btn {
    display: block;
    max-width: 500px;
    width: 100%;
    margin: 0 auto 12px;
    padding: 18px;
    font-size: 1.2em;
}

.lobby-screener-btn {
    display: block;
    max-width: 500px;
    width: 100%;
    margin: 0 auto 12px;
    padding: 14px;
    font-size: 1.05em;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    background: #1a1f3a;
    color: #4fc3f7;
    border: 1px solid #2a3055;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.lobby-screener-btn:hover {
    background: #232a4a;
    border-color: #4fc3f7;
}

.lobby-logout-btn {
    display: block;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    padding: 12px;
}

/* Exit 버튼 */
.btn-exit {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: 1px solid #ef5350;
    color: #ef5350;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.85em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-exit:hover {
    background: #ef5350;
    color: white;
}

#game-screen header {
    position: relative;
}

/* 비중 선택 모달 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background: #1a1f3a;
    border-radius: 12px;
    padding: 30px;
    min-width: 280px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    margin-bottom: 20px;
    font-size: 1.3em;
}

.modal-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-option {
    background: #2a3055;
    color: #e0e0e0;
    padding: 14px 20px;
    font-size: 1.1em;
}

.modal-option:hover {
    background: #3a4075;
}

.btn-cancel {
    background: #555;
    color: #ccc;
    width: 100%;
    padding: 12px;
}

.game-end-modal {
    max-width: 400px;
    width: 90%;
}

#final-results {
    font-size: 1.1em;
    margin: 15px 0;
    line-height: 1.8;
    text-align: left;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 39, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #4fc3f7;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #4fc3f7;
    font-size: 1.2em;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .game-info {
        flex-wrap: nowrap;
        padding: 10px;
        gap: 4px;
    }

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

    .info-item .label {
        font-size: 0.7em;
    }

    .info-item .value {
        font-size: 0.85em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #chart-container {
        height: 350px;
    }

    .controls {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        position: relative;
        z-index: 1;
    }

    .btn {
        padding: 12px 20px;
        font-size: 1em;
        width: 100%;
    }

    #final-results {
        font-size: 0.95em;
    }

    .lobby-records {
        padding: 20px 16px;
    }

    .record-summary-row {
        gap: 12px;
    }

    .record-label {
        font-size: 0.8em;
    }

    .record-value {
        font-size: 1.2em;
    }

    .record-item .record-result {
        font-size: 0.85em;
    }

    .record-item .record-turns {
        font-size: 0.75em;
    }

    .record-item .record-return {
        font-size: 0.8em;
    }

    .record-item .record-year {
        font-size: 0.65em;
        min-width: 28px;
    }

    .yearly-list {
        max-height: 100px;
    }

    .record-list {
        max-height: 160px;
    }

    .yearly-year {
        font-size: 0.8em;
    }

    .yearly-record {
        font-size: 0.75em;
    }

    .yearly-winrate {
        font-size: 0.8em;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }

    .game-info {
        padding: 8px;
        gap: 2px;
    }

    .info-item .label {
        font-size: 0.65em;
    }

    .info-item .value {
        font-size: 0.75em;
    }

    #chart-container {
        height: 300px;
    }

    .controls {
        grid-template-columns: repeat(2, 1fr);
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .record-summary-row {
        gap: 8px;
    }

    .record-label {
        font-size: 0.75em;
    }

    .record-value {
        font-size: 1em;
    }

    .record-item .record-result {
        font-size: 0.8em;
    }

    .record-item .record-turns {
        font-size: 0.7em;
        min-width: 28px;
    }

    .record-item .record-return {
        font-size: 0.75em;
    }

    .record-item .record-year {
        font-size: 0.6em;
        min-width: 24px;
    }

    .yearly-list {
        max-height: 90px;
    }

    .record-list {
        max-height: 140px;
    }

    .yearly-title {
        font-size: 0.8em;
    }

    .yearly-year {
        font-size: 0.75em;
    }

    .yearly-record {
        font-size: 0.7em;
    }

    .yearly-winrate {
        font-size: 0.75em;
    }
}
