/* tycoon.css - 奇迹算能岛：数学乐园大亨 样式表 */

:root {
  --bg-ocean: linear-gradient(135deg, #74ebd5 0%, #9face6 100%);
  --island-grass: #a8e6cf;
  --island-grid-border: #81c784;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(255, 255, 255, 0.5);
  --card-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  --text-main: #2c3e50;
  --text-muted: #7f8c8d;
  --primary: #ff7675;
  --primary-hover: #d63031;
  --accent: #fdcb6e;
  --success: #00b894;
  --info: #0984e3;
  --font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background: var(--bg-ocean);
  min-height: 100vh;
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 70px;
}

/* 顶部全域跨游戏传送门横幅 */
.portal-bar {
  background: rgba(30, 39, 46, 0.95);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.portal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #ffeaa7;
}

.portal-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.portal-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.portal-btn:hover {
  background: #00cec9;
  color: #2d3436;
}

.portal-btn.active {
  background: #fdcb6e;
  color: #2d3436;
  font-weight: bold;
}

/* App 容器 */
.app-container {
  max-width: 960px;
  margin: 16px auto;
  padding: 0 16px;
}

/* 乐园大亨状态 HUD */
.tycoon-hud {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--panel-border);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.park-logo {
  font-size: 32px;
  background: #fff;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.park-title {
  font-size: 18px;
  font-weight: 700;
  color: #2d3436;
}

.park-level-tag {
  font-size: 12px;
  background: #ffeaa7;
  color: #d63031;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.hud-metrics {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.metric-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.metric-coins {
  color: #e67e22;
  font-size: 16px;
}

.income-tag {
  font-size: 11px;
  color: #27ae60;
  background: #e8f8f5;
  padding: 1px 6px;
  border-radius: 8px;
}

.metric-pros {
  color: #9b59b6;
}

.hud-actions {
  display: flex;
  gap: 8px;
}

.hud-btn {
  background: #fff;
  border: 1px solid #dfe6e9;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #2d3436;
}

.hud-btn:hover {
  background: #f1f2f6;
}

.hud-btn.danger {
  color: #d63031;
}

/* 导航标签栏 */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.nav-tab-btn {
  background: var(--panel-bg);
  border: none;
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  transform: translateY(-1px);
}

.nav-tab-btn.active {
  background: #2d3436;
  color: #fff;
}

/* 面板通用样式 */
.view-panel {
  background: var(--panel-bg);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--panel-border);
  min-height: 480px;
}

/* --- 1. 网格地图视图 --- */
.map-layout-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.island-board {
  background: #b8e994;
  border: 4px solid #78e08f;
  border-radius: 24px;
  padding: 16px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.08);
}

.grid-table {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
}

.grid-cell {
  aspect-ratio: 1 / 1;
  background: #dff9fb;
  border: 2px dashed #81ecec;
  border-radius: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  overflow: hidden;
}

.grid-cell:hover {
  transform: scale(1.02);
  border-color: #00cec9;
  background: #c7ecee;
}

.grid-cell.has-building {
  background: #fff;
  border: 2px solid #fdcb6e;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.cell-coord {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  color: #b2bec3;
  font-weight: bold;
}

.building-badge {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.building-icon {
  font-size: 28px;
  line-height: 1;
}

.building-name {
  font-size: 11px;
  font-weight: bold;
  color: #2d3436;
  white-space: nowrap;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.building-lvl {
  font-size: 10px;
  color: #27ae60;
  font-weight: 600;
}

.plot-tip {
  font-size: 12px;
  color: #00cec9;
  font-weight: bold;
}

/* 游客雪碧精灵 */
.visitor-sprite {
  position: absolute;
  bottom: 6px;
  right: 6px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.animal-avatar {
  font-size: 20px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.visitor-bubble {
  position: absolute;
  bottom: 26px;
  background: #fff;
  color: #2d3436;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  white-space: nowrap;
  font-weight: bold;
  pointer-events: none;
}

.visitor-bubble::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: #fff transparent;
  display: block;
  width: 0;
}

/* 浮动文字特效 */
.floating-score {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  animation: floatUp 1.2s forwards;
  z-index: 20;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(1.2); }
}

/* 蓝图托盘 */
.blueprints-section {
  background: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  border: 1px solid #dfe6e9;
}

.section-label {
  font-size: 13px;
  font-weight: bold;
  color: #636e72;
  margin-bottom: 8px;
}

.blueprints-tray {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.blueprint-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8f9fa;
  border: 2px solid #dfe6e9;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  min-width: 180px;
  transition: all 0.2s;
}

.blueprint-card:hover {
  border-color: #74b9ff;
  background: #f1f8ff;
}

.blueprint-card.selected {
  border-color: #0984e3;
  background: #e8f4fc;
}

.bp-icon {
  font-size: 24px;
}

.bp-title {
  font-size: 12px;
  font-weight: bold;
  color: #2d3436;
}

.bp-cost {
  font-size: 10px;
  color: #636e72;
}

/* --- 2. 课本学习闯关与答题视图 --- */
.district-chips-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid #dfe6e9;
}

.dist-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #b2bec3;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.dist-chip.active {
  background: #ff7675;
  color: #fff;
  border-color: #ff7675;
}

