/**
 * style.css - 全局样式 v2
 * 穿越者：佃农到仙帝
 * 移动端优先，古风宣纸系
 */

/* ========== CSS变量 ========== */
:root {
    --bg: #f5f0e6;
    --card: #fffbf0;
    --border: #d4c5a9;
    --text: #3d2e1f;
    --text-light: #7a6b5a;
    --gold: #c89b3c;
    --purple: #7b5ea7;
    --green: #5a8c5a;
    --red: #a85050;
    --blue: #4a7fb5;
    --orange: #d4863a;
    --font: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', sans-serif;
    --mono: 'Courier New', 'Consolas', monospace;
    --nav-height: 56px;
}

/* ========== 全局重置 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + 10px);
    font-size: 14px;
}

a {
    color: var(--gold);
    text-decoration: none;
}

/* ========== 页面标题（替代深色标题栏） ========== */
.page-title {
    background: var(--card);
    padding: 10px 12px;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--gold);
    border-bottom: 1px solid var(--border);
}

/* ========== 玩家状态栏 ========== */
.player-bar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.player-avatar {
    font-size: 1.8rem;
    line-height: 1;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-weight: bold;
    color: var(--text);
}

.player-detail {
    color: var(--text-light);
    font-size: 0.75rem;
}

/* ========== 资源行 ========== */
.resource-bar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.85rem;
}

