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

:root {
    --bg: #ffffff;
    --fg: #000000;
    --muted: #666666;
    --accent: #000000;
    --border: #000000;
    --light-border: #cccccc;
    --hover-bg: #f5f5f5;
    --green: #e8f5e9;
    --green-border: #4caf50;
    --red: #fce4ec;
    --red-border: #ef5350;
    --orange: #fff3e0;
    --orange-border: #ff9800;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--fg);
    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: 100px 20px 150px;
}

.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; }

/* 骰子 */
.dice-anchor {
    position: absolute;
    width: 50px; height: 50px;
    transform-style: preserve-3d;
    transform: translateZ(120px);
    z-index: 200;
    cursor: pointer;
}
.dice-box {
    width: 100%; height: 100%;
    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); } }

/* --- UI覆盖层 --- */
.ui-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 500; }
.ui-overlay > * { pointer-events: auto; }

.top-ui {
    position: absolute; top: 2rem; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 1rem;
    flex-wrap: nowrap;
    justify-content: center;
}

.task-detail {
    background: var(--bg);
    border: 1.5px solid var(--fg);
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.status-bar {
    background: var(--bg);
    border: 1.5px solid var(--fg);
    border-radius: 8px;
    padding: 10px 20px;
    display: flex; gap: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-item { text-align: center; }
.stat-label { font-size: 10px; color: var(--muted); }
.stat-val { font-size: 1rem; color: var(--fg); margin-top: 1px; font-weight: bold; }
.stat-val.hl { color: var(--fg); text-decoration: underline; }

.btn-back {
    position: absolute; top: 2rem; left: 2rem;
    background: var(--bg);
    border: 1.5px solid var(--fg);
    color: var(--fg);
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}
.btn-back:hover {
    background: var(--fg);
    color: var(--bg);
}

/* --- 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); }

/* --- 底部导航（与项目统一）--- */
.bottom-nav {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 0;
    border-top: 1.5px solid var(--border);
    background: var(--bg);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
}
.nav-text {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--muted);
    font-size: 12px;
    transition: all 0.2s;
    border-bottom: 1.5px solid transparent;
    margin-bottom: -1.5px;
}
.nav-text:hover { color: var(--fg); }
.nav-text.active {
    color: var(--fg);
    font-weight: bold;
    border-bottom-color: var(--fg);
}

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