:root {
    /* Premium Sky Blue Theme Palette */
    --primary-color: #0ea5e9;
    /* Sky-500: Primary Blue */
    --primary-hover: #0284c7;
    /* Sky-600 */
    --secondary-color: #6366f1;
    /* Indigo-500: Secondary Purple */
    --secondary-hover: #4f46e5;
    /* Indigo-600 */
    --danger-color: #ef4444;
    /* Red-500 */
    --success-color: #10b981;
    /* Emerald-500 */

    /* Backgrounds */
    --bg-dark: #0f172a;
    /* Slate-900 */
    --bg-medium: #1e293b;
    /* Slate-800 */
    --bg-light: #334155;
    /* Slate-700 */
    --bg-glass: rgba(15, 23, 42, 0.85);
    /* Dark Glass */

    /* Text */
    --text-light: #f8fafc;
    /* Slate-50 */
    --text-dim: #94a3b8;
    /* Slate-400 */
    --text-dark: #0f172a;
    /* Slate-900 */

    /* Borders & Effects */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-highlight: rgba(14, 165, 233, 0.3);
    --shame-color: #ec4899;
    /* Pink-500 */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --glow-primary: 0 0 15px rgba(14, 165, 233, 0.3);
}

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

body {
    font-family: 'Inter', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-light);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* 只在游戏画面禁用body滚动 */
body.game-active {
    overflow: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    padding-bottom: 40px;
}

.container {
    background: var(--bg-glass);
    border-radius: 24px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    margin: 20px auto;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-highlight), transparent);
}

.game-title {
    font-size: 3.5em;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 40px rgba(14, 165, 233, 0.3);
    font-weight: 800;
    letter-spacing: -1px;
}

.game-subtitle {
    text-align: center;
    margin-bottom: 50px;
    color: var(--text-dim);
    font-size: 1.1em;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    width: 100%;
    margin-top: 15px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #0f172a;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
    width: auto;
    margin: 0 5px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-dim);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-light);
    font-size: 1em;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    background: rgba(15, 23, 42, 0.8);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #9ca3af;
    font-size: 0.85em;
}

.role-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.role-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.role-card:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: var(--glow-primary);
}

.role-card.selected {
    border-color: var(--primary-color);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: var(--glow-primary);
}

.role-card h3 {
    margin-bottom: 10px;
    color: var(--text-light);
    font-size: 1.2em;
}

.role-card.selected h3 {
    color: var(--primary-color);
}

/* 遊戲畫面 */
#game-screen.active {
    display: flex;
    flex-direction: column;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    align-items: stretch;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
}

.status-bar {
    background: rgba(15, 23, 42, 0.9);
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    height: 80px;
    flex: 0 0 80px;
    z-index: 100;
    backdrop-filter: blur(10px);
}

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

.player-name {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--text-light);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.player-role {
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    border: 1px solid rgba(14, 165, 233, 0.2);
    font-weight: 600;
}

.stats {
    flex: 1;
    max-width: 300px;
    margin: 0 20px;
}

.game-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.auto-save-indicator {
    font-size: 0.9em;
    color: #34d399;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: 15px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.auto-save-indicator.saving {
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.2);
    border-color: rgba(14, 165, 233, 0.3);
    animation: pulse 1s infinite;
}

.stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    min-width: 60px;
    font-size: 0.9em;
}

.stat-bar {
    flex: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    transition: width 0.5s;
    border-radius: 10px;
}

.shame-fill {
    background: linear-gradient(90deg, var(--shame-color), #f472b6);
}

.stat-value {
    min-width: 30px;
    text-align: right;
    font-weight: bold;
}

.game-content {
    display: grid;
    grid-template-columns: 250px 1fr 300px;
    gap: 0;
    overflow: hidden;
    height: calc(100vh - 70px);
    position: relative;
}

.sidebar,
.sidebar-right {
    background: rgba(15, 23, 42, 0.6);
    padding: 20px;
    overflow-y: scroll !important;
    overflow-x: hidden;
    border-right: 1px solid var(--border-color);
    height: 100%;
    -webkit-overflow-scrolling: touch;
    z-index: 5;
    position: relative;
    pointer-events: auto;
    backdrop-filter: blur(10px);
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.location-panel,
.npc-panel {
    margin-bottom: 30px;
    pointer-events: auto;
    position: relative;
    z-index: 10;
}

.location-panel h3,
.npc-panel h3,
.npc-detail h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.current-location {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(30, 41, 59, 0.8));
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.npc-item {
    background: rgba(30, 41, 59, 0.4);
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    position: relative;
    z-index: 10;
    pointer-events: auto;
    margin-bottom: 8px;
}

.npc-item:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: var(--primary-color);
    transform: translateX(5px);
}

.npc-item.active {
    border-color: var(--primary-color);
    background: rgba(14, 165, 233, 0.1);
    box-shadow: var(--glow-primary);
}

.npc-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-light);
}

