/*
 * 快艇骰子游戏 - 主样式文件
 * Yacht Dice Game - Main Styles
 */

/* ========== 基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a252f;
    color: #ecf0f1;
    min-height: 100vh;
    padding: 15px;
    overflow-x: hidden;
}

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

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

h1 {
    font-size: 2rem;
    color: #f1c40f;
    margin-bottom: 5px;
}

.subtitle {
    color: #bdc3c7;
    font-size: 0.95rem;
}

/* ========== 游戏信息栏 ========== */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #2c3e50;
    padding: 12px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* 玩家徽章 */
.player-badge {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 1rem;
    color: white;
    transition: all 0.3s;
}

.player1-badge { background-color: #e74c3c; }
.player2-badge { background-color: #3498db; }
.player3-badge { background-color: #2ecc71; }
.player4-badge { background-color: #9b59b6; }
.player5-badge { background-color: #f39c12; }

.player-badge.active {
    box-shadow: 0 0 15px currentColor;
    transform: scale(1.05);
}

/* ========== 按钮样式 ========== */
button {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
}

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

/* 玩家数量选择按钮 */
.player-count-btn {
    padding: 8px 16px;
    border: 2px solid #3498db;
    border-radius: 8px;
    background-color: transparent;
    color: #3498db;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.player-count-btn:hover {
    background-color: #3498db;
    color: white;
}

.player-count-btn.active {
    background-color: #3498db;
    color: white;
}

/* 规则选择按钮 */
.rule-btn {
    padding: 8px 12px;
    border: 2px solid #9b59b6;
    border-radius: 8px;
    background-color: transparent;
    color: #9b59b6;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin: 3px;
}

.rule-btn:hover {
    background-color: #9b59b6;
    color: white;
}

.rule-btn.active {
    background-color: #9b59b6;
    color: white;
}

/* 规则描述 */
.rule-description {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 3px;
}

.rule-description a {
    color: #9b59b6;
    cursor: pointer;
    text-decoration: underline dotted;
    transition: color 0.2s;
}

.rule-description a:hover {
    color: #f1c40f;
}

/* 主按钮 */
#rollBtn {
    background-color: #27ae60;
    color: white;
    font-size: 1.1rem;
    padding: 12px 30px;
}

#rollBtn:hover:not(:disabled) {
    background-color: #219653;
}

#endTurnBtn {
    background-color: #f39c12;
    color: white;
}

#endTurnBtn:hover:not(:disabled) {
    background-color: #d68910;
}

#newGameBtn {
    background-color: #9b59b6;
    color: white;
}

#newGameBtn:hover {
    background-color: #8e44ad;
}

/* ========== 动态玩家信息布局 ========== */
.player-info-left, .player-info-right {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.player-info-right {
    align-items: flex-end;
}

.player-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px;
    border-radius: 8px;
    background-color: #34495e;
    transition: all 0.3s;
}

.player-info-row.active {
    background-color: #3a506b;
    box-shadow: 0 0 10px currentColor;
}

.player-info-row .player-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.player-info-row .player-score {
    font-weight: bold;
    color: #f1c40f;
}

