/* 狼人杀界面样式 */

.game-body {
    min-height: 100vh;
    background: var(--bg);
}

.game-top {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.game-top .brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 15px;
}

.game-top .brand img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: 8px;
}

.room-tag {
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 20px;
}

.day-tag {
    font-size: 12.5px;
    color: var(--text-dim);
    margin-right: 4px;
}

.game-wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px 20px 40px;
}

/* ---------- 入口卡片 ---------- */

.entry-card {
    max-width: 420px;
    margin: 40px auto;
    padding: 32px 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.35);
    text-align: center;
}

.entry-emoji { font-size: 44px; line-height: 1; }

.entry-card h1 {
    margin: 12px 0 8px;
    font-size: 21px;
}

.entry-sub {
    margin: 0 0 22px;
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--text-dim);
}

.btn-big {
    width: 100%;
    padding: 13px;
    font-size: 15px;
}

.or-line {
    position: relative;
    margin: 22px 0 16px;
    font-size: 12px;
    color: var(--text-faint);
}

.or-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.or-line span {
    position: relative;
    padding: 0 12px;
    background: var(--panel);
}

.join-row {
    display: flex;
    gap: 10px;
}

.join-row .field {
    flex: 1;
    text-align: center;
    letter-spacing: 4px;
    font-size: 16px;
    font-weight: 600;
}

/* ---------- 房间内 ---------- */

.lobby-bar,
.phase-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    margin-bottom: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.lobby-label {
    font-size: 12px;
    color: var(--text-dim);
}