.npc-affection {
    font-size: 0.8em;
    color: var(--primary-color);
    font-weight: 500;
}

.main-area {
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.3);
    height: 100%;
    overflow: hidden;
    position: relative;
    z-index: 0;
}

.chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: scroll;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
}

.welcome-message h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.message {
    margin-bottom: 24px;
    padding: 18px 24px;
    border-radius: 18px;
    max-width: 85%;
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-sm);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 流式输出样式 */
.message.streaming .message-content {
    position: relative;
}

.message.streaming .message-content::after {
    content: '▊';
    animation: blink 1s infinite;
    margin-left: 2px;
    color: var(--primary-color);
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

.typing-indicator {
    color: #9ca3af;
    font-style: italic;
}

/* 思考过程样式 */
.thinking-process {
    background: rgba(14, 165, 233, 0.15);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    border-left: 4px solid #0ea5e9;
    overflow: hidden;
    transition: opacity 0.5s, max-height 0.5s;
    max-height: 300px;
    overflow-y: auto;
}

.thinking-process::before {
    content: '💭 AI思考过程';
    display: block;
    color: #0ea5e9;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.thinking-content {
    color: #d1d5db;
    font-size: 0.85em;
    font-style: italic;
    line-height: 1.5;
}

.message.system {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    margin: 30px auto;
    max-width: 90%;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9em;
}

.message.ai {
    background: rgba(30, 41, 59, 0.8);
    border-bottom-left-radius: 4px;
    margin-right: auto;
    border: 1px solid rgba(14, 165, 233, 0.2);
    color: var(--text-light);
}

.message.player {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(2, 132, 199, 0.15));
    border-bottom-right-radius: 4px;
    margin-left: auto;
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: var(--text-light);
}