.dist-chip.locked {
  opacity: 0.6;
}

.dist-header-card {
  background: #fdfaf6;
  border-left: 4px solid #ff7675;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.dist-h-title {
  font-size: 18px;
  font-weight: 700;
  color: #2d3436;
}

.dist-h-topic {
  font-size: 13px;
  color: #e67e22;
  font-weight: 600;
  margin-top: 2px;
}

.dist-h-story {
  font-size: 13px;
  color: #636e72;
  margin-top: 6px;
}

.task-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #dfe6e9;
  padding: 20px;
}

.task-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #ecf0f1;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}

.task-progress-bar {
  height: 100%;
  background: #00b894;
  transition: width 0.3s ease;
}

.task-step-tag {
  font-size: 12px;
  color: #0984e3;
  font-weight: bold;
  margin-bottom: 8px;
}

.task-prompt {
  font-size: 16px;
  font-weight: 600;
  color: #2d3436;
  line-height: 1.6;
  margin-bottom: 20px;
}

.task-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-option-btn {
  background: #f8f9fa;
  border: 1px solid #ced6e0;
  border-radius: 12px;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  color: #2f3542;
  font-weight: 500;
}

.task-option-btn:hover:not(:disabled) {
  background: #e4f0ec;
  border-color: #00b894;
}

.opt-label {
  font-weight: bold;
  color: #00b894;
  margin-right: 6px;
}

.task-feedback-box {
  margin-top: 20px;
  padding: 16px;
  border-radius: 12px;
  font-size: 14px;
}

.task-feedback-box.correct {
  background: #e8f8f5;
  border: 1px solid #a3e4d7;
  color: #117a65;
}

.task-feedback-box.wrong {
  background: #fef9e7;
  border: 1px solid #f9e79f;
  color: #7d6608;
}

.fb-header {
  font-weight: bold;
  font-size: 15px;
  margin-bottom: 6px;
}

.fb-exp {
  line-height: 1.6;
  margin-bottom: 12px;
}

.fb-next-btn {
  background: #00b894;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.fb-next-btn.retry {
  background: #f39c12;
}

/* 通关大横幅 */
.district-cleared-banner {
  text-align: center;
  padding: 40px 20px;
}

.cleared-trophy {
  font-size: 56px;
  margin-bottom: 12px;
}

.action-btn {
  background: #ff7675;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 16px;
}

/* --- 3. 规划工具箱视图 --- */
.tool-chips-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tool-chip {
  background: #fff;
  border: 1px solid #dfe6e9;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #2d3436;
}

.tool-chip.active {
  background: #0984e3;
  color: #fff;
  border-color: #0984e3;
}

.tool-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid #dfe6e9;
}

