* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #05030a; color: #e8e4f0; overflow: hidden; font-family: "Trebuchet MS", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#cv { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #000; box-shadow: 0 0 40px #000; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; }
#title { background: radial-gradient(ellipse at 70% 25%, #3a2050 0%, #120a22 45%, #05030a 100%); overflow: hidden; }
#title .moon { position: absolute; right: 12%; top: 8%; width: 18vmin; height: 18vmin; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fff8e8, #e8d8b8 60%, #b8a888); box-shadow: 0 0 60px 20px rgba(255,240,210,.25); }
#title::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 38%; background:
  linear-gradient(transparent 0 30%, #0a0614 30%) 10% 0 / 12% 100% no-repeat, linear-gradient(transparent 0 10%, #0a0614 10%) 26% 0 / 8% 100% no-repeat,
  linear-gradient(transparent 0 45%, #0a0614 45%) 38% 0 / 20% 100% no-repeat, linear-gradient(transparent 0 0%, #0a0614 0%) 64% 0 / 5% 100% no-repeat,
  linear-gradient(transparent 0 35%, #0a0614 35%) 70% 0 / 16% 100% no-repeat, linear-gradient(#0a0614, #0a0614) 0 100% / 100% 30% no-repeat; pointer-events: none; }
.logo { text-align: center; z-index: 1; margin-bottom: 4vh; }
.logo .l1 { font-size: clamp(36px, 9vmin, 84px); font-weight: bold; letter-spacing: .08em; color: #f0e8ff; text-shadow: 0 0 18px #8a3ac8, 0 4px 0 #3a1050; font-family: "Times New Roman", "Microsoft JhengHei", serif; }
.logo .l2 { font-size: clamp(14px, 3vmin, 26px); color: #d8b060; letter-spacing: .3em; margin-top: 6px; font-family: "Times New Roman", serif; }
.tmenu { display: flex; flex-direction: column; gap: 10px; z-index: 1; width: min(280px, 70vw); }
.tmenu button, .screen > button, .panel .row button, .closeBtn { background: linear-gradient(#3a2858, #22163a); color: #f0e8ff; border: 2px solid #d8b060; border-radius: 6px; padding: 10px 14px; font-size: 18px; letter-spacing: .05em; box-shadow: 0 3px 0 #0a0614; }
.tmenu button:hover, .screen > button:hover { filter: brightness(1.3); }
.tmenu button:disabled { opacity: .35; cursor: default; }
.row { display: flex; gap: 10px; justify-content: center; }
.tmenu .small { flex: 1; font-size: 14px; padding: 6px; }
.tmenu .small.on { background: #d8b060; color: #22163a; }
.ver { position: absolute; right: 10px; bottom: 8px; font-size: 11px; opacity: .4; z-index: 1; }

.panel { background: rgba(8,4,16,.92); padding: 20px; overflow-y: auto; justify-content: flex-start; padding-top: max(20px, env(safe-area-inset-top)); }
.panel h2 { color: #d8b060; margin: 10px 0; font-family: "Times New Roman", "Microsoft JhengHei", serif; letter-spacing: .1em; }
.panel p { max-width: 640px; line-height: 1.6; }
.closeBtn { margin-top: 14px; }

#dialog { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%); width: min(720px, 94vw); min-height: 96px; background: rgba(10,6,22,.94); border: 2px solid #d8b060; border-radius: 6px; padding: 12px 16px 14px; z-index: 20; box-shadow: 0 6px 24px #000; cursor: pointer; }
#dialog .who { color: #d8b060; font-weight: bold; margin-bottom: 6px; font-size: 15px; }
#dialog .text { font-size: 17px; line-height: 1.55; min-height: 2.4em; }
#dialog .more { position: absolute; right: 12px; bottom: 6px; color: #d8b060; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }

#toasts { position: absolute; top: 12%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 15; pointer-events: none; }
.toast { background: rgba(10,6,22,.88); border: 1px solid #d8b060; color: #f4ecff; padding: 6px 14px; border-radius: 4px; font-size: 15px; animation: tin .25s ease-out; display: flex; align-items: center; gap: 8px; }
.toast canvas { width: 24px; height: 24px; image-rendering: pixelated; }
.toast.big { font-size: 18px; padding: 10px 18px; border-width: 2px; }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }
#areaName { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); font-size: clamp(20px, 4vmin, 34px); color: #f0e8ff; text-shadow: 0 0 12px #8a3ac8, 0 2px 0 #000; font-family: "Times New Roman", "Microsoft JhengHei", serif; letter-spacing: .15em; pointer-events: none; z-index: 14; animation: area 2.6s ease forwards; }
@keyframes area { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

#menu .tabs, #shop .tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 10px; align-items: center; }
.tabs button { background: #22163a; color: #c8c0d8; border: 1px solid #5a4a7a; border-radius: 4px; padding: 7px 12px; font-size: 15px; }
.tabs button.on { background: #d8b060; color: #1a1028; border-color: #d8b060; }
.goldLbl { color: #ffd76a; margin-left: 10px; }
#menu .body, #shop .body { width: min(680px, 96vw); }
.stat { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; }
.stat div { display: flex; justify-content: space-between; border-bottom: 1px solid #2a2040; padding: 3px 0; }
.stat b { color: #d8b060; font-weight: normal; }
.list { display: flex; flex-direction: column; gap: 4px; }
.it { display: flex; align-items: center; gap: 10px; background: #160e26; border: 1px solid #2a2040; border-radius: 4px; padding: 6px 10px; cursor: pointer; }
.it:hover { border-color: #8a6ab0; }
.it.eq { border-color: #d8b060; }
.it canvas { width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
.it .nm { flex: 1; }
.it .sm { font-size: 12px; color: #a898c0; }
.it .pr { color: #ffd76a; }
.it.dis { opacity: .4; }
.sect { color: #d8b060; margin: 12px 0 6px; font-size: 14px; letter-spacing: .1em; }
#mapCv { width: 100%; max-width: 680px; background: #0a0c18; border: 1px solid #2a2040; display: block; margin: 0 auto; }
.maphelp { text-align: center; font-size: 13px; color: #a898c0; margin-top: 6px; }
#shop .msg { min-height: 1.4em; color: #ffd76a; margin-top: 8px; }

#over { background: rgba(30,0,8,.82); gap: 14px; }
#over .big, #ending .big { font-size: clamp(28px, 6vmin, 52px); color: #ff6a7a; font-family: "Times New Roman", "Microsoft JhengHei", serif; letter-spacing: .1em; margin-bottom: 16px; text-shadow: 0 0 16px #a01020; }
#ending { background: radial-gradient(ellipse at 50% 30%, #3a3060, #0a0614); gap: 12px; }
#ending .big { color: #f8f0ff; text-shadow: 0 0 20px #d8b060; }
#ending .stats { font-size: 18px; line-height: 1.8; text-align: center; }

#touch { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
#pad { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18); pointer-events: auto; touch-action: none; }
#pad .knob { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: rgba(216,176,96,.35); border: 2px solid rgba(216,176,96,.6); }
#btns { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); width: 220px; height: 170px; pointer-events: none; }
.tb { position: absolute; border-radius: 50%; background: rgba(40,24,70,.55); border: 2px solid rgba(216,176,96,.55); color: #f0e8ff; font-size: 16px; pointer-events: auto; touch-action: none; }
.tb.on { background: rgba(216,176,96,.6); }
.tb.big1 { width: 76px; height: 76px; right: 92px; bottom: 6px; font-size: 20px; }
.tb.big2 { width: 76px; height: 76px; right: 6px; bottom: 50px; font-size: 20px; }
.tb.s1 { width: 50px; height: 50px; right: 172px; bottom: 90px; }
.tb.s2 { width: 50px; height: 50px; right: 30px; bottom: 134px; }
.tb.s3 { width: 50px; height: 50px; right: 110px; bottom: 98px; }
#topBtns { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; pointer-events: auto; }
.tt { width: 44px; height: 44px; border-radius: 8px; background: rgba(20,12,36,.6); border: 1px solid rgba(216,176,96,.5); color: #fff; font-size: 20px; }
.gpf { outline: 3px solid #ffe070 !important; outline-offset: 2px; box-shadow: 0 0 14px rgba(255,224,112,.6) !important; }

/* v2: equipment, item cards, warp */
.tb.s4 { width: 50px; height: 50px; right: 176px; bottom: 150px; }
#warp .body { width: min(520px, 96vw); max-height: 60vh; overflow: auto; }
.doll { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px; }
.doll .slot { min-height: 40px; }
.noicon { width: 24px; text-align: center; color: #5a4a7a; flex: none; }
.card { background: #120a20; border: 1px solid #8a6ab0; border-radius: 6px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.card .cname { font-size: 19px; margin-bottom: 6px; }
.card .cname small { display: block; font-size: 12px; color: #a898c0; }
.card .cl { font-size: 14px; line-height: 1.45; }
.card .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card button, #warp button, .stat .plus { background: #22163a; color: #f0e8ff; border: 1px solid #8a6ab0; border-radius: 4px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
.card button:disabled { opacity: .4; }
.stat .plus { padding: 0 8px; margin-left: 8px; color: #6aff6a; }

/* gallery */
#dex .dbody, .dexbox .dbody { width: min(680px, 96vw); }
#dex .dbody { max-height: 68vh; overflow: auto; }
.dexbox .dtabs { margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dexlist { display: flex; flex-direction: column; gap: 4px; }
.dx { background: #160e26; border: 1px solid #2a2040; border-radius: 4px; padding: 6px 10px; cursor: pointer; }
.dx:hover, .dx.open { border-color: #8a6ab0; }
.dxh { display: flex; align-items: center; gap: 10px; }
.dxh .nm { flex: 1; }
.dxh canvas { width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
.sprbox { width: 56px; height: 56px; flex: none; background: radial-gradient(circle at 50% 70%, #2a1e44, #120a20 70%); border-radius: 4px; display: block; }
.sprbox canvas.spr { width: 56px; height: 56px; display: block; }
.dxh canvas.shadow { filter: brightness(0) drop-shadow(0 0 1.5px #9a7ac8); }
.unk { color: #7a6a98; letter-spacing: .2em; }
.dxd { margin: 8px 0 2px 4px; border-top: 1px solid #2a2040; padding-top: 6px; cursor: default; }
.dxd .cl { font-size: 14px; line-height: 1.5; }
.dx .sm, #warp .sm { font-size: 12px; color: #a898c0; }
.ok { color: #6aff6a; font-weight: normal; font-size: 13px; }
.dsect { color: #d8b060; font-size: 13px; margin: 8px 0 4px; letter-spacing: .1em; }
.drop { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 2px 0; }
.drop canvas { width: 24px; height: 24px; image-rendering: pixelated; flex: none; }
.drop .dl { width: 7.5em; color: #a898c0; font-size: 12px; flex: none; }
.drop .dn { flex: 1; }
.drop .dp { color: #ffd76a; font-size: 12px; }
.drop canvas.shadow { filter: brightness(0) drop-shadow(0 0 1.5px #9a7ac8); }
.eliteBox { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; padding-top: 8px; border-top: 1px dashed #4a2a3a; }
.sprbox.elite { background: radial-gradient(circle at 50% 70%, #4a1420, #120a20 70%); }
.sprbox.elite canvas:not(.shadow) { filter: drop-shadow(0 0 3px #ff2a2a); }
.sprbox.elite canvas.shadow { filter: brightness(0) drop-shadow(0 0 2px #ff3a3a); }
.elt { color: #ff6a5a; font-weight: normal; font-size: 13px; }
