/* =========================================================
   pixel.css — 像素风基础层：设计变量 / 边框 / 按钮 / 通用组件
   ========================================================= */

:root {
  /* 主色板（开罗风：暖色纸面 + 深棕描边 + 高饱和高光） */
  --ink:        #33200f;   /* 主描边 */
  --ink-soft:   #5a4028;
  --paper:      #fdf6e3;
  --paper-2:    #f6e7c6;
  --paper-3:    #ead6ac;
  --line:       #c8a877;

  --brand:      #ff9a2e;
  --brand-dk:   #c96a08;
  --blue:       #3d9ae8;
  --blue-dk:    #1f6fae;
  --green:      #5cb85c;   /* 只做底色/进度条，白字场合请用 #2e7d32 */
  --green-dk:   #3a8a3a;
  --red:        #c0392b;   /* 白字压深版；纯装饰可用 #e5543c */
  --red-dk:     #ad3220;
  --gold:       #ffc23c;
  --purple:     #7d4fc0;   /* 白字压深版 */

  --wood-1:     #7a4b2a;
  --wood-2:     #5c3520;
  --wood-3:     #3a2213;

  --txt:        #3b2a1a;
  --txt-dim:    #6f5b42;   /* 5.3:1 on paper-2，小字也看得清 */

  /* 像素描边 */
  --bd: 3px solid var(--ink);
  --shadow-sm: 0 3px 0 rgba(51,32,15,.28);
  --shadow-md: 0 5px 0 rgba(51,32,15,.30);

  --r: 4px;
}

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

/* 保证 hidden 属性胜过各处的 display 设定 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background:
    repeating-linear-gradient(45deg, #e8d4ab 0 8px, #dfc79a 8px 16px);
  color: var(--txt);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  image-rendering: pixelated;
  overscroll-behavior: none;
  user-select: none;
}

button { font-family: inherit; }

/* ---------------- 按钮 ---------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #3b2410;
  background: var(--brand);
  border: var(--bd);
  border-radius: var(--r);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.42),
              inset 0 -4px 0 rgba(0,0,0,.16),
              0 4px 0 var(--brand-dk),
              0 4px 0 3px var(--ink);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s, filter .12s;
  text-shadow: 0 1px 0 rgba(255,255,255,.45);
  white-space: nowrap;
}
.btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35),
              inset 0 -3px 0 rgba(0,0,0,.18),
              0 0 0 var(--brand-dk),
              0 0 0 3px var(--ink);
}
.btn:disabled,
.btn.is-disabled {
  filter: grayscale(.75) brightness(1.02);
  opacity: .72;
  cursor: not-allowed;
}
.btn.disabled,
.btn.is-disabled:active { transform: none; }

.btn-blue  { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); background: #2470b4;  box-shadow: inset 0 3px 0 rgba(255,255,255,.42), inset 0 -4px 0 rgba(0,0,0,.16), 0 4px 0 var(--blue-dk), 0 4px 0 3px var(--ink); }
.btn-green { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); background: #2e7d32; box-shadow: inset 0 3px 0 rgba(255,255,255,.42), inset 0 -4px 0 rgba(0,0,0,.16), 0 4px 0 var(--green-dk), 0 4px 0 3px var(--ink); }
.btn-red   { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); background: #b8351f;   box-shadow: inset 0 3px 0 rgba(255,255,255,.42), inset 0 -4px 0 rgba(0,0,0,.16), 0 4px 0 var(--red-dk), 0 4px 0 3px var(--ink); }

.btn-ghost {
  color: var(--ink);
  background: var(--paper-2);
  text-shadow: none;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.75),
              inset 0 -4px 0 rgba(0,0,0,.10),
              0 4px 0 var(--line),
              0 4px 0 3px var(--ink);
}
.btn-ghost:active:not(:disabled) {
  box-shadow: inset 0 3px 0 rgba(255,255,255,.6),
              inset 0 -3px 0 rgba(0,0,0,.12),
              0 0 0 var(--line),
              0 0 0 3px var(--ink);
}

.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 13px 20px; font-size: 17px; letter-spacing: 2px; }
.btn-sm { padding: 6px 11px; font-size: 12px; box-shadow: inset 0 2px 0 rgba(255,255,255,.42), inset 0 -3px 0 rgba(0,0,0,.14), 0 3px 0 var(--line), 0 3px 0 3px var(--ink); }
.btn-xs { padding: 4px 8px; font-size: 11px; border-width: 2px; border-radius: 3px; box-shadow: 0 2px 0 rgba(51,32,15,.3); }
.btn-sm.btn-primary { box-shadow: inset 0 2px 0 rgba(255,255,255,.42), inset 0 -3px 0 rgba(0,0,0,.14), 0 3px 0 var(--brand-dk), 0 3px 0 3px var(--ink); }

/* ---------------- 面板 ---------------- */
.panel {
  position: relative;
  background: var(--paper);
  border: var(--bd);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(51,32,15,.06) inset;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  margin: -1px -1px 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffeccd;
  background: var(--wood-2);
  border-bottom: 3px solid var(--ink);
  border-radius: 2px 2px 0 0;
}