.message-header {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.9em;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.message.ai .message-header {
    color: var(--secondary-color);
}

.message.player .message-header {
    color: var(--primary-color);
}

.options-container {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    max-height: 200px;
    overflow-y: auto;
    flex: 0 0 auto;
    background: rgba(15, 23, 42, 0.95);
    position: relative;
    z-index: 0;
    backdrop-filter: blur(20px);
    transition: all 0.3s ease;
}

.options-container.collapsed {
    max-height: 0;
    padding: 0;
    border-top: none;
    overflow: hidden;
    opacity: 0;
}

.options-toggle-btn {
    position: absolute;
    right: 20px;
    top: -45px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
}

.options-toggle-btn:hover {
    background: var(--primary-color);
    color: white;
}

.options-toggle-btn.collapsed svg {
    transform: rotate(180deg);
}

.option-btn {
    flex: 1;
    min-width: 220px;
    padding: 16px 24px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 0.95em;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
}

.option-btn:hover {
    background: rgba(30, 41, 59, 0.9);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.option-btn.平常 {
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

.option-btn.平常:hover {
    border-color: #3b82f6;
    background: rgba(96, 165, 250, 0.25);
}

.option-btn.激进 {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

.option-btn.激进:hover {
    border-color: #ef4444;
    background: rgba(248, 113, 113, 0.25);
}

.option-btn.调皮 {
    border-color: #0ea5e9;
    background: rgba(14, 165, 233, 0.15);
}

.option-btn.调皮:hover {
    border-color: #0284c7;
    background: rgba(14, 165, 233, 0.25);
}

.loading-options {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-style: italic;
}

.loading-options small {
    display: block;
    margin-top: 8px;
    font-size: 0.85em;
    color: #6b7280;
}

/* 选项槽位 */
.option-slot {
    flex: 1;
    min-width: 200px;
    margin-bottom: 10px;
}

.option-generating {
    padding: 15px 20px;
    background: rgba(14, 165, 233, 0.2);
    border: 2px solid #0ea5e9;
    border-radius: 10px;
    text-align: center;
    color: #0ea5e9;
    font-weight: bold;
}

.option-pending {
    padding: 15px 20px;
    background: rgba(107, 114, 128, 0.1);
    border: 2px dashed #6b7280;
    border-radius: 10px;
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

/* 选项流式生成中的样式 */
.option-streaming {
    opacity: 0.9;
    pointer-events: none;
    animation: optionPulse 1s infinite;
}

@keyframes optionPulse {

    0%,
    100% {
        opacity: 0.9;
    }

    50% {
        opacity: 1;
    }
}

/* 右侧滑入动画 */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* 新手引导（指向右侧菜单按钮） */
.newbie-guide {
    position: fixed;
    right: 90px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: guideFloat 2s infinite;
}

@keyframes guideFloat {

    0%,
    100% {
        transform: translateY(-50%) translateX(0);
        right: 90px;
    }

    50% {
        transform: translateY(-50%) translateX(-5px);
        right: 95px;
    }
}

.guide-arrow {
    font-size: 2.5em;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(14, 165, 233, 0.8);
    animation: arrowBlink 1.5s infinite;
    line-height: 1;
    margin-left: 5px;
}

@keyframes arrowBlink {

    0%,
    100% {
        opacity: 1;
        transform: translateX(0);
    }

    50% {
        opacity: 0.7;
        transform: translateX(5px);
    }
}

.guide-text {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    padding: 12px 18px;
    border-radius: 10px;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
    animation: guidePulse 1.5s infinite;
    white-space: nowrap;
    font-size: 0.95em;
}

@keyframes guidePulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(99, 102, 241, 0.7);
    }
}

.guide-text small {
    display: block;
    margin-top: 3px;
    font-weight: normal;
    font-size: 0.8em;
    opacity: 0.95;
}

/* 首次NPC选择样式优化 */
.first-npc-modal-bg {
    background: transparent !important;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 80px;
}

.first-npc-modal {
    max-width: 420px;
    width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideInRight 0.5s ease-out;
    position: relative;
}

.loading-dots::after {
    content: '...';
    animation: loadingDots 1.5s infinite;
}

@keyframes loadingDots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

.punishment-warning {
    text-align: center;
    padding: 20px;
    color: #f87171;
    font-weight: bold;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 2px solid rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {

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

    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn.disabled:hover,
.btn:disabled:hover {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    transform: none !important;
}

.input-area {
    padding: 15px 20px;
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: 10px;
    flex: 0 0 auto;
    background: rgba(30, 27, 75, 0.95);
    position: relative;
    z-index: 0;
    align-items: flex-start;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.input-area textarea {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: rgba(30, 27, 75, 0.5);
    color: var(--text-light);
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
}

.input-area textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(30, 27, 75, 0.7);
}

.input-area input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: rgba(30, 27, 75, 0.5);
    color: var(--text-light);
    font-size: 1em;
}

.btn-send {
    width: 100%;
    padding: 10px 20px;
    margin: 0;
}

.btn-generate-options {
    padding: 10px 16px;
    font-size: 0.9em;
    width: auto;
    white-space: nowrap;
    min-width: 120px;
    margin: 0;
    background: rgba(139, 92, 246, 0.3);
    border: 2px solid var(--secondary-color);
    color: var(--text-light);
}

.btn-generate-options:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.5);
    border-color: var(--primary-color);
}

.btn-generate-options:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.npc-detail {
    background: rgba(76, 29, 149, 0.3);
    padding: 20px;
    border-radius: 12px;
    position: relative;
    /* 确保不脱离文档流 */
    z-index: 1;
}

.npc-detail .placeholder {
    color: #9ca3af;
    text-align: center;
    padding: 20px;
}

.npc-detail-content {
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.npc-avatar {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4em;
}

.npc-info-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.npc-info-label {
    font-size: 0.9em;
    color: #9ca3af;
    margin-bottom: 5px;
}

.npc-info-value {
    font-weight: bold;
}

.affection-bar {
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

.affection-fill {
    height: 100%;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    border-radius: 5px;
    transition: width 0.5s ease-in-out;
}

.no-affection-hint {
    margin-top: 5px;
    font-size: 0.85em;
    color: #6b7280;
    font-style: italic;
}

.npc-affection-display {
    transition: color 0.3s;
}

.npc-item .affection-value {
    transition: all 0.3s;
    display: inline-block;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-medium);
    padding: 40px;
    border-radius: 20px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    border: 2px solid var(--border-color);
    box-sizing: border-box;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    text-align: center;
}

.location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.location-card {
    background: rgba(76, 29, 149, 0.4);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.location-card:hover {
    background: rgba(76, 29, 149, 0.6);
    border-color: var(--primary-color);
    transform: translateY(-5px);
}

.location-card h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.location-card p {
    font-size: 0.9em;
    color: #9ca3af;
}

/* NPC资料网格 */
.npc-profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    overflow: visible;
    width: 100%;
}

.npc-profile-card {
    background: rgba(76, 29, 149, 0.4);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    transition: all 0.3s;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.npc-profile-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.npc-profile-card.selectable {
    cursor: pointer;
}

.npc-profile-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    margin: 0 auto 15px;
    font-weight: bold;
}

.npc-profile-info {
    text-align: center;
}

.npc-profile-name {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.npc-profile-detail {
    font-size: 0.85em;
    color: #c7d2fe;
    margin: 6px 0;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.npc-profile-detail:last-child {
    border-bottom: none;
}

.npc-profile-detail strong {
    color: #a5b4fc;
    margin-right: 5px;
}

/* 移动端优化 */
@media (max-width: 768px) {
    .npc-profiles-grid {
        grid-template-columns: 1fr;
    }

    .npc-profile-card {
        padding: 15px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    /* 移动端：首次NPC选择居中 */
    .first-npc-modal-bg {
        padding-right: 0 !important;
        justify-content: center !important;
    }

    .first-npc-modal {
        max-width: 90% !important;
        width: 90% !important;
    }

    /* 移动端：引导提示调整 */
    .newbie-guide {
        right: 80px;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: row;
    }

    @keyframes guideFloat {

        0%,
        100% {
            transform: translateY(-50%) translateX(0);
            right: 80px;
        }

        50% {
            transform: translateY(-50%) translateX(-5px);
            right: 85px;
        }
    }

    .guide-arrow {
        font-size: 2em;
    }

    .guide-text {
        font-size: 0.85em;
        padding: 10px 15px;
    }
}

/* 載入動畫 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 滾動條美化 */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* 移动端菜单按钮（改为右侧中心） */
.mobile-menu-btn {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    border: 3px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    z-index: 1001;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    pointer-events: auto;
}

.mobile-menu-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.7);
}

.mobile-menu-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.menu-icon {
    display: block;
    line-height: 1;
}

/* 移动端遮罩层 - 完全禁用 */
.mobile-overlay {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

/* 即使有active类也不显示（桌面端） */
@media (min-width: 769px) {

    .mobile-overlay,
    .mobile-overlay.active {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* 移动端才显示遮罩层 */
@media (max-width: 768px) {
    .mobile-overlay.active {
        display: block !important;
        pointer-events: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 997;
    }
}

/* 響應式設計 */
@media (max-width: 1200px) {
    .game-content {
        grid-template-columns: 200px 1fr;
    }

    .sidebar-right {
        display: none !important;
    }
}

@media (max-width: 768px) {

    /* 显示移动端菜单按钮 */
    .mobile-menu-btn {
        display: flex;
    }

    #game-screen.active {
        height: 100vh;
        height: -webkit-fill-available;
    }

    .game-content {
        grid-template-columns: 1fr;
    }

    /* 侧边栏默认隐藏，通过类控制显示 */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        z-index: 998;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        pointer-events: auto;
    }

    .sidebar.mobile-active {
        left: 0;
        z-index: 999;
    }

    .status-bar {
        flex-wrap: wrap;
        padding: 10px 15px;
    }

    .player-info {
        width: 100%;
        justify-content: space-between;
        margin-bottom: 8px;
    }

    .stats {
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .game-controls {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 8px;
    }

    .auto-save-indicator {
        font-size: 0.85em;
    }

    /* 优化选项按钮 */
    .options-container {
        flex-direction: column;
        max-height: 180px;
    }

    .option-btn {
        min-width: 100%;
        margin-bottom: 8px;
    }

    /* 优化输入区 */
    .input-area {
        flex-direction: column;
    }

    .input-wrapper {
        width: 100%;
    }

    .input-area textarea {
        width: 100%;
        margin-bottom: 8px;
    }

    .input-area input {
        width: 100%;
        margin-bottom: 8px;
    }

    .input-area .btn-send {
        width: 100%;
    }

    .input-area .btn-generate-options {
        width: 100%;
        min-width: auto;
    }

    /* 优化聊天容器 */
    .chat-container {
        padding: 15px;
    }

    .message {
        max-width: 90%;
        font-size: 0.95em;
    }

    /* 优化NPC列表 */
    .npc-item {
        padding: 10px;
        z-index: 100;
    }

    .sidebar {
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* 优化地点卡片 */
    .location-grid {
        grid-template-columns: 1fr;
    }

    .location-card {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .game-title {
        font-size: 2em;
    }

    .role-selection {
        grid-template-columns: 1fr;
    }

    .status-bar {
        font-size: 0.9em;
    }

    .mobile-menu-btn {
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .mobile-menu-btn:hover {
        transform: translateY(-50%) scale(1.05);
    }

    .mobile-menu-btn:active {
        transform: translateY(-50%) scale(0.95);
    }

    .chat-container {
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .main-area {
        overflow: hidden !important;
    }
}