.tool-controls {
  display: flex;
  gap: 20px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.tool-calc-formula {
  background: #f1f2f6;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  color: #2f3542;
  margin-top: 16px;
  font-size: 14px;
}

/* 10x10 网格 */
.grid-100 {
  display: grid;
  grid-template-columns: repeat(10, 24px);
  gap: 2px;
  margin: 12px 0;
  justify-content: center;
}

.grid-100-cell {
  width: 24px;
  height: 24px;
  background: #f1f2f6;
  border: 1px solid #ced6e0;
}

.grid-100-cell.highlight {
  background: #ff7675;
  border-color: #d63031;
}

/* 数对雷达 */
.radar-interactive-grid {
  display: grid;
  grid-template-columns: repeat(5, 50px);
  gap: 6px;
  justify-content: center;
  margin: 16px 0;
}

.radar-cell {
  width: 50px;
  height: 50px;
  background: #f8f9fa;
  border: 1px solid #b2bec3;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}

.radar-cell.selected {
  background: #0984e3;
  color: #fff;
  border-color: #0984e3;
}

/* 天平样式 */
.balance-display-wrap {
  display: flex;
  justify-content: center;
  padding: 30px 0 10px;
}

.balance-beam {
  display: flex;
  align-items: center;
  gap: 60px;
  position: relative;
  transition: transform 0.3s ease;
}

.balance-plate {
  background: #fff;
  border: 2px solid #2d3436;
  border-radius: 12px;
  padding: 12px 18px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  min-width: 120px;
}

.plate-label {
  font-size: 12px;
  color: #636e72;
}

.plate-weight {
  font-size: 18px;
  font-weight: bold;
  color: #d63031;
  margin-top: 4px;
}

.balance-fulcrum {
  font-size: 32px;
  color: #2d3436;
}

/* 植树尺 */
.tree-track-box {
  display: flex;
  align-items: center;
  overflow-x: auto;
  padding: 16px 8px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 16px 0;
}

.tree-node {
  text-align: center;
}

.tree-icon {
  font-size: 24px;
}

.tree-dist {
  font-size: 10px;
  color: #636e72;
}

.tree-seg {
  flex-grow: 1;
  min-width: 40px;
  height: 4px;
  background: #81c784;
  margin: 0 4px;
  position: relative;
  text-align: center;
  font-size: 10px;
  color: #27ae60;
  line-height: 24px;
}

/* --- 4. 错题档案 --- */
.mistakes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mistake-card {
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 12px;
  padding: 16px;
}

.m-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #95a5a6;
  margin-bottom: 8px;
}

.m-title {
  font-weight: bold;
  color: #e74c3c;
}

.m-prompt {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.m-answers {
  display: flex;
  gap: 16px;
  font-size: 13px;
  margin-bottom: 8px;
}

.your-ans {
  color: #c0392b;
}

.correct-ans {
  color: #27ae60;
}

.m-exp {
  font-size: 13px;
  color: #7f8c8d;
  background: #fcf3cf;
  padding: 8px 12px;
  border-radius: 8px;
}

/* --- 5. 资产与统计 --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-item {
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.stat-val {
  font-size: 24px;
  font-weight: bold;
  color: #2d3436;
}

.stat-lbl {
  font-size: 12px;
  color: #7f8c8d;
  margin-top: 4px;
}

.badges-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.achievement-badge {
  background: #fff;
  border: 1px solid #dfe6e9;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.achievement-badge.earned {
  border-color: #f1c40f;
  background: #fef9e7;
}

.achievement-badge.locked {
  opacity: 0.5;
}

.badge-icon {
  font-size: 28px;
}

.badge-title {
  font-size: 13px;
  font-weight: bold;
}

.badge-sub {
  font-size: 11px;
  color: #7f8c8d;
}

/* 模态弹窗 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.modal-card {
  background: #fff;
  border-radius: 20px;
  max-width: 400px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.modal-header-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 18px;
  font-weight: bold;
}

.modal-details {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 12px;
  margin: 16px 0;
  font-size: 13px;
  text-align: left;
  line-height: 1.8;
}

.modal-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}

.modal-action-btn {
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

.modal-action-btn.upgrade {
  background: #2ecc71;
  color: #fff;
}

.modal-action-btn.demolish {
  background: #e74c3c;
  color: #fff;
}

.modal-action-btn.cancel {
  background: #bdc3c7;
  color: #fff;
}

/* 响应式调整 */
@media (max-width: 600px) {
  .tycoon-hud {
    flex-direction: column;
    align-items: stretch;
  }
  .hud-metrics {
    justify-content: space-around;
  }
  .grid-table {
    gap: 4px;
  }
  .building-name {
    font-size: 9px;
  }
  .building-icon {
    font-size: 22px;
  }
}