/* 玩家信息行左侧主题色边框 */
.player-info-row[data-player="1"] { border-left: 4px solid #e74c3c; }
.player-info-row[data-player="2"] { border-left: 4px solid #3498db; }
.player-info-row[data-player="3"] { border-left: 4px solid #2ecc71; }
.player-info-row[data-player="4"] { border-left: 4px solid #9b59b6; }
.player-info-row[data-player="5"] { border-left: 4px solid #f39c12; }

/* ========== 分数显示 ========== */
.score-display {
    font-size: 1.1rem;
}

.score-display span {
    color: #f1c40f;
    font-weight: bold;
    font-size: 1.3rem;
}

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

.round-info .round-num {
    color: #f1c40f;
    font-weight: bold;
    font-size: 1.2rem;
}

/* ========== 投掷控制区 ========== */
.roll-section {
    background-color: #2c3e50;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.roll-info {
    margin-bottom: 10px;
    font-size: 1rem;
    color: #bdc3c7;
}

.roll-info .rolls-left {
    color: #e74c3c;
    font-weight: bold;
    font-size: 1.2rem;
}

.roll-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.hint {
    text-align: center;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 10px;
}

/* ========== 骰子区域 ========== */
.dice-section {
    background-color: #2c3e50;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid #e74c3c;
    transition: border-left-color 0.3s;
}

.dice-section[data-player="1"] { border-left-color: #e74c3c; }
.dice-section[data-player="2"] { border-left-color: #3498db; }
.dice-section[data-player="3"] { border-left-color: #2ecc71; }
.dice-section[data-player="4"] { border-left-color: #9b59b6; }
.dice-section[data-player="5"] { border-left-color: #f39c12; }

.dice-section h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #f1c40f;
}

.dice-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
    perspective: 1000px;
    min-height: 130px;
}

.dice-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 5px;
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.dice-wrapper:hover {
    transform: scale(1.05);
}

.dice-wrapper.selected {
    border-color: #f1c40f;
    background-color: rgba(241, 196, 15, 0.1);
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.dice-wrapper.selected .dice {
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.5);
}

.dice {
    width: 70px;
    height: 70px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s ease-out;
}

.face {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: white;
    border: 2px solid #333;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.dot {
    width: 10px;
    height: 10px;
    background-color: #333;
    border-radius: 50%;
    position: absolute;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.3);
}

/* 点数布局 */
.dots-1 .dot:nth-child(1) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.dots-2 .dot:nth-child(1) { top: 20%; left: 20%; }
.dots-2 .dot:nth-child(2) { bottom: 20%; right: 20%; }
.dots-3 .dot:nth-child(1) { top: 20%; left: 20%; }
.dots-3 .dot:nth-child(2) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.dots-3 .dot:nth-child(3) { bottom: 20%; right: 20%; }
.dots-4 .dot:nth-child(1) { top: 20%; left: 20%; }
.dots-4 .dot:nth-child(2) { top: 20%; right: 20%; }
.dots-4 .dot:nth-child(3) { bottom: 20%; left: 20%; }
.dots-4 .dot:nth-child(4) { bottom: 20%; right: 20%; }
.dots-5 .dot:nth-child(1) { top: 20%; left: 20%; }
.dots-5 .dot:nth-child(2) { top: 20%; right: 20%; }
.dots-5 .dot:nth-child(3) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.dots-5 .dot:nth-child(4) { bottom: 20%; left: 20%; }
.dots-5 .dot:nth-child(5) { bottom: 20%; right: 20%; }
.dots-6 .dot:nth-child(1) { top: 20%; left: 25%; }
.dots-6 .dot:nth-child(2) { top: 20%; right: 25%; }
.dots-6 .dot:nth-child(3) { top: 50%; left: 25%; transform: translateY(-50%); }
.dots-6 .dot:nth-child(4) { top: 50%; right: 25%; transform: translateY(-50%); }
.dots-6 .dot:nth-child(5) { bottom: 20%; left: 25%; }
.dots-6 .dot:nth-child(6) { bottom: 20%; right: 25%; }

/* 3D位置 */
.face-1 { transform: translateZ(35px); }
.face-2 { transform: rotateX(-90deg) translateZ(35px); }
.face-3 { transform: rotateY(90deg) translateZ(35px); }
.face-4 { transform: rotateY(-90deg) translateZ(35px); }
.face-5 { transform: rotateX(90deg) translateZ(35px); }
.face-6 { transform: rotateY(180deg) translateZ(35px); }

.dice-label {
    margin-top: 5px;
    font-size: 0.85rem;
    color: #bdc3c7;
}

/* ========== 计分表区域 ========== */
.score-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.score-panel {
    background-color: #2c3e50;
    border-radius: 10px;
    padding: 15px;
}

.score-panel h3 {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #34495e;
}

.player1-panel h3 { color: #e74c3c; }
.player2-panel h3 { color: #3498db; }
.player3-panel h3 { color: #2ecc71; }
.player4-panel h3 { color: #9b59b6; }
.player5-panel h3 { color: #f39c12; }

/* 玩家面板主题色边框 */
.player1-panel { border-left: 4px solid #e74c3c; }
.player2-panel { border-left: 4px solid #3498db; }
.player3-panel { border-left: 4px solid #2ecc71; }
.player4-panel { border-left: 4px solid #9b59b6; }
.player5-panel { border-left: 4px solid #f39c12; }

.score-table {
    width: 100%;
    border-collapse: collapse;
}

.score-table tr {
    border-bottom: 1px solid #34495e;
}

.score-table tr:last-child {
    border-bottom: none;
}

.score-table td {
    padding: 8px 10px;
    text-align: left;
}

.score-table td:first-child {
    color: #ecf0f1;
    font-size: 0.95rem;
}

.score-cell {
    text-align: right;
    font-weight: bold;
    font-size: 1rem;
}

.score-cell.empty {
    color: #7f8c8d;
}

.score-cell.scored {
    color: #2ecc71;
}

.score-cell.zero {
    color: #e74c3c;
}

.category-clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-clickable:hover {
    background-color: rgba(241, 196, 15, 0.1);
}

.category-clickable td:first-child::before {
    content: '🎯 ';
}

.category-used {
    opacity: 0.6;
}

.category-used td:first-child::before {
    content: '✅ ';
}

.subtotal-row td {
    font-weight: bold;
    color: #f1c40f;
    border-top: 2px solid #34495e;
}

.bonus-row td {
    color: #2ecc71;
    font-weight: bold;
}

.total-row td {
    font-size: 1.2rem;
    font-weight: bold;
    color: #f1c40f;
    border-top: 3px solid #f1c40f;
}

/* ========== 弹窗样式 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

/* 弹窗关闭按钮 */
.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #e74c3c;
}

.modal-content {
    background-color: #2c3e50;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    position: relative;
}

.modal-content h2 {
    color: #f1c40f;
    font-size: 2rem;
    margin-bottom: 20px;
}

/* 类别选择弹窗样式 */
.modal-content.category-modal-content {
    width: 60%;
    max-width: none;
    padding: 20px;
}

.modal-content.category-modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.modal-content.category-modal-content p {
    font-size: 0.9rem;
    margin-bottom: 10px;
}

/* ========== 类别选择弹窗 ========== */
.category-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-height: none;
    overflow-y: visible;
    padding: 5px 0;
}

.category-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 5px;
    background-color: #34495e;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.category-option:hover:not(.disabled) {
    background-color: #3a506b;
    border-color: #f1c40f;
    transform: translateY(-2px);
}

.category-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.category-option.disabled:hover {
    transform: none;
    border-color: transparent;
}

.category-name {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 3px;
}

.category-score {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2ecc71;
}

.category-score.zero {
    color: #e74c3c;
}

/* 上半部分和下半部分的视觉区分 */
.category-section-title {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.8rem;
    color: #95a5a6;
    margin: 8px 0 4px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #34495e;
}

/* ========== 游戏结束弹窗 ========== */
.winner-info {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.winner-name {
    font-weight: bold;
    font-size: 1.5rem;
}

.winner-p1 { color: #e74c3c; }
.winner-p2 { color: #3498db; }

.final-scores {
    margin: 20px 0;
    font-size: 1.1rem;
}

.final-scores p {
    margin: 8px 0;
}

.tie-info {
    color: #f1c40f;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* ========== 输入框样式 ========== */
input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #34495e;
    color: #ecf0f1;
}

input[type="text"]:focus {
    outline: 2px solid #3498db;
}

input[type="text"]::placeholder {
    color: #7f8c8d;
}

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .modal-content.category-modal-content {
        width: 90%;
        padding: 15px;
    }

    .category-options {
        grid-template-columns: repeat(3, 1fr);
    }

    .score-section {
        grid-template-columns: 1fr;
    }

    .dice {
        width: 55px;
        height: 55px;
    }

    .face-1 { transform: translateZ(27.5px); }
    .face-2 { transform: rotateX(-90deg) translateZ(27.5px); }
    .face-3 { transform: rotateY(90deg) translateZ(27.5px); }
    .face-4 { transform: rotateY(-90deg) translateZ(27.5px); }
    .face-5 { transform: rotateX(90deg) translateZ(27.5px); }
    .face-6 { transform: rotateY(180deg) translateZ(27.5px); }

    .dot {
        width: 8px;
        height: 8px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .game-info {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 500px) {
    .category-options {
        grid-template-columns: repeat(2, 1fr);
    }
}