/* ---------------- 标签 / 徽章 ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  color: var(--ink);
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: 3px;
}
.tag-blue  { background: #bfe0fb; }
.tag-green { background: #cbeecb; }
.tag-red   { background: #ffcfc7; }
.tag-gold  { background: var(--gold); }
.tag-purple{ background: #ded0fb; }

/* ---------------- 进度条 ---------------- */
.bar {
  position: relative;
  height: 16px;
  background: #d9c49a;
  border: var(--bd);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.14);
}
.bar-fill {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(180deg, #ffd166, var(--brand));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.45);
  transition: width .3s linear;
}
.bar-fill.is-blue  { background: linear-gradient(180deg, #8fd0f8, var(--blue)); }
.bar-fill.is-green { background: linear-gradient(180deg, #9fe09f, var(--green)); }
.bar-fill.is-red   { background: linear-gradient(180deg, #ff9a8a, var(--red)); }
.bar-stripes::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,.25) 0 6px, transparent 6px 12px);
  animation: stripes 1s linear infinite;
}
@keyframes stripes { to { transform: translateX(12px); } }

/* ---------------- 弹窗 ---------------- */
#overlay-root { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: rgba(38,22,10,.62);
  pointer-events: auto;
  animation: fade .16s ease-out;
  z-index: 61;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  width: 100%;
  max-width: 430px;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  margin: auto 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 8px 0 rgba(51,32,15,.35), 0 0 0 4px rgba(255,255,255,.35) inset;
  animation: pop .18s cubic-bezier(.2,1.4,.6,1);
  overflow: hidden;
}
@keyframes pop {
  from { transform: scale(.9) translateY(10px); opacity: 0; }
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 10px 12px;
  color: #ffeccd;
  background: linear-gradient(180deg, var(--wood-1), var(--wood-2));
  border-bottom: 4px solid var(--ink);
  font-weight: 800;
  letter-spacing: 1px;
}
.modal-head .modal-ico { font-size: 17px; }
.modal-head .modal-title { flex: 1; font-size: 15px; }
.modal-x {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 900; line-height: 1;
  color: #ffeccd;
  background: rgba(0,0,0,.22);
  border: 2px solid rgba(255,236,205,.55);
  border-radius: 3px;
  cursor: pointer;
}
.modal-body {
  padding: 12px;
  flex: 1 1 auto;
  min-height: 0;          /* 内容超高时让 body 内部滚动，底部按钮不会被顶出屏幕 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;   /* 滚到底不要把背后的页面一起带着滚 */
  touch-action: pan-y;
}
.modal-foot {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 12px 13px;
  padding-bottom: calc(13px + env(safe-area-inset-bottom, 0px));
  border-top: 3px dashed var(--line);
  background: var(--paper-2);
}
.modal-foot .btn { flex: 1; }

/* 弹窗打开时锁住背后页面的触摸滚动（iOS 上 overflow:hidden 不够） */
body.modal-open { overflow: hidden; }
body.modal-open #app,
body.modal-open #boot { touch-action: none; }
/* 弹窗开着时把 toast 挪到上方，别压住底部的「开始开发 / 继续经营」 */
body.modal-open .toast-root { top: 66px; bottom: auto; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  max-width: 86%;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: #fff5e2;
  background: rgba(58,34,19,.94);
  border: 2px solid rgba(255,236,205,.5);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  animation: toastIn .2s ease-out, toastOut .3s ease-in 1.5s forwards;
}
/* 注意：.gold 是全局文字色工具类（#a97500），必须在各变体里显式写死文字色，
   否则 .toast.gold 会继承 .gold 的深黄字 → 黄底黄字看不清 */
.toast.ok   { background: rgba(46,108,42,.97); color: #f2ffe9; border-color: rgba(190,240,180,.55); }
.toast.bad  { background: rgba(150,40,26,.97); color: #fff0ec; border-color: rgba(255,200,190,.55); }
.toast.gold { background: #ffc93c; color: #3b2410; border-color: #7d4f00; box-shadow: 0 3px 0 rgba(90,55,0,.4); }
@keyframes toastIn  { from { transform: translateY(10px) scale(.94); opacity: 0; } }
@keyframes toastOut { to   { transform: translateY(-8px); opacity: 0; } }

/* ---------------- 工具类 ---------------- */
.row { display: flex; align-items: center; }
.gap4 { gap: 4px; } .gap6 { gap: 6px; } .gap8 { gap: 8px; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt4 { margin-top: 4px; } .mt6 { margin-top: 6px; }
.mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; }
.mb6 { margin-bottom: 6px; } .mb8 { margin-bottom: 8px; }
.dim { color: var(--txt-dim); }
.tiny { font-size: 11px; }
.small { font-size: 12px; }
.bold { font-weight: 800; }
.num { font-family: "Courier New", ui-monospace, monospace; font-weight: 700; letter-spacing: -.3px; }
/* 文字色工具类统一加 txt- 前缀，避免与 .toast.gold 之类的背景修饰类抢同名 */
.txt-gold { color: #8a5c00; }
.txt-green { color: #2f7d32; }
.txt-red { color: #c0392b; }
.txt-blue { color: #1f6fae; }
.green { color: #2f7d32; }
.red { color: #c0392b; }
.blue { color: #1f6fae; }
.nowrap { white-space: nowrap; }
.divider { height: 3px; margin: 10px 0; background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 12px); }
