/* ============================
   smfxq.css - SM飞行棋 CSS 3D横向棋盘版
   复用 game.css 的基础样式（.setup-container, .setup-card, .section-header, .tag-btn, .add-btn, .grid-input-row, .modal-overlay 等）
   ============================ */

body { height: auto; overflow: hidden; }

/* 设置面板覆盖：允许滚动 */
.setup-container { overflow-y: auto; }

/* 玩家设置 */
.player-setup {
    border: 1.5px solid var(--light-border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}
.player-setup h3 { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.player-rows { display: flex; flex-direction: column; gap: 8px; }
.player-row { display: flex; align-items: center; gap: 10px; }
.player-dot {
    width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
    border: 1.5px solid var(--border);
}
.player-row input {
    flex: 1;
    background: var(--bg);
    border: 1.5px solid var(--light-border);
    color: var(--fg);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}
.player-row input:focus {
    outline: none;
    border-color: var(--border);
}
.player-count-ctrl {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.player-count-ctrl button {
    width: 30px; height: 30px; border-radius: 50%;
    border: 1.5px solid var(--border); background: var(--bg);
    color: var(--fg); font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.player-count-ctrl button:hover {
    background: var(--fg); color: var(--bg);
}
.player-count-ctrl span {
    font-size: 18px; font-weight: bold; min-width: 24px; text-align: center;
}

/* 开始按钮 */
.btn-start {
    background: var(--fg); color: var(--bg);
    border: 2px solid var(--fg); padding: 14px;
    border-radius: 5px; font-weight: 700; cursor: pointer;
    width: 100%; font-family: inherit; font-size: 16px;
    transition: all 0.3s;
}
.btn-start:hover { background: var(--bg); color: var(--fg); }

/* 模式切换 */
.mode-toggle {
    margin: 16px 0 8px;
    padding: 12px 16px;
    border: 1.5px solid var(--light-border);
    border-radius: 8px;
    background: var(--bg);
}
.mode-toggle label {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; font-size: 14px;
}
.mode-toggle input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--fg);
}
.mode-hint {
    font-size: 12px; color: var(--muted); margin-left: 4px;
}

/* ========== 游戏面板 ========== */
.game-container {
    display: none; flex-direction: column;
    height: 100vh; overflow: hidden;
    padding-bottom: 50px;
}
.game-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--bg);
    border-bottom: 1.5px solid var(--border);
    z-index: 100; flex-shrink: 0;
}
.player-tabs {
    display: flex; gap: 6px; flex-wrap: wrap; justify-content: center;
}
.player-tab {
    padding: 5px 12px; border-radius: 4px; font-size: 12px; font-weight: bold;
    border: 1.5px solid transparent; opacity: 0.4;
    transition: all 0.3s; color: var(--bg);
}
.player-tab.active {
    opacity: 1; border-color: var(--fg);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

/* ========== 骰子+任务区 ========== */
.play-bar {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px 8px;
    border-bottom: 1.5px solid var(--border);
    flex-shrink: 0;
    background: var(--bg);
}
.play-bar-top {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    min-height: 56px;
}
/* 左右标签绝对定位，不影响骰子居中 */
.play-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--muted);
}
.play-label strong { font-size: 14px; color: var(--fg); }
.play-label-left { left: 0; }
.play-label-right { right: 0; }
.dice-result { font-size: 15px; font-weight: bold; color: var(--fg); }
.task-bar-inline {
    width: 100%;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    min-height: 20px;
    padding: 6px 0 0;
    color: var(--muted);
    transition: all 0.3s;
}
.task-bar-inline.flash {
    color: var(--fg);
    font-weight: bold;
}
.task-bar-inline .task-player { font-weight: bold; margin-right: 4px; }
.task-bar-inline .task-specify-target { font-weight: bold; text-decoration: underline; }
.dice-3d-anchor {
    width: 52px; height: 52px;
    perspective: 300px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.dice-3d-box {
    width: 100%; height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.15s;
    transform: rotateX(-20deg) rotateY(20deg);
}
.dice-3d-box.rolling {
    animation: dice3d-roll 0.7s ease-out forwards;
}
@keyframes dice3d-roll {
    0% { transform: rotateX(0) rotateY(0) rotateZ(0); }
    30% { transform: rotateX(400deg) rotateY(300deg) rotateZ(100deg); }
    60% { transform: rotateX(800deg) rotateY(600deg) rotateZ(50deg); }
    100% { transform: rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(0deg); }
}
.dice-face {
    position: absolute; width: 52px; height: 52px;
    background: var(--bg); border: 2px solid var(--fg);
    border-radius: 8px;
    display: flex; justify-content: center; align-items: center;
    font-size: 24px; font-weight: bold; color: var(--fg);
    font-family: inherit;
    backface-visibility: hidden;
}
.dice-face.f1 { transform: rotateY(0deg) translateZ(26px); }
.dice-face.f2 { transform: rotateY(180deg) translateZ(26px); }
.dice-face.f3 { transform: rotateY(90deg) translateZ(26px); }
.dice-face.f4 { transform: rotateY(-90deg) translateZ(26px); }
.dice-face.f5 { transform: rotateX(90deg) translateZ(26px); }
.dice-face.f6 { transform: rotateX(-90deg) translateZ(26px); }

/* ========== 3D棋盘视口 ========== */
.board-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    perspective: 900px;
    perspective-origin: 50% 50%;
    background: linear-gradient(180deg, var(--bg) 0%, var(--hover-bg) 100%);
    padding-bottom: 50px;
}

