/* ============ 基础 ============ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: #fff; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; overflow: hidden; }
#glcanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.hidden { display: none !important; }
.layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.screen { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; }

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
.big-btn { pointer-events: auto; padding: 12px 36px; font-size: 16px; border-radius: 8px; background: #e8e2d4; color: #1a1a1a; font-weight: 700; letter-spacing: 2px; }
.big-btn:active { transform: scale(.97); }

/* ============ HUD ============ */
#hud-top { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.85); text-shadow: 0 1px 3px #000; letter-spacing: 1px; }
#hud-top span { margin: 0 10px; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%); }
#crosshair i { position: absolute; background: rgba(255,255,255,.9); box-shadow: 0 0 2px #000; }
#crosshair i:first-child { left: 50%; top: 50%; width: 2px; height: 2px; transform: translate(-50%,-50%); border-radius: 50%; }
#crosshair.focus i { background: #ffd86b; }
#interact-hint { position: absolute; left: 50%; top: calc(50% + 28px); transform: translateX(-50%); font-size: 14px; padding: 5px 12px; background: rgba(0,0,0,.55); border-radius: 5px; white-space: nowrap; opacity: 0; transition: opacity .15s; }
#interact-hint.show { opacity: 1; }
#lock-tip { position: absolute; left: 50%; bottom: calc(40px + env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: 13px; padding: 8px 16px; background: rgba(0,0,0,.6); border-radius: 20px; opacity: 0; transition: opacity .2s; }
#lock-tip.show { opacity: 1; }

/* ============ 移动端触控 ============ */
#touch-ui { z-index: 6; }
#joystick { position: absolute; left: 22px; bottom: calc(30px + env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(0,0,0,.18); opacity: 0; transition: opacity .2s; }
#joystick.show { opacity: 1; }
#joystick-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.4); border: 2px solid rgba(255,255,255,.6); }
#touch-tip { position: absolute; top: calc(40px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,.6); }

