/* ============================
   game.css - 任务矩阵大富翁
   统一项目黑白简约风格
   ============================ */

:root {
    --green: #e8f5e9;
    --green-border: #4caf50;
    --red: #fce4ec;
    --red-border: #ef5350;
    --orange: #fff3e0;
    --orange-border: #ff9800;
}

body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}


.setup-container {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}
.setup-card {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.setup-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.section-header label {
    font-size: 14px;
    color: var(--muted);
}

.tag-btn {
    padding: 6px 14px;
    border: 1px solid var(--light-border);
    background: var(--bg);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    margin: 2px;
    font-family: inherit;
}
.tag-btn:hover { border-color: var(--border); color: var(--fg); }
.tag-btn.selected {
    background: var(--fg);
    border-color: var(--fg);
    color: var(--bg);
}
.tag-btn .remove { margin-left: 6px; color: var(--red-border); font-weight: bold; pointer-events: none; font-size: 1rem; }

.btn-main {
    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-main:hover {
    background: var(--bg);
    color: var(--fg);
}

.add-btn {
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--hover-bg);
    border: 1px solid transparent;
}
.add-btn:hover { color: var(--fg); border-color: var(--light-border); }

.grid-input-row {
    margin-bottom: 1.5rem;
}
.grid-input-row label {
    display: block;
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 8px;
}
.grid-input-row input[type="range"] {
    width: 100%;
    accent-color: var(--fg);
}

/* --- 3D场景 --- */
.game-viewport {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    perspective: 1200px;
    overflow: auto;
    background: var(--bg);
    padding: 20px;
}

.scene-root {
    min-width: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    padding: 20px;
}

.board-stage {
    position: relative;
    width: auto; height: auto;
    transform-style: preserve-3d;
    transform: none;
    margin: 20px auto;
}

.matrix-grid {
    position: relative;
    transform-style: preserve-3d;
    margin: 0 auto;
}

.cell {
    position: absolute;
    width: 70px; height: 70px;
    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;
    transition: all 0.2s;
    transform-style: preserve-3d;
    box-shadow: 0 3px 0 rgba(0,0,0,0.08);
}

.cell:hover { transform: translateZ(15px); border-color: var(--border); z-index: 10; }
.cell.active {
    border: 2px solid var(--border);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.1);
}

.cell.start {
    background: var(--bg);
    color: var(--fg);
    border-color: var(--fg);
    border-width: 2px;
}
.cell.forward {
    border-color: var(--green-border);
    background: var(--green);
}
.cell.backward {
    border-color: var(--red-border);
    background: var(--red);
}
.cell.other {
    border-color: var(--orange-border);
    background: var(--orange);
}

.cell-content { padding: 0.25rem; pointer-events: none; width: 100%; }
.cell-title { font-size: 11px; font-weight: bold; display: block; margin-bottom: 1px; color: var(--fg); }
.cell-sub { font-size: 10px; color: var(--muted); display: block; }
.cell-meta { font-size: 11px; color: var(--fg); font-weight: bold; margin-top: 2px; display: block; }

/* 骰子3D */
.dice-box {
    width: 50px; height: 50px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.1s;
    transform: rotateX(0deg) rotateY(0deg);
}
.face {
    position: absolute;
    width: 50px; height: 50px;
    background: var(--bg);
    border: 2px solid var(--fg);
    border-radius: 10px;
    display: flex; justify-content: center; align-items: center;
    font-size: 28px;
    color: var(--fg);
    font-weight: bold;
    font-family: inherit;
    backface-visibility: hidden;
}
.f-front { transform: rotateY(0deg) translateZ(25px); }
.f-back { transform: rotateY(180deg) translateZ(25px); }
.f-right { transform: rotateY(90deg) translateZ(25px); }
.f-left { transform: rotateY(-90deg) translateZ(25px); }
.f-top { transform: rotateX(90deg) translateZ(25px); }
.f-bottom { transform: rotateX(-90deg) translateZ(25px); }

@keyframes roll-anim {
    0% { transform: rotateX(0) rotateY(0); }
    100% { transform: rotateX(720deg) rotateY(720deg); }
}
.rolling { animation: roll-anim 0.8s ease-out; }

