/* ========== 全局重置与基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", "STZhongsong", "PingFang SC", "Microsoft YaHei", serif;
    background: url('../卡背.png') center center / cover no-repeat fixed;
    color: #86877B;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior-y: contain;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 246, 211, 0.35);
    z-index: -1;
    pointer-events: none;
}

input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

.hidden { display: none !important; }

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
}

input, textarea {
    font-family: inherit;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input, textarea, select {
    font-size: 16px !important;
}

/* ========== 按钮样式（楷体字体，卡背粉色/黄色配色） ========== */
.btn {
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    transition: all 0.2s ease;
    min-height: 48px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.3;
    touch-action: manipulation;
}

.btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* 主按钮：卡背粉色 #FDC8D5 渐变 */
.btn-primary {
    background: linear-gradient(135deg, #FDC8D5 0%, #F8A8B8 100%);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(253, 200, 213, 0.6);
    background: linear-gradient(135deg, #FDC8D5 0%, #F4909F 100%);
}

/* 黄色按钮：淡柠檬黄 */
.btn-yellow {
    background: linear-gradient(135deg, #FFF176 0%, #FFE64D 100%);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.3);
}

.btn-yellow:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 241, 118, 0.6);
    background: linear-gradient(135deg, #FFF59D 0%, #FFE64D 100%);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.55);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.3);
    backdrop-filter: blur(8px);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.75);
}

/* 危险按钮：淡红色（解散房间） */
.btn-danger {
    background: linear-gradient(135deg, #FFCDD2 0%, #EF9A9A 100%);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 154, 154, 0.5);
    background: linear-gradient(135deg, #FFCDD2 0%, #E57373 100%);
}

/* 小按钮 */
.btn-small {
    padding: 8px 18px;
    font-size: 13px;
    min-height: 36px;
    min-width: 36px;
}

.btn-large {
    padding: 14px 32px;
    font-size: 16px;
}

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

/* ========== 使用说明按钮（卡背粉色） ========== */
.instructions-btn {
    position: fixed;
    top: 15px;
    top: calc(15px + env(safe-area-inset-top));
    right: 15px;
    z-index: 900;
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    background: linear-gradient(135deg, #FDC8D5 0%, #F8A8B8 100%);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.3);
    padding: 10px 18px;
    border-radius: 22px;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(253, 200, 213, 0.5);
    min-height: 40px;
}

.instructions-btn:hover {
    background: linear-gradient(135deg, #FDC8D5 0%, #F4909F 100%);
    box-shadow: 0 4px 12px rgba(253, 200, 213, 0.7);
}

.instructions-btn:active {
    transform: scale(0.95);
}

/* ========== 弹窗通用样式 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(134, 135, 123, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ========== 使用说明弹窗（卡背风格：米黄底+楷体+灰绿文字） ========== */
.instructions-modal {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    background: linear-gradient(135deg, #FDF6D3 0%, #FDC8D5 100%);
    border: 2px solid #86877B;
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(134, 135, 123, 0.4);
}

.instructions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(134, 135, 123, 0.3);
}

.instructions-header h2 {
    font-size: 22px;
    color: #86877B;
    letter-spacing: 4px;
}

.close-btn {
    background: linear-gradient(135deg, #FFB81C 0%, #E5A015 100%);
    color: #86877B;
    font-size: 22px;
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 50%;
    border: 1px solid rgba(134, 135, 123, 0.3);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: linear-gradient(135deg, #FFB81C 0%, #CC8C10 100%);
}

.instructions-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.instructions-section {
    margin-bottom: 20px;
}

.instructions-section h3 {
    color: #86877B;
    font-size: 17px;
    margin-bottom: 8px;
    letter-spacing: 2px;
    border-left: 4px solid #86877B;
    padding-left: 8px;
}

.instructions-section p {
    color: #86877B;
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 4px;
}

.instructions-section p strong {
    color: #86877B;
    font-weight: bold;
}

/* ========== 屏幕切换 ========== */
.screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
}

/* ========== 主页（直接使用卡背图片作背景，楷体灰绿文字） ========== */
#homeScreen {
    background: url('../卡背.png') center center / cover no-repeat;
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* 仅在卡背上方叠加极淡的米黄遮罩，保留卡背原图同时保证文字可读 */
#homeScreen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 246, 211, 0.35);
    z-index: 0;
}

#homeScreen > * {
    position: relative;
    z-index: 1;
}

.home-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

/* 主标题：卡背同款灰绿色 #86877B，楷体书法风 */
.game-title {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    font-size: 72px;
    font-weight: bold;
    color: #86877B;
    letter-spacing: 16px;
    text-shadow: 0 2px 6px rgba(255, 255, 255, 0.6), 0 0 2px #fff;
    margin-bottom: 10px;
}

.game-subtitle {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    color: #86877B;
    font-size: 18px;
    margin-bottom: 50px;
    letter-spacing: 4px;
}

.home-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    background: rgba(255, 255, 255, 0.55);
    padding: 22px;
    border-radius: 12px;
    border: 1px solid rgba(134, 135, 123, 0.3);
    backdrop-filter: blur(8px);
}

.join-form input {
    padding: 12px 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid rgba(134, 135, 123, 0.3);
    color: #86877B;
    font-size: 15px;
    font-family: inherit;
    text-align: center;
}

.join-form input::placeholder {
    color: #b5b6a8;
}

.join-form input:focus {
    border-color: #86877B;
    box-shadow: 0 0 0 3px rgba(134, 135, 123, 0.15);
}

/* ========== 昵称输入页面 ========== */
.nickname-page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 24px;
}

.nickname-page-container .game-title {
    color: #86877B;
    letter-spacing: 12px;
    text-shadow: 2px 2px 4px rgba(134, 135, 123, 0.2);
    font-size: 48px;
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
}

.nickname-page-container .game-subtitle {
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
    color: #86877B;
    font-size: 18px;
    letter-spacing: 4px;
    opacity: 0.8;
}

.nickname-page-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.nickname-page-form input {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    background: #fff;
    border: 2px solid rgba(134, 135, 123, 0.4);
    color: #86877B;
    font-size: 16px;
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
    text-align: center;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.nickname-page-form input::placeholder {
    color: #b5b6a8;
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
}

.nickname-page-form input:focus {
    border-color: #86877B;
    box-shadow: 0 0 0 3px rgba(134, 135, 123, 0.15);
    outline: none;
}

.nickname-page-form .btn-large {
    width: 100%;
    padding: 14px 36px;
    font-size: 18px;
}

.nickname-page-form .btn-back {
    background: rgba(134, 135, 123, 0.12);
    color: #86877B;
    padding: 12px 36px;
    font-size: 15px;
}

/* ========== 大厅 ========== */
.lobby-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.55);
    padding: 16px 20px;
    border-radius: 12px;
    border: 1px solid rgba(134, 135, 123, 0.25);
    backdrop-filter: blur(8px);
}

.room-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.label {
    color: #86877B;
    font-size: 14px;
}

.room-code {
    font-size: 22px;
    font-weight: bold;
    color: #e94560;
    letter-spacing: 2px;
}

.btn-copy {
    margin-left: 8px;
    padding: 3px 10px;
    font-size: 12px;
    font-family: inherit;
    color: #86877B;
    background: rgba(134, 135, 123, 0.12);
    border: 1px solid rgba(134, 135, 123, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-copy:hover {
    background: rgba(134, 135, 123, 0.25);
    color: #5a5b4f;
}

.btn-copy:active {
    background: rgba(134, 135, 123, 0.35);
    transform: scale(0.96);
}

.player-count {
    color: #86877B;
    font-size: 14px;
}

.players-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.player-card {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(134, 135, 123, 0.25);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
    color: #86877B;
}

.player-card.is-host {
    border-color: #e94560;
    background: rgba(253, 200, 213, 0.45);
}

.player-card .player-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    color: #86877B;
}

.player-card .player-role {
    font-size: 12px;
    color: #86877B;
    opacity: 0.8;
}

.host-badge {
    display: inline-block;
    background: #e94560;
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ========== 准备状态标识 ========== */
.ready-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.ready-badge.ready-yes {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.ready-badge.ready-no {
    background: rgba(134, 135, 123, 0.1);
    color: #999;
    border: 1px solid rgba(134, 135, 123, 0.2);
}

/* ========== 准备按钮 ========== */
.btn-ready {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 7px 0;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-do-ready {
    background: linear-gradient(135deg, #e94560, #d63c50);
    color: #fff;
}

.btn-do-ready:hover {
    background: linear-gradient(135deg, #d63c50, #c43346);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(233, 69, 96, 0.3);
}

.btn-cancel-ready {
    background: rgba(134, 135, 123, 0.15);
    color: #86877B;
}

.btn-cancel-ready:hover {
    background: rgba(134, 135, 123, 0.25);
}

/* ========== 开始游戏按钮禁用态 ========== */
#startGameBtn.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ========== 房主语音聊天室模块 ========== */
.host-module {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(253, 200, 213, 0.7);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
}

.host-module h3 {
    color: #e94560;
    font-size: 16px;
    margin-bottom: 8px;
}

.module-tip {
    color: #86877B;
    font-size: 13px;
    margin-bottom: 12px;
    opacity: 0.9;
}

.host-module textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(134, 135, 123, 0.3);
    color: #86877B;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.host-module textarea::placeholder {
    color: #b5b6a8;
}

.host-module textarea:focus {
    border-color: #86877B;
    box-shadow: 0 0 0 3px rgba(134, 135, 123, 0.15);
    outline: none;
}

.image-upload-area {
    margin-top: 12px;
}

.upload-label {
    display: inline-block;
    padding: 10px 18px;
    background: rgba(253, 246, 211, 0.6);
    border: 1px dashed rgba(134, 135, 123, 0.5);
    border-radius: 8px;
    color: #86877B;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-label:hover {
    background: rgba(253, 246, 211, 0.85);
}

.image-preview {
    margin-top: 10px;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid rgba(134, 135, 123, 0.25);
}

.host-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

/* ========== 历史记录 ========== */
.history-area {
    background: rgba(255, 255, 255, 0.55);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(134, 135, 123, 0.25);
    backdrop-filter: blur(8px);
}

.history-area h3 {
    color: #e94560;
    font-size: 15px;
    margin-bottom: 12px;
}

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

.history-item {
    background: rgba(253, 246, 211, 0.55);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    border: 1px solid rgba(134, 135, 123, 0.15);
}

.history-item .history-meta {
    color: #e94560;
    font-size: 12px;
    margin-bottom: 4px;
}

.history-item .history-content {
    color: #86877B;
    word-break: break-all;
}

.history-item img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 6px;
    margin-top: 6px;
    border: 1px solid rgba(134, 135, 123, 0.25);
}

.start-area {
    text-align: center;
    padding: 20px 0;
}

.room-actions-bottom {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px 0 8px;
    border-top: 1px solid rgba(134, 135, 123, 0.2);
    margin-top: 8px;
}

/* ========== 游戏界面 ========== */
/* 语音室悬浮栏显示时，游戏界面内容适当下移以避开覆盖 */
#gameScreen.banner-visible {
    padding-top: 50px;
}

/* 底部身份确认栏显示时，避免内容被遮挡 */
#gameScreen.confirm-visible {
    padding-bottom: 100px;
}
.game-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(134, 135, 123, 0.25);
    margin-bottom: 16px;
    border-radius: 12px;
    gap: 8px;
    flex-wrap: wrap;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.room-info {
    flex: 1;
    min-width: 0;
    color: #86877B;
}

.phase-label {
    font-size: 16px;
    font-weight: bold;
    color: #e94560;
    white-space: nowrap;
}

.countdown {
    font-size: 18px;
    font-weight: bold;
    color: #c89800;
    background: rgba(255, 241, 118, 0.45);
    padding: 6px 14px;
    border-radius: 8px;
    white-space: nowrap;
    border: 1px solid rgba(255, 192, 0, 0.4);
}

/* ========== 存活玩家列表 ========== */
.alive-players-section {
    margin-bottom: 20px;
}

.alive-players-section h4 {
    color: #86877B;
    font-size: 13px;
    margin-bottom: 10px;
    opacity: 0.9;
}

.alive-players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
}

.alive-player-item {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(134, 135, 123, 0.25);
    border-radius: 10px;
    padding: 12px 6px;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    backdrop-filter: blur(8px);
    color: #86877B;
}

.alive-player-item:active {
    transform: scale(0.96);
}

.alive-player-item.selected {
    border-color: #e94560;
    background: rgba(253, 200, 213, 0.5);
    box-shadow: 0 0 10px rgba(233, 69, 96, 0.25);
    color: #86877B;
}

.alive-player-item.dead {
    opacity: 0.45;
    filter: grayscale(100%);
    cursor: not-allowed;
    pointer-events: none;
    text-decoration: line-through;
}
.alive-player-item.dead:active {
    transform: none;
}

.alive-player-item.dead::after {
    content: '已离场';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #e94560;
    font-size: 11px;
    font-weight: bold;
    filter: none;
    pointer-events: none;
    z-index: 1;
}

/* 离场玩家遗言阶段：临时取消置灰，恢复交互 */
.alive-player-item.dead.eliminated-speaking {
    opacity: 1;
    filter: none;
    cursor: default;
    pointer-events: auto;
    text-decoration: none;
    background: #2a2d36;
}
.alive-player-item.dead.eliminated-speaking::after {
    opacity: 0.7;
}

.alive-player-item .mute-status {
    display: block;
    font-size: 10px;
    color: #86877B;
    opacity: 0.85;
    margin-top: 4px;
}

.alive-player-item .mute-status.muted {
    color: #c89800;
    opacity: 1;
}

/* ========== 身份卡牌 3D 翻转动画 ========== */
.card-area {
    display: flex;
    justify-content: center;
    margin: 24px 0;
    padding: 0 8px;
}

.card-container {
    perspective: 1200px;
    width: 260px;
    height: 380px;
    max-width: 100%;
}

.identity-card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 1s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
    touch-action: manipulation;
}

.identity-card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 40px rgba(134, 135, 123, 0.45);
    border: 2px solid #e94560;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-back {
    background: linear-gradient(135deg, #FDF6D3 0%, #FDC8D5 100%);
}

.card-front {
    background: linear-gradient(135deg, #FDF6D3 0%, #F8E4E9 100%);
    transform: rotateY(180deg);
    padding: 8px;
    justify-content: flex-start;
    border: 2px solid #86877B;
}

.card-front .card-img {
    height: 85%;
    border-radius: 8px 8px 0 0;
    border: 1px solid rgba(134, 135, 123, 0.3);
}

.card-role-faction {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 10px;
    margin: 8px 0 4px;
}

.card-role-faction.villain {
    background: rgba(233, 69, 96, 0.25);
    color: #c83a52;
    border: 1px solid rgba(233, 69, 96, 0.35);
}

.card-role-faction.good {
    background: rgba(72, 187, 120, 0.25);
    color: #4a9b6e;
    border: 1px solid rgba(72, 187, 120, 0.35);
}

.card-role-skill {
    font-size: 11px;
    color: #86877B;
    text-align: center;
    line-height: 1.5;
    padding: 0 10px 8px;
}

/* ========== 语音室悬浮信息栏 ========== */
.voice-room-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1490;
    /* 留白区域 + 半透明背景，不遮挡下方核心内容 */
    background: rgba(253, 246, 211, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(233, 69, 96, 0.25);
    padding: 10px 16px;
    padding-top: max(10px, env(safe-area-inset-top));
    animation: bannerSlideDown 0.35s ease;
}

@keyframes bannerSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.banner-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 720px;
    margin: 0 auto;
}

.banner-label {
    font-size: 12px;
    color: #e94560;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 2px 10px;
    background: rgba(233, 69, 96, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.banner-body {
    flex: 1;
    min-width: 0;
    line-height: 1.6;
}

.banner-text-content {
    font-size: 13px;
    color: #5a594f;
    word-break: break-all;
}

.banner-image-content {
    display: block;
    max-width: 100%;
    max-height: 70px;
    width: auto;
    border-radius: 6px;
    margin-top: 6px;
    border: 1px solid rgba(134, 135, 123, 0.25);
}

.banner-empty-hint {
    font-size: 12px;
    color: #b0afaa;
    font-style: italic;
}

/* ========== 身份确认区域（页面底部固定栏） ========== */
.identity-confirm-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1490;
    background: rgba(26, 24, 20, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(233, 69, 96, 0.25);
    padding: 14px 16px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    animation: bannerSlideUp 0.3s ease;
}

@keyframes bannerSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.identity-confirm-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 420px;
    margin: 0 auto;
}

.identity-confirm-status {
    font-size: 14px;
    color: #c2c0b5;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.identity-confirm-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: center;
    max-width: 380px;
    padding: 4px 0;
}

.identity-player-status {
    font-size: 13px;
    color: #a09c90;
    padding: 3px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    white-space: nowrap;
    transition: all 0.3s;
}

.identity-player-status.ready {
    color: #4CAF50;
    border-color: rgba(76,175,80,0.25);
    background: rgba(76,175,80,0.08);
}

.confirm-ready-btn {
    width: 100%;
    max-width: 280px;
    padding: 13px 0;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 1px;
    border-radius: 28px;
    background: linear-gradient(135deg, #e94560, #c72d4a);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.35);
    transition: transform 0.18s, box-shadow 0.18s, opacity 0.2s;
    cursor: pointer;
}

.confirm-ready-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.2);
}

.confirm-ready-btn.confirmed {
    background: #666;
    box-shadow: none;
    pointer-events: none;
    opacity: 0.7;
}

/* ========== 技能详情弹窗（卡背背景卡片布局） ========== */
#skillDetailOverlay {
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.skill-detail-card {
    position: relative;
    width: 280px;
    max-width: 94vw;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(134, 135, 123, 0.5);
    border: 2px solid #86877B;
    animation: skillCardIn 0.3s ease;
}

@keyframes skillCardIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.skill-detail-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

.skill-detail-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: linear-gradient(
        135deg,
        rgba(253, 246, 211, 0.88) 0%,
        rgba(253, 200, 213, 0.82) 100%
    );
}