/* 棋盘舞台 - 3D倾斜 */
.board-stage {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform-style: preserve-3d;
    transform: rotateX(20deg) translateY(-40%);
    transition: transform 0.5s;
}

/* 横向滚动轨道 */
.board-track {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 40px 80px 60px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

/* ========== 3D格子 ========== */
.cell {
    width: 80px; min-width: 80px;
    height: 90px;
    background: var(--bg);
    border: 1.5px solid var(--light-border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 6px 4px;
    transform-style: preserve-3d;
    box-shadow: 0 4px 0 rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.3s cubic-bezier(0.25,1,0.5,1),
                box-shadow 0.3s,
                border-color 0.2s;
    position: relative;
    flex-shrink: 0;
}
.cell:hover {
    transform: translateZ(10px) translateY(-4px);
    box-shadow: 0 8px 0 rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.1);
    z-index: 10;
}
.cell.active {
    transform: translateZ(16px) translateY(-6px) scale(1.05);
    box-shadow: 0 12px 0 rgba(0,0,0,0.18), 0 6px 20px rgba(0,0,0,0.12);
    border-color: var(--fg);
    z-index: 20;
}
.cell.active::after {
    content: '';
    position: absolute; inset: -4px;
    border: 2px solid var(--fg);
    border-radius: 10px;
    animation: cell-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes cell-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.7; }
}

/* 格子侧面（3D厚度） */
.cell::before {
    content: '';
    position: absolute;
    bottom: -4px; left: 0; right: 0;
    height: 4px;
    background: rgba(0,0,0,0.15);
    border-radius: 0 0 4px 4px;
    transform: rotateX(-90deg);
    transform-origin: top;
}

/* 格子类型着色 */
.cell.start {
    border-color: var(--fg); border-width: 2px;
    background: var(--bg);
}
.cell.finish {
    border-color: var(--fg); border-width: 2px;
    background: var(--bg);
}
.cell.forward { border-color: var(--green-border); background: var(--green); }
.cell.backward { border-color: var(--red-border); background: var(--red); }
.cell.specify { border-color: var(--orange-border); background: var(--orange); }
.cell.reward { border-color: var(--green-border); background: var(--green); }
.cell.punish { border-color: var(--red-border); background: var(--red); }
.cell.task { border-color: var(--light-border); }