.resource-item {
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.resource-item .icon {
    font-size: 1rem;
}

.resource-item .value {
    font-family: var(--mono);
    font-weight: bold;
}

/* ========== 进度条 ========== */
.progress-bar {
    width: 100%;
    height: 14px;
    background: #e8e0d0;
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.progress-bar.small {
    height: 8px;
    border-radius: 4px;
}

.progress-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.3s ease;
}

.progress-fill.hp { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.progress-fill.mp { background: linear-gradient(90deg, #2980b9, #3498db); }
.progress-fill.exp { background: linear-gradient(90deg, var(--purple), #9b7bc8); }
.progress-fill.stamina { background: linear-gradient(90deg, var(--orange), #e6a745); }
.progress-fill.gold { background: linear-gradient(90deg, var(--gold), #dbb55a); }
.progress-fill.green { background: linear-gradient(90deg, var(--green), #7ab87a); }

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
}

/* ========== 进度条组 ========== */
.progress-group {
    padding: 8px 12px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.progress-row:last-child {
    margin-bottom: 0;
}

.progress-label {
    font-size: 0.8rem;
    color: var(--text-light);
    min-width: 36px;
    text-align: right;
}

.progress-wrapper {
    flex: 1;
    position: relative;
}

/* ========== 内容区域 ========== */
.content {
    flex: 1;
    padding: 10px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    width: 100%;
}

.card-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* ========== 按钮样式 ========== */

/* 主功能大按钮 */
.btn-primary {
    display: block;
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
    position: relative;
    overflow: hidden;
}

.btn-primary:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.btn-primary.purple { background: linear-gradient(135deg, var(--purple), #6a4d90); }
.btn-primary.green { background: linear-gradient(135deg, var(--green), #4a7a4a); }
.btn-primary.gold { background: linear-gradient(135deg, var(--gold), #a07830); }
.btn-primary.red { background: linear-gradient(135deg, var(--red), #8a3a3a); }
.btn-primary.blue { background: linear-gradient(135deg, var(--blue), #3a6a9a); }

.btn-primary:disabled,
.btn-primary.disabled {
    background: #b0a898;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary:disabled:active,
.btn-primary.disabled:active {
    transform: none;
    opacity: 0.6;
}

/* 分栏操作按钮 */
.btn-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-group .btn-half {
    flex: 1;
    height: 48px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
}

.btn-half:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.btn-half.gold { background: var(--gold); }
.btn-half.green { background: var(--green); }
.btn-half.purple { background: var(--purple); }
.btn-half.red { background: var(--red); }
.btn-half.blue { background: var(--blue); }
.btn-half.orange { background: var(--orange); }

.btn-half:disabled {
    background: #b0a898;
    cursor: not-allowed;
    opacity: 0.6;
}

/* 小型文字按钮 */
.btn-small {
    display: inline-block;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
    line-height: 30px;
}

.btn-small:active {
    transform: scale(0.95);
    opacity: 0.9;
    background: #e8e0d0;
}

.btn-small.gold { border-color: var(--gold); color: var(--gold); }
.btn-small.green { border-color: var(--green); color: var(--green); }
.btn-small.purple { border-color: var(--purple); color: var(--purple); }
.btn-small.red { border-color: var(--red); color: var(--red); }

/* ========== 底部导航栏 ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-light);
    font-size: 0.7rem;
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: none;
}

.nav-item.active {
    color: var(--gold);
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-text {
    font-size: 0.65rem;
    line-height: 1;
}

/* ========== 属性面板 ========== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    background: #f8f4ec;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: var(--mono);
    color: var(--gold);
}

/* ========== 快捷按钮组 ========== */
.quick-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ========== 事件日志 ========== */
.log-list {
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.8;
}

.log-item {
    padding: 2px 0;
    border-bottom: 1px dashed #e8e0d0;
}

.log-item:last-child { border-bottom: none; }

.log-time {
    color: var(--text-light);
    font-size: 0.75rem;
    margin-right: 4px;
}

.log-info { color: var(--text); }
.log-success { color: var(--green); }
.log-warning { color: var(--orange); }
.log-danger { color: var(--red); }
.log-event { color: var(--purple); }

/* ========== 田地网格 ========== */
.farm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.farm-cell {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    min-height: 100px;
    gap: 4px;
}

.farm-cell:active {
    transform: scale(0.95);
    opacity: 0.9;
}

.farm-cell.empty {
    border-style: dashed;
    border-color: var(--green);
    background: #f0faf0;
}

.farm-cell.growing {
    border-color: var(--green);
    background: #f5faf5;
}

.farm-cell.ready {
    border-color: var(--gold);
    background: #fffdf0;
    box-shadow: 0 0 0 1px rgba(200,155,60,0.2);
}

.farm-cell.locked {
    background: #e8e0d0;
    opacity: 0.6;
    cursor: not-allowed;
}

.farm-icon {
    font-size: 1.8rem;
    line-height: 1;
}

.farm-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-align: center;
}

.farm-sub {
    font-size: 0.7rem;
    color: var(--text-light);
}

.farm-progress {
    width: 80%;
    margin-top: 2px;
}

/* ========== 种子列表 ========== */
.seed-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.seed-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f4ec;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.seed-icon {
    font-size: 1.5rem;
    min-width: 36px;
    text-align: center;
}

.seed-info {
    flex: 1;
    min-width: 0;
}

.seed-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.seed-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.seed-action {
    flex-shrink: 0;
}

/* ========== 商城行情 ========== */
.market-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.market-table th {
    background: #f0ebe0;
    padding: 8px 6px;
    text-align: left;
    font-weight: bold;
    border-bottom: 2px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-light);
}

.market-table td {
    padding: 10px 6px;
    border-bottom: 1px solid #e8e0d0;
}

.market-table tr:active {
    background: #f8f4ec;
}

.market-table .selected {
    background: #fff8e8;
}

.price-up { color: var(--red); font-weight: bold; }
.price-down { color: var(--green); font-weight: bold; }
.price-flat { color: var(--text-light); }

/* 数量选择器 */
.qty-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:active {
    transform: scale(0.95);
    background: #e8e0d0;
}

.qty-input {
    width: 60px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    font-family: var(--mono);
    background: #fff;
}

/* ========== 修仙境界 ========== */
.realm-display {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #f5f0ff, #ede5f8);
    border: 1px solid #d4c0e8;
    border-radius: 12px;
    margin-bottom: 10px;
}

.realm-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--purple);
}

.realm-level {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 2px;
}

/* 物品列表 */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f4ec;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.item-icon {
    font-size: 1.5rem;
    min-width: 36px;
    text-align: center;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.item-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.item-action {
    flex-shrink: 0;
}

/* 品质颜色 */
.quality-普通 { color: var(--text-light); border-color: var(--border); }
.quality-优秀 { color: var(--green); border-color: var(--green); }
.quality-稀有 { color: var(--blue); border-color: var(--blue); }
.quality-传说 { color: var(--purple); border-color: var(--purple); }
.quality-仙品 { color: var(--gold); border-color: var(--gold); }

/* ========== 剧情 ========== */
.story-content {
    line-height: 2;
    font-size: 0.95rem;
    padding: 12px;
    background: #faf7f0;
    border-left: 3px solid var(--gold);
    border-radius: 0 8px 8px 0;
    margin-bottom: 10px;
}

.story-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.story-option {
    display: block;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s;
}

.story-option:active {
    transform: scale(0.95);
    opacity: 0.9;
    background: #f0ebe0;
}

/* ========== 背包 ========== */
.inv-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.inv-tab {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    background: var(--card);
    color: var(--text-light);
}

.inv-tab.active {
    background: var(--gold);
    color: #fff;
    border-color: var(--gold);
}

.inv-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.inv-cell {
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card);
    cursor: pointer;
    position: relative;
    min-height: 60px;
    transition: all 0.15s;
}

.inv-cell:active {
    transform: scale(0.95);
}

.inv-cell.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(200,155,60,0.3);
}

.inv-cell .icon {
    font-size: 1.4rem;
    line-height: 1;
}

.inv-cell .qty {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text);
    background: rgba(255,255,255,0.85);
    border-radius: 4px;
    padding: 0 3px;
}

/* 品质边框 */
.inv-cell.q-普通 { border-color: var(--border); }
.inv-cell.q-优秀 { border-color: var(--green); }
.inv-cell.q-稀有 { border-color: var(--blue); }
.inv-cell.q-传说 { border-color: var(--purple); }
.inv-cell.q-仙品 { border-color: var(--gold); }

/* ========== 弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card);
    border-radius: 14px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.85);
    transition: transform 0.3s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 12px;
    color: var(--gold);
}

.modal-body {
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 16px;
}

.modal-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ========== 设置页 ========== */
.settings-section {
    margin-bottom: 16px;
}

.settings-section .section-title {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0ebe0;
    font-size: 0.95rem;
}

.settings-label {
    font-size: 0.95rem;
}

.settings-value {
    font-size: 0.95rem;
    color: var(--text-light);
    font-family: var(--mono);
}

/* ========== 登录注册页 ========== */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    width: 100%;
    max-width: 360px;
}

.auth-title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 14px;
    font-size: 1rem;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: var(--gold);
}

.form-input::placeholder {
    color: #c0b8a8;
}

.form-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 4px;
}

.form-link {
    text-align: center;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-purple { color: var(--purple); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-blue { color: var(--blue); }
.text-small { font-size: 0.8rem; }
.text-light { color: var(--text-light); }
.text-mono { font-family: var(--mono); }
.fw-bold { font-weight: bold; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.hidden { display: none !important; }

/* ========== 动画 ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.3s ease; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.pulse { animation: pulse 2s infinite; }

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-40px); }
}
.float-text {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--gold);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 300;
    pointer-events: none;
    animation: floatUp 1.2s ease forwards;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.toast.show { opacity: 1; }
