:root {
  --bg: #14112b; --bg2: #1f1a40; --card: #2a2452; --line: #3b3470; --tx: #f1eefc; --dim: #a39fc4;
  --acc: #ffb347; --acc2: #ff6f91; --good: #5be3a0; --bad: #ff7a7a; --blue: #7cc4ff;
  --sb: env(safe-area-inset-bottom, 0px); --st: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); overscroll-behavior: none; }
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(120% 60% at 50% 0%, #2d2066 0%, var(--bg) 60%) fixed; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
small { display: block; font-size: 12px; color: var(--dim); }
[hidden] { display: none !important; }
.page { max-width: 520px; margin: 0 auto; min-height: 100%; padding: calc(var(--st) + 12px) 14px calc(var(--sb) + 14px); }
.dim { color: var(--dim); } .center { text-align: center; }

/* 首页 */
.hero { text-align: center; padding: 26px 0 10px; }
.globe { font-size: 72px; animation: spin 14s linear infinite; display: inline-block; filter: drop-shadow(0 6px 24px #4c7dff88); }
@keyframes spin { 0% { transform: rotate(-8deg) } 50% { transform: rotate(8deg) } 100% { transform: rotate(-8deg) } }
.hero h1 { margin: 6px 0; font-size: 34px; letter-spacing: 4px; background: linear-gradient(90deg, var(--acc), var(--acc2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--dim); margin: 0; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0; }
.grid4 > div { background: var(--card); border-radius: 14px; padding: 10px 4px; text-align: center; }
.grid4 b { display: block; font-size: 17px; word-break: break-all; } .grid4 span { font-size: 11px; color: var(--dim); }
.gender { display: flex; gap: 8px; margin-bottom: 12px; }
.gender button { flex: 1; padding: 10px 0; border-radius: 12px; background: var(--card); border: 1px solid transparent; }
.gender button.on { border-color: var(--acc); background: #3a2f5e; }
.menu { display: grid; gap: 10px; }
.menu button { text-align: left; padding: 15px 16px; border-radius: 16px; background: var(--card); font-size: 17px; font-weight: 600; }
.menu button.primary { background: linear-gradient(135deg, #ff9a56, #ff5f8f); box-shadow: 0 8px 24px #ff5f8f44; }
.menu button.primary small { color: #fff0e6; }
.menu button small { font-weight: 400; margin-top: 2px; }
.foot { text-align: center; color: var(--dim); font-size: 12px; margin-top: 22px; }

/* 选国家 */
.bar { display: flex; align-items: center; gap: 8px; }
.bar h2 { margin: 0; font-size: 20px; }
.icon { width: 36px; height: 36px; border-radius: 50%; background: var(--card); font-size: 20px; line-height: 1; flex: none; }
#pickSearch { width: 100%; margin: 12px 0; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--tx); font-size: 15px; outline: none; }
#countryList { display: grid; gap: 8px; }
.crow { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--card); text-align: left; }
.crow:active, .item:active, .menu button:active { transform: scale(.98); }
.flag { font-size: 30px; }
.cname { flex: 1; } .cinfo { text-align: right; }

/* 游戏 */
#game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding-bottom: calc(var(--sb) + 8px); }
.card { background: var(--card); border-radius: 18px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex: none; }
#avatar { font-size: 38px; width: 50px; height: 50px; display: grid; place-items: center; background: var(--bg2); border-radius: 50%; }
.who { flex: 1; min-width: 0; } .who b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money { text-align: right; } .money b { color: var(--good); font-size: 16px; } .money b.neg { color: var(--bad); }
#log { flex: 1; overflow-y: auto; margin: 10px 0; padding: 0 2px; -webkit-overflow-scrolling: touch; }
.yr { border-left: 2px solid var(--line); padding: 0 0 8px 14px; margin-left: 6px; position: relative; }
.yr::before { content: ''; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); }
.yr h4 { margin: 0 0 2px; font-size: 14px; color: var(--acc); } .yr h4 small { display: inline; margin-left: 6px; }
.yr p { margin: 2px 0; } .yr p.big { font-size: 16px; } .yr p.good { color: var(--good); } .yr p.bad { color: var(--bad); }
.yr p.choice { color: var(--blue); } .yr p.act { color: #d8d3ff; } .yr p.ach { color: var(--acc); font-weight: 600; }
.yr p.death { color: #fff; font-weight: 700; background: #00000040; border-radius: 8px; padding: 6px 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; background: var(--card); border-radius: 16px; padding: 10px 12px; flex: none; }
.stats div { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.stats span { width: 52px; flex: none; } .stats b { width: 22px; text-align: right; }
.stats i { flex: 1; height: 7px; background: var(--bg2); border-radius: 9px; overflow: hidden; }
.stats em { display: block; height: 100%; background: var(--good); border-radius: 9px; transition: width .4s; }
.stats em.mid { background: var(--acc); } .stats em.low { background: var(--bad); }
#btnAge { flex: none; margin: 10px auto 8px; width: 100%; height: 54px; border-radius: 18px; background: linear-gradient(135deg, #ff9a56, #ff5f8f); box-shadow: 0 8px 22px #ff5f8f55; display: flex; align-items: center; justify-content: center; gap: 4px; }
#btnAge b { font-size: 24px; } #btnAge small { color: #fff; font-size: 15px; }
#btnAge:disabled { background: #4a4466; box-shadow: none; }
#btnAge.pop { animation: pop .25s; } @keyframes pop { 50% { transform: scale(.95) } }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: none; }
.actions button { background: var(--card); border-radius: 14px; padding: 7px 0 6px; font-size: 12px; }
.actions span { display: block; font-size: 22px; line-height: 1.2; }

/* 抽屉 */
#sheet { position: fixed; inset: 0; background: #0008; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column; background: var(--bg2); border-radius: 22px 22px 0 0; padding: 12px 14px calc(var(--sb) + 14px); transform: translateY(100%); transition: transform .2s ease-out; }
#sheet.open .sheet-box { transform: none; }
.sheet-box header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-box h3 { margin: 0; }
#sheetBody { overflow-y: auto; -webkit-overflow-scrolling: touch; }
#sheetBody h5, #modalBox h5 { margin: 14px 2px 6px; color: var(--dim); font-weight: 500; font-size: 13px; }
.item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 7px; }
.item.off { opacity: .5; }
.ie { font-size: 24px; width: 32px; text-align: center; flex: none; }
.it { flex: 1; min-width: 0; }
.why { font-size: 12px; color: var(--dim); flex: none; max-width: 40%; text-align: right; }
.tag { font-size: 11px; color: #fff; background: var(--bad); padding: 1px 7px; border-radius: 9px; }

/* 弹窗 */
#modal { position: fixed; inset: 0; z-index: 20; background: #000a; display: flex; align-items: center; justify-content: center; padding: 18px; }
#modalBox { width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 22px; padding: 18px; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0 } }
#modalBox h3 { text-align: center; margin: 4px 0 10px; font-size: 20px; }
.ev-icon { text-align: center; font-size: 52px; }
.choices { display: grid; gap: 8px; margin-top: 14px; }
.choices button { padding: 13px; border-radius: 14px; background: linear-gradient(135deg, #5d4bd1, #8a56d8); font-weight: 600; }
.choices button small { color: #ddd6ff; font-weight: 400; }
.choices button.ghost { background: var(--card); }
.epi { color: var(--acc); font-style: italic; }
.score { text-align: center; margin-top: 10px; } .score b { font-size: 30px; color: var(--acc); margin-left: 6px; }
.chip { display: inline-block; background: var(--card); border-radius: 10px; padding: 2px 8px; margin: 2px; font-size: 12px; }
.pass { display: flex; flex-wrap: wrap; gap: 4px; font-size: 26px; }
.pass span { filter: grayscale(1); opacity: .25; } .pass span.on { filter: none; opacity: 1; }
.achs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.achs div { background: var(--card); border-radius: 12px; padding: 8px; opacity: .45; font-size: 13px; }
.achs div.on { opacity: 1; } .achs span { font-size: 20px; margin-right: 4px; }
.past { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px; }
.past > span { font-size: 26px; } .past > div { flex: 1; min-width: 0; } .past em { font-style: normal; color: var(--acc); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: calc(var(--sb) + 150px); transform: translate(-50%, 20px); max-width: 86%; background: #000c; padding: 9px 14px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 30; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