.cell-num {
    font-size: 10px; color: var(--muted); font-weight: bold;
    position: absolute; top: 3px; right: 5px;
}
.cell-title { font-size: 11px; font-weight: bold; display: block; margin-bottom: 2px; color: var(--fg); line-height: 1.2; }
.cell-sub { font-size: 9px; color: var(--muted); display: block; line-height: 1.2; }
.cell-meta { font-size: 12px; color: var(--fg); font-weight: bold; margin-top: 2px; display: block; }

/* ========== 3D棋子 ========== */
.token {
    position: absolute;
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: bold; color: #fff;
    border: 2px solid var(--fg);
    z-index: 20;
    pointer-events: none;
    transform: translateZ(20px);
    box-shadow: 0 3px 0 rgba(0,0,0,0.4), 0 1px 6px rgba(0,0,0,0.2);
    transition: left 0.35s cubic-bezier(0.25,1,0.5,1),
                top 0.35s cubic-bezier(0.25,1,0.5,1);
}

/* 棋子跳跃动画 - 抛物线 */
.token.jumping {
    animation: token-arc 0.35s ease-out;
}
@keyframes token-arc {
    0% { transform: translateZ(20px) translateY(0) scale(1); }
    30% { transform: translateZ(30px) translateY(-25px) scale(1.15); }
    100% { transform: translateZ(20px) translateY(0) scale(1); }
}

/* 棋子阴影 */
.token-shadow {
    position: absolute;
    width: 20px; height: 6px;
    border-radius: 50%;
    background: rgba(0,0,0,0.15);
    z-index: 19;
    pointer-events: none;
    transform: translateZ(2px);
    transition: left 0.35s cubic-bezier(0.25,1,0.5,1),
                top 0.35s cubic-bezier(0.25,1,0.5,1);
}

/* ========== 指定玩家面板 ========== */
.select-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center; z-index: 2000;
}
.select-overlay.active { display: flex; }
.select-box {
    background: var(--bg); border: 2px solid var(--fg);
    border-radius: 10px; padding: 24px; width: 90%; max-width: 400px;
}
.select-box h3 { font-size: 1.1rem; text-align: center; margin-bottom: 16px; }
.select-player-btn {
    width: 100%; padding: 12px; border: 1.5px solid var(--fg);
    border-radius: 5px; color: #fff; font-size: 15px; font-weight: bold;
    cursor: pointer; margin-bottom: 8px; transition: all 0.2s; font-family: inherit;
}
.select-player-btn:hover { opacity: 0.85; }
.select-cancel-btn {
    width: 100%; padding: 10px; background: var(--bg);
    border: 1px solid var(--light-border); border-radius: 5px;
    color: var(--muted); cursor: pointer; font-family: inherit; margin-top: 8px;
}

.mb-4 { margin-bottom: 16px; }

/* ========== 移动端优化 ========== */
@media (max-width: 600px) {
    .cell { width: 65px; min-width: 65px; height: 75px; }
    .cell-title { font-size: 10px; }
    .cell-sub { font-size: 8px; }
    .cell-meta { font-size: 10px; }
    .board-track { padding: 30px 40px 50px; gap: 6px; }
    .board-stage { transform: rotateX(15deg) translateY(-35%); }
    .play-bar { padding: 8px 12px 6px; }
    .task-bar-inline { font-size: 12px; }
    .dice-3d-anchor { width: 40px; height: 40px; }
    .dice-face { width: 40px; height: 40px; font-size: 18px; }
    .dice-face.f1 { transform: rotateY(0deg) translateZ(20px); }
    .dice-face.f2 { transform: rotateY(180deg) translateZ(20px); }
    .dice-face.f3 { transform: rotateY(90deg) translateZ(20px); }
    .dice-face.f4 { transform: rotateY(-90deg) translateZ(20px); }
    .dice-face.f5 { transform: rotateX(90deg) translateZ(20px); }
    .dice-face.f6 { transform: rotateX(-90deg) translateZ(20px); }
    .token { width: 22px; height: 22px; font-size: 10px; }
}
