:root {
    --bg-color: #050505;
    --card-table: #1a2a4a;
    /* Deep blue for Sic Bo */
    --neon-red: #ff3131;
    --gold: #ffd700;
    --text-white: #ffffff;
    --glass: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans KR', sans-serif;
}

html,
body {
    height: 100vh;
    width: 100vw;
    background-color: var(--bg-color);
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

#app {
    display: contents;
}



/* --- Game Layout --- */
.main-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.game-area {
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, var(--card-table) 0%, var(--bg-color) 100%);
    position: relative;
    overflow-y: auto;
    flex: 1;
}

.game-message {
    font-size: 1.1rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.8);
    padding: 0 30px;
    border-radius: 20px;
    border: 1px solid var(--gold);
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(20, 20, 0, 0.8));
    margin-top: 20px;
    margin-bottom: 20px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dice-stage {
    margin-top: 20px;
    margin-bottom: 30px;
    flex-shrink: 0;
}

.dice-cup {
    width: 250px;
    height: 180px;
    background: linear-gradient(135deg, #444, #111);
    border: 5px solid #222;
    border-radius: 50% 50% 10px 10px;
    padding: 40px 20px 20px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    position: relative;
}

.dice-cup.shaking {
    animation: shakeCup 0.4s infinite ease-in-out;
}

@keyframes shakeCup {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-10px) rotate(5deg);
    }

    50% {
        transform: translateY(0) rotate(0deg);
    }

    75% {
        transform: translateY(-10px) rotate(-5deg);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

/* Removed old shake keyframes */

.dice-container {
    display: flex;
    gap: 15px;
}

.dice {
    width: 50px;
    height: 50px;
    background: #fff;
    color: #000;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 900;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    position: relative;
}

.dice.rolling {
    animation: diceRolling 0.1s infinite linear;
}

.dice.pop {
    animation: dicePop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes diceRolling {
    0% {
        transform: rotate(0deg) scale(0.9);
        opacity: 0.7;
    }

    50% {
        transform: rotate(180deg) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: rotate(360deg) scale(0.9);
        opacity: 0.7;
    }
}

@keyframes dicePop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    70% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.betting-table {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.bet-spot {
    width: 180px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.bet-spot:hover,
.bet-spot.active {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.bet-label {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gold);
}

.bet-odds {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    opacity: 0.8;
}

.bet-desc {
    font-size: 0.65rem;
    color: #aaa;
    text-align: center;
    margin-top: 5px;
}

.chart-container {
    width: 100%;
    max-width: 800px;
    height: 140px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass);
    border-radius: 15px;
    padding: 10px;
    margin-top: auto;
    flex-shrink: 0;
}

/* Stats Panel */
.stats-panel {
    background: rgba(0, 0, 0, 0.7);
    border-left: 1px solid var(--glass);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(15px);
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    color: #fff;
}

.stats-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sub-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--gold);
    border-bottom: 1px solid var(--glass);
    padding-bottom: 5px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #ddd;
}

.analysis-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
}

.analysis-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.analysis-label {
    display: block;
    font-size: 0.75rem;
    color: #bbb;
    margin-bottom: 8px;
    font-weight: 700;
}

.analysis-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
}

.analysis-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.analysis-label {
    display: block;
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 8px;
}

.win-rate-bar {
    height: 8px;
    background: #333;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    margin-bottom: 5px;
}

.rate-p {
    height: 100%;
    transition: width 0.3s;
}

.rate-b {
    height: 100%;
    transition: width 0.3s;
}

.rate-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

.streak-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.streak-item {
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px;
    border-radius: 8px;
}

.s-label {
    display: block;
    font-size: 0.6rem;
    color: #666;
}

.s-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
}

.s-value.red {
    color: var(--neon-red);
}

.roi-value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gold);
    text-align: center;
}

.roi-sub {
    display: block;
    text-align: center;
    font-size: 0.6rem;
    color: #555;
}

/* Controls */
.game-controls {
    height: 100px;
    padding: 0 40px;
    background: #000;
    border-top: 2px solid var(--gold);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-group {
    display: flex;
    gap: 30px;
    align-items: center;
}

.amount-btns {
    display: flex;
    gap: 8px;
    align-items: center;
}

.amount-btns button {
    padding: 5px 12px;
    border-radius: 5px;
    border: 1px solid #444;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 0.8rem;
}

.start-btn {
    padding: 12px 30px;
    border-radius: 25px;
    border: none;
    background: linear-gradient(135deg, var(--gold), #b8860b);
    color: #000;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
}

.start-btn.active {
    background: var(--neon-red);
    color: #fff;
}

.secondary-btn {
    padding: 15px 30px;
    border-radius: 30px;
    border: 2px solid var(--gold);
    background: transparent;
    color: var(--gold);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 15px;
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(255, 215, 0, 0.1);
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #444;
    color: #444;
}

.speed-slider {
    width: 120px;
}

.house-rule-info {
    font-size: 0.75rem;
    color: #666;
    text-align: right;
    line-height: 1.4;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #111;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--gold);
    max-width: 400px;
}

.modal-content h2 {
    color: var(--gold);
    margin-bottom: 15px;
}

.modal-content button {
    margin-top: 25px;
    padding: 10px 30px;
    border-radius: 10px;
    border: none;
    background: var(--gold);
    color: #000;
    font-weight: 800;
    cursor: pointer;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1100px) {
    .rule-info {
        display: none;
    }
}

@media (max-width: 850px) {

    html,
    body {
        height: auto;
        overflow: visible;
    }

    body {
        display: block;
        position: relative;
    }

    .main-container {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
        padding-bottom: 150px;
    }

    .game-area {
        height: auto;
        min-height: 400px;
        overflow: visible;
        padding: 20px 10px;
    }

    .dice-stage {
        height: auto;
        margin-top: 20px;
        gap: 15px;
    }

    .dice {
        width: 60px;
        height: 60px;
        font-size: 2.22rem;
    }

    .betting-area {
        width: 100%;
        flex-direction: column;
        gap: 15px;
        margin-top: 25px;
    }

    .bet-option {
        width: 100%;
        height: 60px;
    }

    .stats-panel {
        border-left: none;
        border-top: 1px solid var(--glass);
        height: auto;
        overflow: visible;
        padding: 20px;
    }

    .chart-container {
        height: 180px;
        margin-top: 30px;
    }

    .game-controls {
        height: auto;
        padding: 5px 12px 20px;
        display: flex;
        flex-direction: column;
        gap: 8px;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        background: rgba(5, 5, 5, 0.95);
        border-top: 1px solid rgba(255, 215, 0, 0.4);
        backdrop-filter: blur(20px);
    }

    .btn-group {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    #play-once-btn,
    #auto-btn,
    .secondary-btn,
    .start-btn {
        flex: 1;
        width: auto;
        height: 44px;
        padding: 0 5px;
        font-size: 0.9rem;
        margin: 0 !important;
        border-radius: 12px;
    }

    .house-rule-info {
        display: none;
    }
}

@media (max-width: 480px) {
    .modal-content {
        padding: 30px 20px;
        margin: 0 15px;
    }
}