.lobby-code {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 6px;
    color: var(--accent);
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.phase-name {
    font-size: 15px;
    font-weight: 600;
}

.game-main {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 18px;
    align-items: start;
}

.seat-panel {
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.seat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.seat {
    position: relative;
    padding: 14px 10px 12px;
    text-align: center;
    background: var(--panel-2);
    border: 2px solid transparent;
    border-radius: 14px;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.seat.me {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.seat.acting {
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.seat.dead {
    opacity: 0.42;
    filter: grayscale(1);
}

.seat.dead .seat-ava::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #dc2626;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
}

.seat.pickable {
    cursor: pointer;
    border-color: #fbbf24;
}

.seat.pickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.4);
}

.seat-ava {
    position: relative;
    width: 56px;
    height: 56px;
    margin: 0 auto 8px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

.seat-ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.seat-empty {
    font-size: 11px;
    color: var(--text-faint);
    font-weight: 400;
}

.seat-name {
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.seat-no {
    font-size: 11px;
    color: var(--text-faint);
}

.seat-role {
    display: inline-block;
    margin-top: 7px;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
}

.seat-role.wolf { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.seat-role.seer { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }
.seat-role.witch { color: #0d9488; border-color: #99f6e4; background: #f0fdfa; }

.seat-thinking {
    margin-top: 6px;
    font-size: 11px;
    color: #f59e0b;
}

/* ---------- 侧栏 ---------- */

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.side-card {
    padding: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.side-card.grow {
    display: flex;
    flex-direction: column;
    min-height: 320px;
    max-height: 52vh;
}

.side-title {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.my-role {
    font-size: 19px;
    font-weight: 700;
}

.my-role.wolf { color: #dc2626; }
.my-role.seer { color: #7c3aed; }
.my-role.witch { color: #0d9488; }

.my-extra {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.8;
    color: var(--text-dim);
}

.log-list {
    flex: 1;
    overflow-y: auto;
    font-size: 12.5px;
    line-height: 1.75;
}

.log-item {
    padding: 5px 0;
    border-bottom: 1px dashed var(--border);
    color: var(--text-dim);
}

.log-item.speak { color: var(--text); }
.log-item.vote { color: #b45309; }
.log-item.result { font-weight: 700; color: var(--accent); }

.log-day {
    display: inline-block;
    min-width: 30px;
    margin-right: 6px;
    font-size: 11px;
    color: var(--text-faint);
}

/* ---------- 操作区 ---------- */

.action-bar {
    margin-top: 18px;
    padding: 16px 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

/* 房间里的提示条（操作失败等） */
.room-notice {
    margin: 0 0 10px;
    display: none;
}

.room-notice.show {
    display: block;
}

.action-hint {
    font-size: 13.5px;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 20px;
}

.action-body:empty { display: none; }

.pick-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pick-btn {
    padding: 9px 15px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.16s ease;
}

.pick-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.pick-btn.danger { color: #b91c1c; }
.pick-btn.danger:hover { border-color: #dc2626; color: #dc2626; }
.pick-btn.ghost { color: var(--text-dim); }

.speak-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.speak-row .field { flex: 1; }

.spin {
    width: 11px;
    height: 11px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.7s linear infinite;
}

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

/* ---------- 结算弹层 ---------- */

.win-good { color: #059669; }
.win-wolf { color: #dc2626; }

.over-roles {
    margin: 16px 0;
    max-height: 40vh;
    overflow-y: auto;
}

.over-role {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    background: var(--panel-2);
    margin-bottom: 6px;
}

.over-role.wolf { background: #fef2f2; }
.over-role.seer { background: #f5f3ff; }
.over-role.witch { background: #f0fdfa; }

/* ---------- 响应式 ---------- */

/* style.css 里的 .spacer 只作用于后台页面，游戏页一直没生效，
   导致顶栏和房间栏的按钮全都挤在左边。 */
.spacer { flex: 1; }

/* 触摸设备：去掉点击延迟与双击缩放，并给一点点击反馈 */
.seat,
.pick-btn,
.btn,
.mini-btn,
.pick-row .field {
    touch-action: manipulation;
}

.seat,
.pick-btn,
.btn,
.mini-btn {
    -webkit-tap-highlight-color: rgba(236, 72, 153, 0.12);
}

@media (max-width: 760px) {
    /* ---- 竖向排列，并把「我的身份」提到座位前面 ---- */
    .game-main {
        display: flex;
        flex-direction: column;
        /* 必须显式写 stretch：基础规则里的 align-items:start 会留下来，
           让每个卡片按内容收缩（「我的身份」只剩 70 多 px 宽，座位网格也不撑满）。 */
        align-items: stretch;
        gap: 10px;
    }

    /* 把侧栏拆开，好让「我的身份」插到座位上方：手机屏幕小，
       玩家一进来就得先看见自己是什么身份。 */
    .side-panel { display: contents; }
    .side-panel > #my-card { order: 1; }
    .seat-panel { order: 2; }
    .side-panel > .side-card.grow { order: 3; }

    .side-card { padding: 12px; }
    .side-card.grow { max-height: 26vh; min-height: 110px; }
    .my-role { font-size: 17px; }

    /* ---- 座位：3 列，6 个人正好两行，不用滚动就能全看到 ---- */
    .seat-panel { padding: 12px; }
    .seat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .seat { padding: 10px 6px 9px; border-radius: 12px; }
    .seat-ava { width: 46px; height: 46px; margin-bottom: 6px; font-size: 17px; }
    .seat-name { font-size: 12px; }
    .seat-no { font-size: 10px; }
    .seat-role { margin-top: 5px; padding: 2px 6px; font-size: 10px; }
    .seat-thinking { font-size: 10px; }

    /* 可点的座位给一圈明显的橙色，手指才点得准 */
    .seat.pickable {
        border-color: #f59e0b;
        box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
    }
    .seat.pickable:active { transform: scale(0.97); }

    /* ---- 操作区吸底：刀人 / 投票 / 发言随时点得到，不用先滚到页面底部 ---- */
    .action-bar {
        position: sticky;
        bottom: 0;
        z-index: 15;
        margin-top: 12px;
        padding: 12px 14px;
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -10px 26px -16px rgba(15, 23, 42, 0.5);
        /* 投票时最多 6 个候选，吸底之后不能超过半屏，否则挡光座位 */
        max-height: 46vh;
        overflow-y: auto;
    }
    .game-wrap { padding: 12px 12px 88px; }
    .action-hint { font-size: 13px; margin-bottom: 9px; }

    /* ---- 按钮：高度至少 44px，一行两个，手指点得中 ---- */
    .pick-row { gap: 8px; }
    .pick-btn {
        flex: 1 1 calc(50% - 4px);
        min-height: 46px;
        padding: 12px 10px;
        font-size: 14px;
    }
    .btn { min-height: 42px; padding: 10px 16px; font-size: 14px; }
    .btn-big { padding: 14px; font-size: 15px; }
    .mini-btn { min-height: 38px; padding: 8px 12px; font-size: 12.5px; }

    /* ---- 输入框 ≥16px：iOS 上小于 16px 会自动放大整页 ---- */
    .field { font-size: 16px; }
    .speak-row { flex-direction: column; align-items: stretch; gap: 8px; }
    .speak-row .btn { width: 100%; }

    /* ---- 顶栏与房间栏 ---- */
    .game-top { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .game-top .brand { font-size: 14px; }
    .game-top .brand img { width: 24px; height: 24px; }
    .room-tag, .day-tag { font-size: 11px; }

    .lobby-bar { flex-wrap: wrap; gap: 8px; padding: 12px; }
    .lobby-code { font-size: 22px; letter-spacing: 4px; }
    .lobby-bar .btn { flex: 1 1 auto; }

    /* ---- 结算弹层别顶出屏幕 ---- */
    .modal { padding: 12px; }
    .modal-card { max-height: 88vh; overflow-y: auto; padding: 18px; }
    .over-roles { max-height: 44vh; }
}

@media (max-width: 400px) {
    .seat-grid { gap: 6px; }
    .seat { padding: 8px 5px; }
    .seat-ava { width: 40px; height: 40px; font-size: 15px; }
    .seat-name { font-size: 11.5px; }
    .pick-btn { font-size: 13.5px; }
}