.skill-detail-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px 28px;
}

.skill-detail-img {
    width: 160px;
    height: 230px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(134, 135, 123, 0.4);
    box-shadow: 0 4px 16px rgba(134, 135, 123, 0.3);
    margin-bottom: 16px;
}

.skill-detail-faction {
    font-size: 15px;
    padding: 6px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.skill-detail-type {
    font-size: 14px;
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    color: #86877B;
    letter-spacing: 4px;
    margin: 4px 0 14px;
    opacity: 0.85;
}

.skill-detail-desc {
    font-size: 13px;
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    color: #5a5b4f;
    text-align: center;
    line-height: 1.8;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 10px;
    border: 1px solid rgba(134, 135, 123, 0.2);
    max-width: 100%;
}

.skill-detail-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(134, 135, 123, 0.35);
    background: rgba(255, 255, 255, 0.7);
    color: #86877B;
    font-size: 16px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    backdrop-filter: blur(4px);
}

.skill-detail-close:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.1);
}

/* ========== 行动面板 ========== */
.action-panel {
    background: rgba(255, 255, 255, 0.55);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
    min-height: 60px;
    border: 1px solid rgba(134, 135, 123, 0.25);
    backdrop-filter: blur(8px);
}

.action-panel h3 {
    color: #e94560;
    font-size: 15px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.action-targets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.action-btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ========== 偷恋者私聊面板 ========== */
.villain-panel {
    background: rgba(253, 200, 213, 0.35);
    border: 1px solid rgba(233, 69, 96, 0.45);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
}

.villain-panel h3 {
    color: #c83a52;
    font-size: 15px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.warning-text {
    background: rgba(253, 200, 213, 0.55);
    border: 1px solid rgba(233, 69, 96, 0.5);
    color: #c83a52;
    font-size: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: center;
    line-height: 1.5;
}

.chat-messages {
    max-height: 220px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(134, 135, 123, 0.2);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    color: #86877B;
}

.chat-msg {
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.6;
    color: #86877B;
}

.chat-msg .msg-sender {
    color: #e94560;
    font-weight: 500;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.chat-input-row input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(134, 135, 123, 0.3);
    color: #86877B;
    min-height: 48px;
    font-family: inherit;
}

.chat-input-row input::placeholder {
    color: #b5b6a8;
}

.chat-input-row input:focus {
    border-color: #86877B;
    box-shadow: 0 0 0 3px rgba(134, 135, 123, 0.15);
    outline: none;
}

.chat-input-row .btn {
    min-height: 48px;
}

/* ========== 技能按钮 ========== */
.skill-btn {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    background: rgba(253, 246, 211, 0.6);
    color: #86877B;
    border: 1px solid rgba(134, 135, 123, 0.35);
    min-height: 48px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
    touch-action: manipulation;
    transition: all 0.15s ease;
    word-break: break-word;
}

.skill-btn:hover:not(:disabled),
.skill-btn:active:not(:disabled) {
    background: rgba(253, 200, 213, 0.55);
    border-color: #e94560;
}

.skill-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.skill-btn.active {
    background: rgba(253, 200, 213, 0.7);
    border-color: #e94560;
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.25);
    color: #86877B;
}

.skill-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* ========== 弹窗通用 ========== */
.confirm-modal {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    background: linear-gradient(135deg, #FDF6D3 0%, #FDC8D5 100%);
    border: 2px solid #86877B;
    border-radius: 18px;
    padding: 28px 24px;
    text-align: center;
    max-width: 400px;
    width: 92%;
    box-shadow: 0 20px 60px rgba(134, 135, 123, 0.45);
    -webkit-overflow-scrolling: touch;
}

.confirm-text {
    font-size: 18px;
    color: #86877B;
    margin-bottom: 22px;
    line-height: 1.7;
}

.result-text {
    color: #86877B;
    font-size: 14px;
    line-height: 1.8;
    margin: 16px 0;
    text-align: left;
}

.result-text ul {
    margin-top: 8px;
    padding-left: 18px;
}

.result-text li {
    margin-bottom: 4px;
}

/* ========== 投票面板 ========== */
.vote-panel {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(134, 135, 123, 0.25);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 20px;
    backdrop-filter: blur(8px);
}

.vote-panel h3 {
    color: #e94560;
    font-size: 15px;
    margin-bottom: 8px;
    line-height: 1.4;
}

.vote-tip {
    color: #86877B;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.5;
    opacity: 0.9;
}

.vote-targets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

/* ========== 游戏结束面板 ========== */
.game-over-modal {
    font-family: "KaiTi", "STKaiti", "华文楷体", "FangSong", serif;
    background: linear-gradient(135deg, #FDF6D3 0%, #FDC8D5 100%);
    border: 2px solid #86877B;
    border-radius: 18px;
    padding: 24px 20px;
    max-width: 560px;
    width: 92%;
    max-height: 88vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.winner-text {
    font-size: 26px;
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.4;
}

.winner-text.villain-win {
    color: #c83a52;
}

.winner-text.good-win {
    color: #4a9b6e;
}

.game-over-modal h3 {
    color: #86877B;
    font-size: 16px;
    margin-bottom: 12px;
}

.review-list {
    margin-bottom: 22px;
}

.review-item {
    background: rgba(253, 246, 211, 0.55);
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 8px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(134, 135, 123, 0.2);
}

.review-item .review-name {
    color: #86877B;
    flex-shrink: 0;
}

.review-item .review-role {
    color: #86877B;
    opacity: 0.85;
    text-align: right;
    font-size: 13px;
    line-height: 1.4;
}

.review-item.villain .review-role {
    color: #c83a52;
    opacity: 1;
}

.review-item.good .review-role {
    color: #4a9b6e;
    opacity: 1;
}

.game-over-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.game-over-actions .btn {
    flex: 1;
    min-width: 140px;
}

/* ========== 轻量提示 toast ========== */
.toast {
    position: fixed;
    bottom: 30px;
    bottom: calc(30px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #FDC8D5 0%, #F8A8B8 100%);
    color: #86877B;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 15px;
    z-index: 3000;
    box-shadow: 0 6px 18px rgba(134, 135, 123, 0.35);
    border: 1px solid rgba(134, 135, 123, 0.3);
    animation: toastIn 0.3s ease;
    max-width: 85%;
    text-align: center;
    line-height: 1.5;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ========== 响应式：手机适配 ========== */

/* 平板和大手机（≤768px） */
@media (max-width: 768px) {
    .lobby-container { padding: 16px; }
}

/* 中等屏（≤600px）：主页、大厅、卡牌、弹窗统一缩小 */
@media (max-width: 600px) {
    /* —— 全局 —— */
    .screen {
        padding-top: 15px;
        padding-top: calc(15px + env(safe-area-inset-top));
    }

    /* —— 主页 —— */
    .home-container { padding: 24px 16px; max-width: 100%; }
    .game-title {
        font-size: 48px;
        letter-spacing: 8px;
    }
    .game-subtitle {
        font-size: 14px;
        margin-bottom: 32px;
        letter-spacing: 3px;
    }
    .home-actions { gap: 16px; }
    .join-form { padding: 16px; }
    .join-form input { padding: 14px 14px; font-size: 16px; } /* 16px 防 iOS 缩放 */
    .btn { padding: 14px 18px; font-size: 15px; }
    .btn-large { padding: 16px 28px; font-size: 16px; }

    /* —— 使用说明按钮 —— */
    .instructions-btn {
        top: 10px;
        top: calc(10px + env(safe-area-inset-top));
        right: 10px;
        padding: 8px 14px;
        font-size: 12px;
        min-height: 36px;
    }

    /* —— 游戏规则弹窗：近乎全屏 —— */
    .instructions-modal {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        max-height: calc(90vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        border-radius: 14px;
    }
    .instructions-header { padding: 16px 18px; }
    .instructions-header h2 { font-size: 18px; letter-spacing: 2px; }
    .instructions-body { padding: 14px 18px; }
    .instructions-section { margin-bottom: 14px; }
    .instructions-section h3 { font-size: 15px; }
    .instructions-section p { font-size: 13px; line-height: 1.8; }
    .close-btn { width: 34px; height: 34px; font-size: 20px; }

    /* —— 昵称页面 —— */
    .nickname-page-form { max-width: 90%; }
    .nickname-page-container .game-title { font-size: 36px; }

    /* —— 大厅 —— */
    .lobby-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .lobby-container { padding: 14px; }
    .lobby-header { padding: 14px 16px; margin-bottom: 16px; }
    .room-code { font-size: 20px; }
    .player-count { font-size: 13px; }

    /* —— 卡牌 —— */
    .card-area { margin: 20px 0; }
    .card-container {
        width: 200px;
        height: 290px;
    }
    .card-role-faction { font-size: 12px; padding: 4px 10px; }
    .card-role-skill { font-size: 10px; }

    /* —— 技能详情弹窗 —— */
    .skill-detail-card { width: 260px; }
    .skill-detail-img { width: 140px; height: 200px; }
    .skill-detail-faction { font-size: 14px; }
    .skill-detail-desc { font-size: 12px; padding: 10px 14px; }

    /* —— 大厅玩家列表：双列 —— */
    .players-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .player-card { padding: 12px 8px; }

    /* —— 准备按钮—— */
    .btn-ready { font-size: 12px; padding: 6px 0; }
    .ready-badge { font-size: 10px; padding: 2px 6px; }

    /* —— 身份确认 —— */
    .identity-confirm-bar { max-width: 360px; }
    .confirm-ready-btn { max-width: 240px; font-size: 15px; }
    .identity-confirm-status { font-size: 13px; }
    /* —— 语音室悬浮栏 —— */
    .banner-text-content { font-size: 12px; }

    /* —— 游戏顶栏 —— */
    .game-topbar {
        padding: 12px 14px;
        gap: 10px;
    }
    .room-info { font-size: 13px; }
    .phase-label { font-size: 15px; }
    .countdown { font-size: 16px; padding: 5px 12px; }

    /* —— 存活玩家 —— */
    .alive-players-grid { gap: 8px; }
    .alive-player-item { padding: 10px 4px; font-size: 12px; min-height: 48px; }
    .alive-player-item .mute-status { font-size: 9px; }

    /* —— 聊天/历史区域 —— */
    .history-area { padding: 12px; margin-bottom: 14px; }
    .history-area h3 { font-size: 14px; }
    .history-item { font-size: 12px; padding: 10px 12px; }
    .image-preview img { max-height: 150px; }
    .host-module { padding: 16px; }
    .host-module h3 { font-size: 15px; }
    .host-module textarea { font-size: 14px; min-height: 72px; }
    .host-actions { flex-direction: column; }
    .host-actions .btn { flex: 1; }

    /* —— 行动面板 —— */
    .action-panel { padding: 14px; }
    .action-panel h3 { font-size: 14px; }
    .action-targets { gap: 8px; }

    /* —— 技能/投票按钮加大触摸区 —— */
    .skill-btn, .vote-btn {
        padding: 12px 12px;
        font-size: 13px;
        min-height: 46px;
    }
    .vote-panel { padding: 14px; margin-bottom: 14px; }
    .vote-panel h3 { font-size: 14px; }
    .vote-tip { font-size: 12px; }

    /* —— 私聊面板 —— */
    .villain-panel { padding: 14px; }
    .chat-messages { max-height: 200px; }
    .chat-input-row { flex-direction: column; gap: 10px; }
    .chat-input-row input { width: 100%; }
    .chat-input-row .btn { width: 100%; }

    /* —— 游戏结束面板 —— */
    .game-over-modal { padding: 20px 16px; }
    .winner-text { font-size: 22px; }
    .review-item { padding: 10px 12px; font-size: 13px; flex-direction: column; align-items: flex-start; gap: 6px; }
    .review-item .review-role { text-align: left; }

    /* —— 确认弹窗 —— */
    .confirm-modal {
        max-width: 94%;
        padding: 22px 18px;
    }
    .confirm-text { font-size: 16px; margin-bottom: 18px; }
    .result-text { font-size: 13px; }

    /* —— Toast —— */
    .toast {
        padding: 12px 18px;
        font-size: 14px;
        bottom: 24px;
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* 小屏手机（≤400px）：iPhone SE/mini 等更紧凑 */
@media (max-width: 400px) {
    .home-container { padding: 20px 14px; }
    .game-title {
        font-size: 40px;
        letter-spacing: 6px;
    }
    .game-subtitle {
        font-size: 12px;
        margin-bottom: 24px;
        letter-spacing: 2px;
    }
    .join-form { padding: 14px; }
    .btn { padding: 12px 16px; font-size: 14px; }
    .btn-large { padding: 14px 24px; font-size: 15px; }
    .instructions-btn {
        top: 8px;
        top: calc(8px + env(safe-area-inset-top));
        right: 8px;
        padding: 6px 12px;
        font-size: 11px;
        min-height: 34px;
    }
    .card-container {
        width: 170px;
        height: 248px;
    }
    .card-role-faction { font-size: 11px; padding: 3px 8px; }
    .card-role-skill { font-size: 10px; line-height: 1.4; }
    .skill-detail-card { width: 240px; }
    .skill-detail-img { width: 120px; height: 175px; }
    .btn-ready { font-size: 11px; padding: 5px 0; }
    .ready-badge { font-size: 9px; padding: 1px 5px; }
    .identity-confirm-area { padding: 12px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .identity-confirm-bar { max-width: 320px; }
    .confirm-ready-btn { max-width: 220px; font-size: 14px; padding: 11px 0; }
    .identity-confirm-status { font-size: 12px; }
    .banner-text-content { font-size: 11px; }
    .banner-label { font-size: 11px; padding: 1px 8px; }
    .skill-detail-desc { font-size: 11px; }
    .players-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .lobby-container { padding: 12px; }
    .confirm-modal { padding: 18px 16px; }
    .confirm-text { font-size: 15px; }
    .skill-btn, .vote-btn { padding: 11px 10px; font-size: 12px; min-height: 44px; }
    .alive-players-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .action-targets { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); }
    .vote-targets { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); }
    .game-topbar { padding: 10px 12px; }
    .room-code { font-size: 18px; }
    .winner-text { font-size: 20px; }
    .game-over-modal h3 { font-size: 15px; }
}

/* 超小屏（≤340px） */
@media (max-width: 340px) {
    .game-title { font-size: 36px; letter-spacing: 5px; }
    .game-subtitle { font-size: 11px; margin-bottom: 20px; }
    .players-list { grid-template-columns: 1fr; }
    .card-container { width: 160px; height: 232px; }
}

/* 横屏手机适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .screen { padding-top: 60px; padding-top: calc(60px + env(safe-area-inset-top)); }
    .home-container { padding: 16px 20px; }
    .game-title { font-size: 40px; letter-spacing: 8px; margin-bottom: 4px; }
    .game-subtitle { font-size: 13px; margin-bottom: 20px; }
    .home-actions { gap: 12px; }
    .card-container { width: 160px; height: 230px; }
    .card-area { margin: 14px 0; }
    .lobby-header { padding: 10px 14px; margin-bottom: 12px; }
    .alive-players-section { margin-bottom: 12px; }
    .action-panel { padding: 12px; margin-bottom: 12px; }
    .vote-panel { padding: 12px; margin-bottom: 12px; }
    .instructions-modal { max-height: 86vh; }
    .game-over-modal { max-height: 86vh; }
}

/* 高刷屏优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* 深色模式增强（iOS）—— 保持卡背风格一致性 */
@media (prefers-color-scheme: dark) {
    body {
        background: url('../卡背.png') center center / cover no-repeat fixed;
    }
    body::before {
        background: rgba(253, 246, 211, 0.40);
    }
}

/* ========== 时间提示弹窗 ========== */
.time-notice-modal {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 2px solid #e94560;
    border-radius: 16px;
    padding: 30px 40px;
    text-align: center;
    max-width: 400px;
    animation: slideIn 0.3s ease;
    width: 90%;
}
.time-notice-title {
    font-size: 1.5rem;
    color: #e94560;
    margin-bottom: 10px;
    font-family: "KaiTi", "STKaiti", "华文楷体", serif;
}
.time-notice-desc {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 15px;
}
.time-notice-auto {
    font-size: 0.85rem;
    color: #999;
    margin-top: 15px;
}

/* ========== 发言轮次栏 ========== */
.speaking-bar {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: rgba(10, 10, 30, 0.95);
    border: 2px solid #f0c040;
    border-radius: 25px;
    padding: 10px 25px;
    box-shadow: 0 6px 24px rgba(240, 192, 64, 0.3);
}
.speaking-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.speaking-label {
    color: #f0c040;
    font-weight: bold;
    font-size: 1rem;
    white-space: nowrap;
}
.speaking-name {
    color: #fff;
    font-weight: bold;
    font-size: 1.1rem;
    white-space: nowrap;
}
.speaking-status {
    font-size: 0.8rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: bold;
    white-space: nowrap;
}
.speaking-status.speaking-on {
    background: #00cc66;
    color: #000;
    animation: micPulse 1s infinite;
}
.speaking-status.speaking-off {
    background: #666;
    color: #ccc;
}
.speaking-status.voice-ready {
    background: #00cc66;
    color: #000;
}
.speaking-status.voice-waiting {
    background: #ff6600;
    color: #fff;
    animation: micPulse 1s infinite;
}
.speaking-order-info {
    color: #aaa;
    font-size: 0.9rem;
    white-space: nowrap;
}
.speak-end-btn {
    padding: 6px 18px !important;
    font-size: 0.9rem !important;
    white-space: nowrap;
}

/* 发言栏倒计时 */
.speaker-countdown {
    color: #ffcc00;
    font-weight: bold;
    font-size: 1rem;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}
.speaker-countdown.urgent {
    color: #ff4444;
    animation: micPulse 0.5s infinite;
}

@keyframes micPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ========== 头像闪烁动画 ========== */
.avatar-speaker {
    animation: speakerBlink 0.8s infinite !important;
}
@keyframes speakerBlink {
    0%, 100% { box-shadow: 0 0 5px #f0c040; opacity: 1; }
    50% { box-shadow: 0 0 25px #f0c040, 0 0 50px #f0c040; opacity: 0.8; }
}

/* ========== 发言顺序标记 ========== */
.speak-order-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #e94560;
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    line-height: 1;
}

/* ========== 倒计时紧急状态 ========== */
.countdown.urgent {
    color: #ff3333 !important;
    background: rgba(255, 50, 50, 0.25) !important;
    border-color: rgba(255, 50, 50, 0.6) !important;
    animation: urgentPulse 0.5s infinite;
}
@keyframes urgentPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ========== 偷恋者聊天持久显示 ========== */
.villain-chat-persist {
    margin-top: 10px;
    padding: 10px;
    background: rgba(233, 69, 96, 0.08);
    border: 1px solid rgba(233, 69, 96, 0.25);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
.villain-chat-persist .chat-entry {
    padding: 5px 0;
    font-size: 0.85rem;
    color: #e94560;
    border-bottom: 1px solid rgba(233, 69, 96, 0.15);
    line-height: 1.5;
}
.villain-chat-persist .chat-entry:last-child {
    border-bottom: none;
}

/* 响应式补充 */
@media (max-width: 600px) {
    .time-notice-modal {
        padding: 22px 20px;
    }
    .time-notice-title {
        font-size: 1.2rem;
    }
    .time-notice-desc {
        font-size: 1rem;
    }
    .speaking-bar {
        bottom: 70px;
        padding: 8px 16px;
        border-radius: 20px;
    }
    .speaking-bar-inner {
        gap: 8px;
    }
    .speaking-label {
        font-size: 0.85rem;
    }
    .speaking-name {
        font-size: 0.95rem;
    }
    .speaking-order-info {
        font-size: 0.8rem;
    }
    .speaker-countdown {
        font-size: 0.85rem;
        min-width: 50px;
    }
}

/* ========== 玩家序号标记 ========== */
.player-no-tag {
    display: inline-block;
    background: #6c5ce7;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    vertical-align: middle;
}
.player-no-badge {
    display: inline-block;
    background: #6c5ce7;
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
    margin-right: 4px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ========== 阶段倒计时增强 ========== */
.phase-countdown-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(240, 192, 64, 0.12);
    border: 1px solid rgba(240, 192, 64, 0.35);
    border-radius: 20px;
    margin: 8px 0;
    animation: fadeIn 0.3s ease;
}
.phase-countdown-bar .phase-name {
    font-size: 0.9rem;
    color: #f0c040;
    font-weight: bold;
}
.phase-countdown-bar .phase-timer {
    font-size: 1.1rem;
    color: #fff;
    font-weight: bold;
    min-width: 50px;
    text-align: center;
}
.phase-countdown-bar.urgent .phase-timer {
    color: #ff3333;
}

/* 投票面板倒计时 */
.vote-countdown {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(240, 192, 64, 0.15);
    border: 1px solid rgba(240, 192, 64, 0.4);
    border-radius: 12px;
    color: #f0c040;
    font-weight: bold;
    font-size: 0.95rem;
    margin: 0 0 8px 0;
}
.vote-countdown.urgent {
    color: #ff3333;
    background: rgba(255, 50, 50, 0.2);
    border-color: rgba(255, 50, 50, 0.5);
}

/* === 偷恋者共识投票面板 === */
.villain-votes-status {
    margin: 10px 0;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.votes-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.vote-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.9rem;
}
.vote-status-item.is-me {
    background: rgba(240, 192, 64, 0.1);
    border-left: 3px solid #f0c040;
}
.vote-status-item.has-voted {
    border: 1px solid rgba(76, 175, 80, 0.3);
}
.vote-voter {
    color: #ccc;
    min-width: 100px;
    font-weight: bold;
}
.vote-target {
    flex: 1;
    color: #f0c040;
}
.vote-check {
    color: #4caf50;
    font-size: 1rem;
    margin-left: auto;
}
.consensus-reached {
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 8px;
    color: #4caf50;
    font-weight: bold;
    text-align: center;
    font-size: 0.95rem;
    animation: pulse 1.5s infinite;
}
.consensus-pending {
    margin-top: 8px;
    padding: 6px 12px;
    background: rgba(240, 192, 64, 0.1);
    border: 1px solid rgba(240, 192, 64, 0.2);
    border-radius: 8px;
    color: #f0c040;
    text-align: center;
    font-size: 0.9rem;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* === 顾魏沉睡目标信息展示 === */
.sleep-target-info {
    margin: 16px 0;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(240, 192, 64, 0.12), rgba(156, 39, 176, 0.08));
    border: 2px solid rgba(240, 192, 64, 0.35);
    border-radius: 12px;
    text-align: center;
}
.sleep-target-label {
    font-size: 0.85rem;
    color: #f0c040;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.sleep-target-detail {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 12px rgba(240, 192, 64, 0.3);
}

/* ========== 偷恋者同伴悬浮组件（右下角常驻） ========== */
.villain-allies-floating {
    position: fixed;
    right: 10px;
    bottom: 120px;
    z-index: 1000;
    background: rgba(233, 69, 96, 0.92);
    border: 2px solid rgba(240, 80, 110, 0.6);
    border-radius: 12px;
    min-width: 160px;
    max-width: 200px;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.35);
    backdrop-filter: blur(8px);
    animation: floatInRight 0.4s ease;
    transition: all 0.3s ease;
}
@keyframes floatInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
.villain-allies-floating.collapsed .villain-allies-floating-body {
    display: none;
}
.villain-allies-floating.collapsed {
    min-width: auto;
}
.villain-allies-floating-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    cursor: default;
}
.villain-allies-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.villain-allies-toggle:hover {
    background: rgba(255, 255, 255, 0.35);
}
.villain-allies-floating-body {
    padding: 8px 10px;
}
.villain-ally-item {
    padding: 4px 0;
    color: #fff;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.villain-ally-no {
    background: #fff;
    color: #e94560;
    font-weight: bold;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.villain-ally-name {
    font-weight: 500;
    text-overflow: ellipsis;
    overflow: hidden;
}

@media (max-width: 480px) {
    .villain-allies-floating {
        right: 6px;
        bottom: 200px;
        min-width: 140px;
        max-width: 170px;
    }
    .villain-ally-item {
        font-size: 0.75rem;
    }
}