/* 小人 */
.character-anchor {
    position: absolute;
    width: 30px; height: 50px;
    transform-style: preserve-3d;
    transform: none;
    z-index: 150;
    pointer-events: none;
    transition: left 0.4s cubic-bezier(0.25, 1, 0.5, 1), top 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.char-body {
    position: relative;
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    transform: translateZ(2px);
}

.char-head {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 16px; height: 16px;
    background: #ffdca8;
    border: 1.5px solid #d4a574;
    border-radius: 50%;
    z-index: 2;
}
.char-head::after {
    content: '';
    position: absolute;
    top: 5px; left: 3px;
    width: 8px; height: 3px;
    background: radial-gradient(circle, #333 1.5px, transparent 1.5px);
    background-size: 3px 3px;
    background-repeat: space;
}

.char-torso {
    position: absolute;
    top: 14px; left: 50%;
    transform: translateX(-50%);
    width: 14px; height: 18px;
    background: var(--fg);
    border-radius: 3px 3px 2px 2px;
    z-index: 1;
}

.char-arms {
    position: absolute;
    top: 16px; left: 50%;
    transform: translateX(-50%);
    width: 24px; height: 4px;
    display: flex;
    justify-content: space-between;
}
.char-arm {
    width: 5px; height: 14px;
    background: #ffdca8;
    border-radius: 2px;
    transform-origin: top center;
}

.char-legs {
    position: absolute;
    top: 30px; left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
}
.char-leg {
    width: 5px; height: 16px;
    background: #555;
    border-radius: 0 0 2px 2px;
    transform-origin: top center;
}

.walking .char-leg:first-child { animation: walk-a 0.3s infinite alternate; }
.walking .char-leg:last-child { animation: walk-a 0.3s infinite alternate-reverse; }
.walking .char-arm:first-child { animation: arm-s 0.3s infinite alternate; }
.walking .char-arm:last-child { animation: arm-s 0.3s infinite alternate-reverse; }

@keyframes walk-a { from { transform: rotate(-15deg); } to { transform: rotate(15deg); } }
@keyframes arm-s { from { transform: rotate(10deg); } to { transform: rotate(-10deg); } }

/* --- 顶部固定栏 --- */
.game-top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1.5px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
    position: relative;
}
.btn-back-fixed {
    position: absolute;
    left: 16px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    color: var(--fg);
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
}
.btn-back-fixed:hover {
    background: var(--fg);
    color: var(--bg);
}
.dice-3d-anchor {
    width: 50px; height: 50px;
    perspective: 300px;
    cursor: pointer;
    user-select: none;
}
.top-stats {
    display: flex; gap: 16px;
}
.top-stats .stat-item { text-align: center; }
.top-stats .stat-label { font-size: 10px; color: var(--muted); }
.top-stats .stat-val { font-size: 14px; color: var(--fg); font-weight: bold; }
.top-stats .stat-val.hl { text-decoration: underline; }

/* 任务详情栏 */
.task-bar-dmx {
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--muted);
    border-bottom: 1px solid var(--light-border);
    background: var(--bg);
    flex-shrink: 0;
    min-height: 32px;
    transition: all 0.3s;
}
.task-bar-dmx.flash {
    color: var(--fg);
    font-weight: bold;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-box {
    background: var(--bg);
    border: 2px solid var(--fg);
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
}
.modal-box h3 {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 1rem;
}
.modal-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 2px solid var(--fg);
    color: var(--fg);
    margin-bottom: 1rem;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}
.modal-input:focus { outline: none; box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    border: 1.5px solid var(--fg);
    transition: all 0.2s;
}
.modal-cancel { background: var(--bg); color: var(--fg); }
.modal-cancel:hover { background: var(--hover-bg); }
.modal-confirm { background: var(--fg); color: var(--bg); font-weight: bold; }
.modal-confirm:hover { background: var(--bg); color: var(--fg); }


/* --- 通用辅助 --- */
.mb-4 { margin-bottom: 1rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
