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

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

/* 认证界面 */
#auth-screen {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    margin-top: 100px;
}

.auth-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 2em;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: #f5f5f5;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    color: #666;
}

.auth-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.auth-form input {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-form button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}

.auth-form button:hover {
    transform: translateY(-2px);
}

/* 登录界面 */
#login-screen {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    margin-top: 100px;
}

.login-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 2em;
}

.welcome-text {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.welcome-text span {
    color: #667eea;
    font-weight: bold;
}

.login-box input {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid #eee;
    border-radius: 10px;
    font-size: 16px;
}

.login-box input:focus {
    outline: none;
    border-color: #667eea;
}

#join-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    margin-bottom: 10px;
}

#join-btn:hover {
    transform: translateY(-2px);
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #999;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
}

.logout-btn:hover {
    border-color: #f44336;
    color: #f44336;
}

/* 等待房间 */
#waiting-room {
    width: 100%;
    max-width: 700px;
}

.room-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-area {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.setting-item label {
    min-width: 80px;
    color: #666;
}

.setting-item input, .setting-item select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    min-width: 80px;
}

#apply-settings-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.settings-locked-msg {
    background: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    border-radius: 8px;
    text-align: center;
}

.players-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

#players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.player-card {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.player-card .avatar { font-size: 30px; }
.player-card .name { font-weight: bold; color: #333; }
.player-card .status { font-size: 12px; color: #999; }
.player-card .host-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ffd700;
    color: #333;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}
.player-card.ready {
    background: #e8f5e9;
    border: 2px solid #4caf50;
}

.avatar-select {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.avatars {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.avatar-btn {
    width: 60px;
    height: 60px;
    font-size: 35px;
    border: 3px solid #ddd;
    border-radius: 15px;
    background: white;
    cursor: pointer;
}

.avatar-btn.selected {
    border-color: #667eea;
    background: #f0f0ff;
    transform: scale(1.1);
}

.ready-area {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.lock-button {
    flex: 1;
    padding: 15px;
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

.ready-button {
    flex: 1;
    padding: 15px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

.ready-button:disabled, .lock-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#waiting-message {
    text-align: center;
    color: white;
    font-size: 14px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 10px;
}

/* 游戏界面 */
#game-screen {
    width: 100%;
    max-width: 1200px;
}

.game-header {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#current-turn {
    background: #667eea;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
}

.legend {
    background: white;
    border-radius: 10px;
    padding: 10px 20px;
    margin-bottom: 15px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 5px;
}
.legend-color.forward { background: #4caf50; }
.legend-color.backward { background: #f44336; }
.legend-color.teleport { background: #9c27b0; }

#game-board {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    overflow: auto;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
}

.dual-board-container {
    position: relative;
    min-width: fit-content;
}

.board-container {
    display: grid;
    gap: 7px;
    justify-content: start;
    min-width: fit-content;
    position: relative;
}

.cell {
    width: 27px;
    height: 27px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    position: relative;
    transition: all 0.3s;
}

.cell .cell-number { font-size: 10px; color: #333; }
.cell .cell-effect { font-size: 7px; margin-top: 1px; }

.cell.start-cell { background: #4caf50; color: white; }
.cell.end-cell { background: #f44336; color: white; }
.cell.forward-cell { background: #c8e6c9; border: 2px solid #4caf50; }
.cell.backward-cell { background: #ffcdd2; border: 2px solid #f44336; }
.cell.teleport-cell { background: #e1bee7; border: 2px solid #9c27b0; }

.cell.highlighted {
    transform: scale(1.3);
    z-index: 10;
    box-shadow: 0 5px 20px rgba(255, 215, 0, 0.5);
}

.cell .players-on-cell {
    position: absolute;
    top: -10px;
    display: flex;
    gap: -8px;
}

.cell .player-on-cell {
    font-size: 18px;
}

/* 棋盘中心骰子 */
.center-dice {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.3));
}

.center-dice:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.center-dice.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.center-dice.rolling {
    animation: roll 0.5s ease-in-out;
}

@keyframes roll {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-50%, -50%) rotate(15deg) scale(1.1); }
    75% { transform: translate(-50%, -50%) rotate(-15deg) scale(1.1); }
}

.dice-value-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: #667eea;
    z-index: 101;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    pointer-events: none;
}

.players-status {
    background: white;
    border-radius: 15px;
    padding: 20px;
}

#players-status-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.status-card {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-card .avatar { font-size: 30px; }
.status-card .name { font-weight: bold; }
.status-card .position { font-size: 12px; color: #666; }
.status-card.current-turn {
    background: #fff3e0;
    border: 2px solid #ff9800;
}

/* 模态框 */
.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-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
}

.modal-content h2 { margin-bottom: 20px; }
.modal-content p { font-size: 20px; margin-bottom: 30px; }

#restart-btn {
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}

/* Excel上传区域 */
.excel-upload-area {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
}

.excel-upload-area h3 {
    color: #333;
    margin-bottom: 10px;
}

.excel-hint {
    color: #666;
    font-size: 12px;
    margin-bottom: 15px;
}

.excel-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.upload-btn {
    padding: 10px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.upload-btn:hover {
    background: #1976d2;
}

.upload-btn.secondary {
    background: #9c27b0;
}

.upload-btn.secondary:hover {
    background: #7b1fa2;
}

.upload-btn.danger {
    background: #f44336;
}

.upload-btn.danger:hover {
    background: #d32f2f;
}

#excel-status {
    color: #4caf50;
    font-size: 14px;
}

/* Excel消息弹窗 */
.excel-modal {
    max-width: 400px;
    text-align: center;
}

.excel-modal h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.excel-modal p {
    font-size: 18px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 20px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 10px;
}

.continue-btn {
    padding: 12px 40px;
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}

.continue-btn:hover {
    transform: translateY(-2px);
}

/* 消息提示 */
#message-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    display: none;
    z-index: 1001;
}

#message-toast.show {
    display: block;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* 响应式 */
@media (max-width: 800px) {
    .cell { width: 27px; height: 27px; }
    .cell .cell-number { font-size: 10px; }
    .cell .cell-effect { font-size: 7px; }
    .cell .player-on-cell { font-size: 10px; }
    .ready-area { flex-direction: column; }
    #game-board { padding: 10px; }
    .board-container { gap: 6px; }
}

/* 返回设置按钮 */
.back-settings-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 20px auto 0;
    padding: 12px 24px;
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
}

.back-settings-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.5);
}

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

.upload-btn.host-excel {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
    color: #fff;
    border: none;
}

.upload-btn.host-excel:hover {
    background: linear-gradient(135deg, #ab47bc, #8e24aa);
}

#max-players-input {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    font-size: 14px;
    color: #333;
    cursor: pointer;
    outline: none;
}

#max-players-input:focus {
    border-color: #667eea;
}

@media (max-width: 500px) {
    .cell { width: 24px; height: 24px; }
    .cell .cell-number { font-size: 9px; }
    .cell .cell-effect { font-size: 6px; }
    .cell .player-on-cell { font-size: 9px; }
    .board-container { gap: 4px; }
    #game-board { padding: 5px; }
}