/* ============ 开场：县城 ============ */
#intro-town { background: linear-gradient(180deg,#cfd6d0 0%,#c2b9a6 60%,#a89c86 100%); }
.town-overlay { text-align: center; }
.town-title { font-size: 72px; font-weight: 800; letter-spacing: 18px; color: #3a3630; text-shadow: 2px 2px 0 rgba(255,255,255,.3); }
.town-sub { margin: 16px 0 60px; font-size: 16px; color: #5a5247; letter-spacing: 6px; }
#intro-town .big-btn { background: #3a3630; color: #f0ece2; }

/* ============ 开场：暑假快进 ============ */
#intro-summer { background: #12100e; }
.summer-wrap { width: 86%; max-width: 640px; }
#summer-lines { font-size: clamp(18px,4.5vw,26px); line-height: 2; min-height: 300px; }
.summer-line { opacity: 0; margin-bottom: 10px; color: #d8d2c4; }
.summer-line.show { animation: fadeLine .6s forwards; }
.summer-line.os { color: #aaa39a; font-style: italic; }
@keyframes fadeLine { to { opacity: 1; } }
.summer-hint { text-align: right; color: #7a746c; font-size: 14px; margin-top: 30px; pointer-events: auto; cursor: pointer; }

/* ============ 对话框 ============ */
#dialog { background: rgba(0,0,0,.45); z-index: 30; }
.dialog-box { pointer-events: auto; width: 86%; max-width: 520px; background: #f4f0e6; color: #1d1b18; border-radius: 10px; padding: 24px 24px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.dialog-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; border-bottom: 1px solid #d5cdbb; padding-bottom: 8px; }
.dialog-text { font-size: 15px; line-height: 1.9; white-space: pre-wrap; max-height: 50vh; overflow: auto; }
.dialog-ok { display: block; margin: 20px 0 0 auto; padding: 8px 24px; background: #3a3630; color: #fff; border-radius: 6px; font-size: 14px; }

/* ============ 手机 2D 界面 ============ */
#phone-ui { z-index: 40; background: rgba(0,0,0,.82); }
.phone-frame { pointer-events: auto; position: relative; width: min(390px, 92vw); height: min(780px, 92vh); background: #0c0c0e; border: 6px solid #232326; border-radius: 44px; box-shadow: 0 20px 60px rgba(0,0,0,.7); overflow: hidden; display: flex; flex-direction: column; }
.phone-notch { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 132px; height: 24px; background: #0c0c0e; border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; z-index: 3; }
.phone-status { height: 40px; padding: 12px 24px 0; display: flex; justify-content: space-between; font-size: 12px; color: #cfcfd2; flex: none; z-index: 2; }
.status-right { font-size: 11px; letter-spacing: 1px; }
.phone-body { flex: 1; position: relative; overflow: hidden; }
.phone-page { position: absolute; inset: 0; padding: 16px 18px 24px; overflow-y: auto; background: linear-gradient(160deg,#1d2a3a,#121822 60%); }
.phone-page::-webkit-scrollbar { width: 0; }
.page-head { height: 34px; display: flex; align-items: center; justify-content: center; position: relative; margin-bottom: 10px; color: #fff; }
.page-head b { font-size: 16px; }
.back { position: absolute; left: 0; top: 0; height: 34px; background: none; color: #8ec5ff; font-size: 15px; padding: 0 6px; }
.phone-homebar { position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%); width: 120px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.5); pointer-events: auto; cursor: pointer; z-index: 5; }

/* 主屏幕 */
.phone-widget { text-align: center; margin: 16px 0 40px; color: #fff; }
.widget-time { font-size: 62px; font-weight: 200; letter-spacing: 2px; }
.widget-date { font-size: 15px; opacity: .85; }
.app-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 22px 10px; }
.app { text-align: center; color: #fff; font-size: 12px; cursor: pointer; }
.app:active .app-icon { transform: scale(.9); }
.app-icon { width: 56px; height: 56px; margin: 0 auto 6px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; transition: transform .1s; }
.icon-msg { background: #4cd964; } .icon-wx { background: #2dc100; } .icon-cam { background: #8e8e93; }
.icon-photo { background: linear-gradient(135deg,#f5a623,#e74c3c,#8e44ad); } .icon-set { background: #7d8a99; } .icon-clock { background: #1c1c1e; border: 1px solid #444; }

/* 信息 */
.msg-list { background: #fff; border-radius: 10px; overflow: hidden; }
.msg-row { display: flex; align-items: center; padding: 12px; border-bottom: 1px solid #eee; cursor: pointer; color: #222; }
.msg-row:last-child { border-bottom: none; }
.msg-row:active { background: #f2f2f2; }
.msg-avatar { width: 44px; height: 44px; border-radius: 8px; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; margin-right: 12px; flex: none; }
.msg-info { flex: 1; min-width: 0; }
.msg-info b { font-size: 15px; }
.msg-info p { margin: 3px 0 0; font-size: 13px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-date { font-size: 11px; color: #bbb; align-self: flex-start; }
.msg-detail { background: #f2f2f2; border-radius: 10px; min-height: 460px; padding: 10px; }
.msg-detail-head { position: relative; text-align: center; height: 30px; color: #222; }
.msg-detail-head .back { color: #007aff; }
.bubble { margin: 30px 10px; padding: 12px 14px; background: #fff; border-radius: 4px; font-size: 15px; color: #222; line-height: 1.6; position: relative; }
.bubble:before { content: ''; position: absolute; left: -6px; top: 12px; border: 6px solid transparent; border-right-color: #fff; border-left: 0; }
.msg-time { text-align: center; font-size: 11px; color: #aaa; }

/* 微信登录 */
.wx-login { background: #ededed; min-height: 520px; border-radius: 10px; padding: 40px 22px; color: #222; text-align: center; }
.wx-logo { font-size: 30px; font-weight: 700; color: #2dc100; margin-bottom: 6px; }
.wx-tip { color: #888; font-size: 13px; margin: 0 0 30px; }
.wx-login input[type=text] { width: 100%; height: 44px; border: none; border-radius: 6px; padding: 0 14px; font-size: 16px; margin-bottom: 18px; }
.gender-row { display: flex; gap: 30px; justify-content: center; margin-bottom: 28px; font-size: 15px; }
.gender-row label { cursor: pointer; }
.wx-btn { width: 100%; height: 44px; background: #2dc100; color: #fff; font-size: 16px; border-radius: 6px; font-weight: 700; }
.wx-note { margin-top: 20px; font-size: 11px; color: #aaa; line-height: 1.6; }

/* 微信主界面 */
.wx-me { display: flex; align-items: center; padding: 16px; background: #fff; border-radius: 10px; color: #222; margin-bottom: 12px; }
.wx-avatar { width: 50px; height: 50px; border-radius: 6px; background: #2dc100; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; margin-right: 14px; flex: none; }
.wx-avatar.small { width: 42px; height: 42px; margin-right: 12px; }
.wx-nick { font-size: 16px; font-weight: 700; }
.wx-id { font-size: 12px; color: #aaa; margin-top: 4px; }
.wx-contacts { background: #fff; border-radius: 10px; overflow: hidden; }
.wx-row { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid #f0f0f0; color: #222; }
.wx-row:last-child { border-bottom: none; }
.wx-row b { font-size: 15px; }
.wx-preview { font-size: 12px; color: #aaa; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.wx-logout { display: block; width: 100%; margin-top: 16px; padding: 12px; background: #fff; color: #e74c3c; border-radius: 8px; font-size: 15px; }

/* 相机 */
.camera-view { position: relative; background: #000; height: 480px; border-radius: 8px; overflow: hidden; }
.camera-frame { position: absolute; inset: 20px; border: 1px solid rgba(255,255,255,.15); }
.camera-frame i { position: absolute; width: 20px; height: 20px; border: 2px solid #fff; }
.camera-frame i:nth-child(1){ left:-1px;top:-1px;border-right:0;border-bottom:0; }
.camera-frame i:nth-child(2){ right:-1px;top:-1px;border-left:0;border-bottom:0; }
.camera-frame i:nth-child(3){ left:-1px;bottom:-1px;border-right:0;border-top:0; }
.camera-frame i:nth-child(4){ right:-1px;bottom:-1px;border-left:0;border-top:0; }
.camera-tip { position: absolute; bottom: 16px; left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(255,255,255,.5); }
.camera-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.camera-flash.flash { animation: flashAnim .4s; }
@keyframes flashAnim { 0%{opacity:1;} 100%{opacity:0;} }
.camera-bar { text-align: center; padding: 22px 0; }
.shutter { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 4px solid #888; }
.shutter:active { transform: scale(.93); }

/* 相册 */
.photo-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.photo-item { background: #222; border-radius: 6px; padding: 8px; text-align: center; color: #bbb; font-size: 12px; cursor: pointer; }
.photo-item canvas { width: 100%; height: auto; border-radius: 4px; display: block; margin-bottom: 6px; }
.photo-empty { height: 120px; display: flex; align-items: center; justify-content: center; color: #555; font-size: 12px; }
.photo-detail { background: #000; border-radius: 8px; padding: 10px; text-align: center; }
.photo-detail canvas { width: 100%; max-width: 320px; height: auto; }
.photo-detail .back { position: static; display: block; margin: 12px auto 0; }

/* 设置 */
.settings-list { background: #fff; border-radius: 10px; padding: 8px 16px 16px; color: #222; }
.setting-row { padding: 14px 0; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.setting-row label { display: block; margin-bottom: 8px; }
.setting-row input[type=range] { width: calc(100% - 44px); vertical-align: middle; }
.setting-row span { display: inline-block; width: 36px; text-align: right; color: #888; font-size: 13px; }
.setting-note { font-size: 11px; color: #aaa; padding: 12px 0; line-height: 1.6; }
.set-btn { display: block; width: 100%; padding: 13px; margin-top: 10px; background: #f2f2f2; border-radius: 8px; font-size: 15px; color: #222; }
.set-btn.danger { color: #e74c3c; }

/* 时钟 */
.clock-page { text-align: center; color: #fff; margin-top: 100px; }
.clock-big { font-size: 80px; font-weight: 200; }
.clock-note { margin-top: 20px; font-size: 14px; color: #888; }

/* ============ 移动端全屏温馨提示 ============ */
#fs-tip { background: rgba(0,0,0,.82); z-index: 25; }
.fs-box { pointer-events: auto; width: 86%; max-width: 420px; background: #1b1b1e; border: 1px solid #333; border-radius: 14px; padding: 28px 24px 22px; text-align: center; box-shadow: 0 16px 50px rgba(0,0,0,.7); }
.fs-title { font-size: 19px; font-weight: 700; letter-spacing: 1px; margin-bottom: 14px; }
.fs-desc { font-size: 15px; line-height: 1.8; color: #c9c9cf; margin: 0 0 26px; }
#fs-go { display: block; width: 100%; background: #e8e2d4; color: #1a1a1a; letter-spacing: 1px; }
.fs-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; font-size: 13px; }
#fs-count { color: #8a8a90; }
#fs-skip { background: none; color: #8ec5ff; font-size: 13px; padding: 6px 0 6px 12px; }

/* ============ 手机 UI 关闭按钮 ============ */
.phone-exit { position: absolute; top: 44px; right: 14px; z-index: 8; width: 30px; height: 30px; line-height: 28px; text-align: center; border-radius: 50%; background: #e74c3c; color: #fff; font-size: 22px; font-weight: 300; padding: 0; box-shadow: 0 2px 8px rgba(0,0,0,.5); pointer-events: auto; }
.phone-exit:active { transform: scale(.9); }

/* ============ 退出 ============ */
#exit-screen { background: #000; z-index: 50; }
.exit-box { text-align: center; }
.exit-title { font-size: 30px; font-weight: 700; margin-bottom: 16px; }
.exit-box p { color: #999; margin-bottom: 40px; }
#exit-back { background: #444; color: #fff; }

/* ============ toast ============ */
#toast { position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(0,0,0,.8); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 14px; z-index: 60; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

/* ============ 窄屏适配 ============ */
@media (max-width: 420px) {
  .town-title { font-size: 52px; }
  .app-icon { width: 50px; height: 50px; }
  .joystick { width: 100px; height: 100px; }
}
