/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Arial', 'Microsoft YaHei', sans-serif;
    background: #0a0a0a;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: fixed; /* 防止移动端弹性滚动 */
}

/* Background Effects */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: url('../images/background_day.webp') center/cover no-repeat;
    z-index: -2;
    overflow: hidden;
    transition: background-image 2s ease-in-out;
}

#particles {
    position: absolute;
    width: 100%;
    height: 100%;
}

/* Game Container - Mobile First */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* Game Header - Optimized for Mobile */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
}

.game-title {
    font-size: 1.5em;
    color: #d4af37;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
    letter-spacing: 2px;
}

.phase-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    padding: 5px 12px;
    background: rgba(40, 40, 50, 0.7);
    border-radius: 20px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.phase-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.8);
}

/* Main Game Area */
.game-main {
    flex: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Players Circle - Responsive Size */
.players-circle {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}

.player {
    position: absolute;
    width: 70px; /* 移动端缩小尺寸 */
    height: 70px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    pointer-events: auto;
}

@media (min-width: 768px) {
    .player {
        width: 100px;
        height: 100px;
    }
}

.player.dead {
    opacity: 0.4;
    filter: grayscale(100%);
}

.player-frame {
    position: relative;
    width: 100%;
    height: 100%;
}

.frame-border {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, #d4af37, #f4d03f);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.player-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: #2a2a3a;
    border: 2px solid #1a1a2a;
}

.avatar-svg, .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 120%;
}

.player-name {
    font-size: 11px;
    color: #fff;
    text-shadow: 0 1px 2px #000;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tags & Badges */
.me-tag {
    position: absolute;
    top: -5px;
    left: -5px;
    background: #2563eb;
    color: #fff;
    font-size: 10px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 15;
    border: 1.5px solid #fff;
}

.role-badge {
    position: absolute;
    bottom: -5px;
    left: -5px;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid #d4af37;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
}

/* Center Info & Start Button */
.center-info {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 100;
    width: 80%;
}

.start-button {
    padding: 12px 30px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #d4af37, #8b4513);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    cursor: pointer;
}

/* Sidebar - Hidden on Mobile, Toggleable or Floating */
.game-sidebar {
    position: fixed;
    bottom: 20px;
    left: 15px;
    right: 75px; /* Leave space for settings */
    z-index: 200;
    pointer-events: none;
}

.sidebar-section {
    background: rgba(20, 20, 30, 0.85);
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 12px;
    padding: 10px;
    pointer-events: auto;
}

.game-log {
    max-height: 80px; /* 移动端日志变短 */
    overflow-y: auto;
    font-size: 0.8em;
    mask-image: linear-gradient(to bottom, transparent, black 20%);
}

/* Skill Panel - Full Screen on Mobile */
.skill-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.98);
    border-top: 2px solid #d4af37;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Medicine Bottles Mobile */
.witch-medicine-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

.medicine-bottle {
    flex: 1;
    max-width: 120px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(40, 40, 60, 0.6);
    text-align: center;
}

/* Victory Overlay Mobile */
.victory-content {
    width: 90%;
    padding: 30px 20px;
}

/* Chat Input Mobile */
.chat-input-area {
    display: flex;
    gap: 5px;
}

#chatInput {
    flex: 1;
    font-size: 16px; /* 防止 iOS 自动缩放 */
}

/* Settings Button Mobile */
#settingsBtn {
    position: fixed;
    bottom: 20px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: rgba(20, 20, 30, 0.8);
    border: 1px solid #d4af37;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* Utility */
.hidden { display: none !important; }

/* Desktop Overrides */
@media (min-width: 1024px) {
    .game-sidebar {
        position: absolute;
        top: 80px;
        right: 20px;
        left: auto;
        bottom: auto;
        width: 300px;
    }
    .game-log { max-height: 300px; mask-image: none; }
    .skill-panel {
        width: 400px;
        left: 50%;
        bottom: 50%;
        transform: translate(-50%, 50%);
        border-radius: 15px;
    }
}

/* Day/Night Theme */
body.night-phase .background { background-image: url('../images/background.webp'); }
body.day-phase .background { background-image: url('../images/background_day.webp'); }

/* Speaking Animation */
.is-speaking {
    z-index: 100 !important;
}

.is-speaking .player-frame {
    transform: scale(1.1);
    box-shadow: 0 0 20px #4a90e2;
}

.chat-bubble {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid #d4af37;
    border-radius: 15px;
    padding: 5px 12px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 200;
}
