body {
    background-color: #1a1a1a;
    color: #ffd700;
    font-family: 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.game-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-header {
    text-align: center;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.game-header h1 {
    margin: 0;
    font-size: 36px;
}

.rules-section {
    background: #2c2c2c;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #555;
    color: #eee;
}

.rules-section h3 {
    margin-top: 0;
    color: #ffd700;
}

.rules-section ul {
    margin-bottom: 0;
    padding-left: 20px;
}

.rules-section li {
    margin-bottom: 5px;
}

.game-container {
    background: #2c2c2c;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    border: 2px solid #ffd700;
}

.game-layout {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
}

.board-wrapper {
    overflow: auto; /* Allow scroll if needed on very small screens, though we will scale */
    display: flex;
    justify-content: center;
}

.board {
    display: grid;
    grid-template-columns: repeat(9, 80px);
    grid-template-rows: repeat(6, 80px);
    gap: 2px;
    background-color: #444;
    border: 5px solid #8b0000;
    padding: 5px;
    flex-shrink: 0;
    transform-origin: top left; /* For scaling */
    position: relative; /* Ensure z-index works contextually */
}

.center-display {
    grid-column: 2 / 9;
    grid-row: 2 / 6;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Optional: Border or background to match the red box in user image? */
    /* User image shows a red border around the center area too? */
    /* The arrow points to the empty space. The red box in the user image is around the dice in the control panel. */
    /* Moving it to center -> I should probably not add a heavy border unless requested, but maybe a subtle one or just the content. */
    /* User said "picture in right red box content move to arrow pointing red box". */
    /* The arrow points to a red outline box in the center. */
    /* So I should probably add a red border to the center display area. */
    border: 2px solid #d32f2f;
    margin: 5px; /* Add some spacing from the cells */
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
}


.cell {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid #ccc;
    position: relative;
    transition: all 0.3s;
}

.cell.active {
    background-color: #ffeb3b;
    box-shadow: inset 0 0 10px #f57f17;
    border: 3px solid #f00;
    transform: scale(1.05);
    z-index: 10;
}

.cell-number {
    font-size: 28px;
    font-weight: bold;
    color: #000;
}

.cell-prize {
    font-size: 16px;
    color: #d32f2f;
    font-weight: bold;
}

.control-panel {
    background-color: #1a1a1a;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #fff;
    border: 2px solid #555;
    border-radius: 10px;
    min-width: 300px;
    flex-grow: 1;
    max-width: 400px;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
    font-size: 16px;
    width: 100%;
}

.game-info div {
    background: #333;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid #555;
}

.balance-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none !important;
    padding: 0 !important;
    background: none !important;
}

.balance-actions {
    display: flex;
    gap: 10px;
    border: none !important;
    padding: 0 !important;
    background: none !important;
}

.action-btn {
    flex: 1;
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    color: white;
}

.recharge {
    background-color: #2196F3;
}

.withdraw {
    background-color: #f44336;
}

.game-info span {
    color: #ffd700;
    font-weight: bold;
}

.dice-area {
    display: flex;
    gap: 15px;
    margin: 10px 0;
    min-height: 60px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.dice {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 36px;
    line-height: 50px;
    color: #000;
    font-weight: bold;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.5);
    border: 1px solid #999;
}

.total-points {
    font-size: 32px;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 0 0 5px #000;
}

#dice-sum {
    color: #ff4081;
    font-weight: bold;
    font-size: 32px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 27px;
    align-items: center;
    width: 100%;
}

.direction-control {
    display: flex;
    gap: 20px;
    font-size: 18px;
}

.direction-control label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.roll-btn {
    background: linear-gradient(to bottom, #ffd700, #ffa000);
    border: none;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    color: #3e2723;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 0 #bf360c;
    transition: transform 0.1s;
    width: 100%;
}

.roll-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.roll-btn:disabled {
    background: #777;
    box-shadow: none;
    cursor: not-allowed;
    color: #aaa;
}

.settle-btn {
    background: #4caf50;
    border: none;
    padding: 10px 20px;
    font-size: 18px;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
}

.settle-btn:disabled {
    background: #555;
    cursor: not-allowed;
}

.message-area {
    margin-top: 15px;
    font-size: 16px;
    color: #ffeb3b;
    height: 24px;
    text-align: center;
}

/* Records Section */
.records-section {
    background: #2c2c2c;
    border-radius: 10px;
    overflow: hidden;
}

.tabs {
    display: flex;
    background: #333;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: #ffd700;
    border-bottom: 3px solid #ffd700;
    background: #444;
}

.records-content {
    padding: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.record-list {
    display: none;
}

.record-list.active {
    display: block;
}

.record-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #444;
    color: #ddd;
    font-size: 14px;
}

.record-item:last-child {
    border-bottom: none;
}

.empty-record {
    text-align: center;
    color: #777;
    padding: 20px;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: #333;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #ffd700;
    width: 80%;
    max-width: 300px;
    text-align: center;
}

.modal-content input {
    width: 90%;
    padding: 10px;
    margin: 15px 0;
    border-radius: 5px;
    border: 1px solid #555;
    background: #222;
    color: #fff;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-actions button {
    padding: 8px 20px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 16px;
}

#modal-cancel {
    background: #666;
    color: white;
}

#modal-confirm {
    background: #ffd700;
    color: #000;
    font-weight: bold;
}

/* Responsive */
@media (max-width: 1000px) {
    .game-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .control-panel {
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 800px) {
    .board-wrapper {
        width: 100%;
        overflow: hidden;
        display: flex;
        justify-content: center;
        /* Ensure the wrapper has height for the scaled element */
        min-height: 450px; 
    }
    
    .board {
        /* JS will handle scaling */
        transform-origin: top center;
    }
}

@media (max-width: 600px) {
    .board-wrapper {
         min-height: 350px;
    }

    .cell-number {
        font-size: 20px;
    }
    
    .cell-prize {
        font-size: 12px;
    }
    
    .roll-btn {
        font-size: 20px;
        padding: 12px 30px;
    }
}

@media (max-width: 400px) {
    .board-wrapper {
         min-height: 300px;
    }
}
