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

body {
    font-family: 'Quicksand', 'Poppins', system-ui, -apple-system, sans-serif;
    background: linear-gradient(145deg, #fef5e7 0%, #ffe4e8 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.dynamic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.screen {
    display: none;
    position: relative;
    z-index: 10;
    min-height: 100vh;
    width: 100%;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: rgba(255, 250, 245, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 70px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.2);
}

.title {
    font-size: 2rem;
    background: linear-gradient(135deg, #FF8A9F, #C084FC);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 20px;
}

/* 角色选择器样式 - 确保可点击 */
.role-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.role-option {
    flex: 1;
    padding: 15px;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    z-index: 10;
    opacity: 0.5;  /* 未选中时半透明 */
    filter: grayscale(0.3);
}

.role-option.selected {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* 未选中的角色悬停时稍微提高可见度 */
.role-option:hover:not(.selected) {
    opacity: 0.7;
    filter: grayscale(0.2);
    transform: scale(1.02);
}

.role-option * {
    pointer-events: none;
}

.role-option {
    pointer-events: auto;
}

.role-option.pink {
    background: #ffe4f0;
    border: 2px solid #FFB7C5;
}

.role-option.purple {
    background: #f0e6ff;
    border: 2px solid #C084FC;
}

.role-option.pink.selected {
    border: 3px solid #FF6B8B;
    box-shadow: 0 0 20px rgba(255,107,139,0.3);
}

.role-option.purple.selected {
    border: 3px solid #C084FC;
    box-shadow: 0 0 20px rgba(192,132,252,0.3);
}

.role-avatar {
    font-size: 2.5rem;
    margin-bottom: 5px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.role-option:hover .role-avatar {
    transform: scale(1.1) rotate(5deg);
}

.role-option.selected .role-avatar {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 游戏界面头像样式 */
.avatar-icon {
    font-size: 1.8rem;
    display: inline-block;
    transition: transform 0.2s ease;
}

.avatar-icon:hover {
    transform: scale(1.1);
}

.opponent-avatar {
    font-size: 1.5rem;
    margin-right: 8px;
}

.player-avatar {
    font-size: 2rem;
    margin-bottom: 5px;
}

.player-color {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 3px;
}

.player-waiting.pink {
    background: #ffe4f0;
    border-radius: 30px;
    padding: 15px;
}

.player-waiting.purple {
    background: #f0e6ff;
    border-radius: 30px;
    padding: 15px;
}

.role-name {
    font-size: 1rem;
    font-weight: bold;
}

.role-color {
    font-size: 0.8rem;
    opacity: 0.8;
}

.config-section {
    margin: 15px 0;
    text-align: left;
}

.config-section label {
    font-weight: bold;
    color: #c7376f;
    display: block;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.subject-select {
    width: 100%;
    padding: 10px;
    border-radius: 30px;
    border: 2px solid #ffe4f0;
    background: white;
    font-family: inherit;
}

.room-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, #FF6B8B, #FF8A9F);
    color: white;
}

.btn-secondary {
    background: #e0d6ff;
    color: #6b4e9e;
}

.join-room {
    display: flex;
    gap: 8px;
}

.join-room input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ffe4f0;
    border-radius: 40px;
    font-family: inherit;
}

.or-divider {
    color: #999;
    font-size: 0.8rem;
}

.waiting-container {
    background: rgba(255, 250, 245, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 50px;
    padding: 25px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.room-info {
    background: #ffeef4;
    padding: 10px;
    border-radius: 30px;
    margin: 15px 0;
}

.waiting-players {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin: 20px 0;
}

.player-waiting {
    flex: 1;
    padding: 15px;
    border-radius: 30px;
    text-align: center;
}

.player-waiting.pink {
    background: #ffe4f0;
}

.player-waiting.purple {
    background: #f0e6ff;
}

.vs-div {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff8a9f;
    display: flex;
    align-items: center;
}

.start-game-wrapper {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.btn-start-game {
    background: linear-gradient(135deg, #FF6B8B, #FF8A9F, #FFB7C5);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    animation: pulse 2s infinite;
}

.btn-text {
    display: inline-block;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(255,107,139,0.5); }
    50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(255,107,139,0.8); }
}

.game-container {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    background: rgba(255, 250, 245, 0.85);
    backdrop-filter: blur(12px);
    border-radius: 50px;
    padding: 20px;
}

.hero-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FF8A9F, #C084FC);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 15px;
}

.opponent-info {
    background: rgba(255, 250, 245, 0.8);
    border-radius: 30px;
    padding: 10px 15px;
    margin-bottom: 15px;
}

.opponent-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.my-card {
    background: linear-gradient(135deg, #ffe4f0, #ffd9e8);
    border: 2px solid #FFB7C5;
}

.my-card.purple {
    background: linear-gradient(135deg, #f0e6ff, #e9d9ff);
    border: 2px solid #C084FC;
}

.score-badge {
    font-size: 1.3rem;
    font-weight: bold;
    background: rgba(255,255,255,0.8);
    display: inline-block;
    padding: 5px 20px;
    border-radius: 30px;
    margin: 10px 0;
}

.progress-text {
    font-size: 0.85rem;
    margin: 5px 0;
}

.timer-area {
    width: 100px;
    height: 100px;
    margin: 15px auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100px;
    height: 100px;
    position: absolute;
    top: 0;
    left: 0;
}

.timer-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 6;
}

.timer-progress {
    fill: none;
    stroke: #FF6B8B;
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

/* 紫色角色计时器颜色 */
.my-section.purple .timer-progress {
    stroke: #9B6BFF;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3rem;
    font-weight: bold;
    color: #FF6B8B;
    background: rgba(255, 255, 255, 0.9);
    width: 60px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.my-section.purple .timer-text {
    color: #9B6BFF;
}

/* 移动端适配 */
@media (max-width: 600px) {
    .timer-area {
        width: 80px;
        height: 80px;
        margin: 10px auto;
    }
    .timer-svg {
        width: 80px;
        height: 80px;
    }
    .timer-text {
        width: 50px;
        height: 50px;
        line-height: 50px;
        font-size: 1.1rem;
    }
}

.question-card {
    background: rgba(255,255,255,0.9);
    border-radius: 25px;
    padding: 15px;
    margin: 15px 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.question-content {
    margin-bottom: 10px;
}

.question-image img {
    max-width: 100%;
    border-radius: 12px;
    margin: 10px 0;
}

.question-graph {
    background: #f9f9f9;
    border-radius: 12px;
    padding: 10px;
    margin: 10px 0;
    text-align: center;
}

.options-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 15px 0;
}

.opt-btn {
    background: white;
    border: 2px solid #ffbfcf;
    padding: 10px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.player-waiting.pink .player-avatar {
    font-size: 2rem;
    margin-bottom: 8px;
}

.player-waiting.purple .player-avatar {
    font-size: 2rem;
    margin-bottom: 8px;
}

.game-status {
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: #c7376f;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.winner-card {
    background: white;
    border-radius: 50px;
    padding: 30px;
    text-align: center;
    max-width: 350px;
    width: 85%;
}

.correct-flash {
    animation: correctPulse 0.4s ease;
}

@keyframes correctPulse {
    0% { background-color: #c8ffb0; transform: scale(1);}
    50% { background-color: #9bff7a; transform: scale(1.01);}
    100% { background-color: transparent; transform: scale(1);}
}

.wrong-flash {
    animation: wrongShake 0.3s ease;
}

@keyframes wrongShake {
    0%,100%{ transform: translateX(0);}
    25%{ transform: translateX(-3px);}
    75%{ transform: translateX(3px);}
}

@media (max-width: 600px) {
    .login-container { padding: 20px; }
    .title { font-size: 1.5rem; }
    .options-group { grid-template-columns: 1fr; }
    .hero-title { font-size: 1.2rem; }
    .my-card { padding: 15px; }
}

/* MathJax 公式样式 */
.math-inline {
    display: inline-block;
    font-family: monospace;
    background: #f5f5f5;
    padding: 0 4px;
    border-radius: 4px;
}

.math-display {
    text-align: center;
    margin: 12px 0;
    overflow-x: auto;
    background: #f9f9f9;
    padding: 8px;
    border-radius: 8px;
}

mjx-container {
    overflow-x: auto;
    overflow-y: hidden;
}

/* 题目图片样式 */
.question-image img {
    max-width: 100%;
    border-radius: 12px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* SVG 图形样式 */
.question-graph svg {
    max-width: 100%;
    height: auto;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 10px;
}

/* 修复计时器样式 - 确保文字可见 */
.timer-area {
    width: 80px;
    height: 80px;
    margin: 10px auto;
    position: relative;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 80px;
    height: 80px;
}

.timer-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: #FF6B8B;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear;
}

/* 紫色角色计时器颜色 */
.my-card.purple .timer-progress {
    stroke: #9B6BFF;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    width: 50px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    border-radius: 50%;
}

/* 倒计时数字颜色 */
.timer-text {
    color: #FF6B8B;
    font-size: 1.2rem;
    font-weight: bold;
}

.my-card.purple .timer-text {
    color: #9B6BFF;
}

/* 结果弹窗样式优化 */
.winner-card {
    background: white;
    border-radius: 50px;
    padding: 25px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.winner-msg {
    font-size: 1.1rem;
    line-height: 1.5;
}

.winner-card .btn {
    margin: 5px;
    min-width: 120px;
    transition: all 0.3s ease;
}

.winner-card .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.winner-card .btn-primary {
    background: linear-gradient(135deg, #FF6B8B, #FF8A9F);
}

.winner-card .btn-secondary {
    background: #e0d6ff;
    color: #6b4e9e;
}

/* 按钮禁用样式 */
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Toast 动画 */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* 多选题样式 */
.multi-choice-container {
    margin: 15px 0;
}

.multi-hint {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 10px;
    text-align: center;
    padding: 5px;
    background: #f5f5f5;
    border-radius: 20px;
}

.multi-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.multi-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: white;
    border: 2px solid #ffbfcf;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s;
}

.multi-option:hover {
    transform: translateX(5px);
}

/* 美乐蒂主题选中样式 */
.my-section .multi-option.selected {
    background: #FFE4F0;
    border-color: #FF6B8B;
}

/* 库洛米主题选中样式 */
.my-section.purple .multi-option.selected {
    background: #F0E6FF;
    border-color: #C084FC;
}

.custom-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #FF6B8B;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.my-section.purple .custom-checkbox {
    border-color: #C084FC;
}

.custom-checkbox span {
    display: none;
    color: #FF6B8B;
    font-size: 16px;
    font-weight: bold;
}

.my-section.purple .custom-checkbox span {
    color: #C084FC;
}

.multi-option.selected .custom-checkbox span {
    display: block;
}