:root { --wood: #3b2a1c; --cream: #f4ead6; --gold: #f2c15c; --ink: #1d2620; --panel: rgba(24, 30, 26, 0.86); --line: rgba(244, 234, 214, 0.18); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111; color: var(--cream); font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none; }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; font-weight: 600; color: var(--ink); background: linear-gradient(#f6d58a, #e2aa47); border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer; box-shadow: 0 2px 0 #8a5d1e, 0 4px 12px rgba(0,0,0,.3); }
button:active { transform: translateY(1px); }
button.ghost { background: rgba(244,234,214,0.12); color: var(--cream); box-shadow: inset 0 0 0 1px var(--line); }
button:disabled { opacity: .45; cursor: default; }
.small { font-size: 13px; opacity: .8; }
body.touch .pc-only, body:not(.touch) .touch-only { display: none !important; }
.ov { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 20; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.ov.show { display: flex; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }

/* title */
#title { background: linear-gradient(90deg, rgba(14,12,20,.78), rgba(14,12,20,.35) 55%, rgba(0,0,0,0) 80%), linear-gradient(0deg, rgba(10,8,12,.55), rgba(0,0,0,0) 35%); justify-content: flex-start; }
.tpanel { width: min(400px, 46vw); margin-left: clamp(0px, 5vw, 80px); display: flex; flex-direction: column; align-items: center; text-align: center; }
.temblem { width: clamp(72px, 19vh, 150px); height: auto; filter: drop-shadow(0 6px 18px rgba(0,0,0,.55)); animation: tfloat 5s ease-in-out infinite; }
@keyframes tfloat { 50% { transform: translateY(-5px); } }
.tpanel h1 { font: 700 clamp(40px, min(9vw, 13vh), 78px)/1 Georgia, "Times New Roman", serif; margin: 4px 0 0; color: #fff3d6; letter-spacing: 1px; text-shadow: 0 3px 18px rgba(0,0,0,.6); white-space: nowrap; }
.tpanel .tag { color: var(--gold); font-weight: 600; letter-spacing: 2px; text-transform: uppercase; font-size: clamp(10px, 1.6vh, 13px); margin: 6px 0 clamp(10px, 3vh, 22px); }
.tbtns { display: flex; flex-direction: column; gap: clamp(6px, 1.4vh, 10px); width: min(300px, 100%); }
.tbtns button { font-size: clamp(15px, 2.6vh, 18px); padding: clamp(8px, 1.8vh, 12px) 20px; display: flex; flex-direction: column; align-items: center; min-height: 44px; justify-content: center; }
.tbtns button small { font-size: 12px; font-weight: 500; opacity: .75; margin-top: 2px; }
.thelp { opacity: .55; margin-top: 12px; }
button:focus-visible { outline: 3px solid #fff3d6; outline-offset: 2px; }
#title .ver { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); font-size: 12px; opacity: .5; letter-spacing: 1px; }

/* pause, settings, about, dialog */
#pause, #settings, #about, #dlg { background: rgba(8,10,8,.55); }
#pause { z-index: 26; } #settings, #about { z-index: 45; } #dlg { z-index: 50; }
.ppanel { background: var(--panel); border-radius: 16px; padding: 18px 20px; width: min(340px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.5); text-align: center; }
.ppanel.wide { width: min(520px, 100%); text-align: left; }
.ppanel h2 { margin: 0 0 12px; font-family: Georgia, serif; color: #fff3d6; }
.ppanel .mtop h2 { margin: 0; }
.pbtns { display: flex; flex-direction: column; gap: 8px; } .pbtns button { min-height: 44px; font-size: 16px; }
.pbtns.row { flex-direction: row; } .pbtns.row button { flex: 1; }
#p-info { opacity: .7; margin: 12px 0 0; font-size: 12px; }
#dlg p { margin: 0 0 16px; opacity: .9; }
#s-body { margin-top: 12px; padding-right: 4px; }
.srow { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.srow > span { display: flex; justify-content: space-between; font-weight: 600; } .srow b { color: var(--gold); }
.srow.chk { flex-direction: row; justify-content: space-between; align-items: center; cursor: pointer; }
.srow input[type=range] { width: 100%; height: 28px; accent-color: #e2aa47; }
.srow input[type=checkbox] { width: 24px; height: 24px; accent-color: #e2aa47; }
.seg { display: flex; gap: 6px; } .seg button { flex: 1; padding: 9px 6px; min-height: 40px; }
.seg button:not(.on) { background: rgba(244,234,214,0.1); color: var(--cream); box-shadow: inset 0 0 0 1px var(--line); }
.snote { opacity: .65; font-size: 12px; margin: 6px 0 0; }
#about .help { margin-top: 10px; }

/* in-game menu button + fps */
#b-menu { position: absolute; z-index: 3; pointer-events: auto; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 52px; height: 52px; padding: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: rgba(20,26,20,.72); color: #fff3d6; box-shadow: inset 0 0 0 2px rgba(244,234,214,.35), 0 3px 10px rgba(0,0,0,.3); }
#b-menu:active { background: rgba(242,193,92,.8); color: #111; }
body:not([data-mode=play]) #b-menu { display: none; }
#fps { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); top: max(4px, env(safe-area-inset-top)); font: 600 12px ui-monospace, monospace; background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 6px; display: none; pointer-events: none; }

/* starter pick */
#starter { background: rgba(12,16,12,.55); }
.spanel { background: var(--panel); border-radius: 16px; padding: 18px; max-width: 980px; width: 100%; max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.spanel h2 { margin: 0 0 4px; font-family: Georgia, serif; }
#scards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
.scard { background: rgba(244,234,214,.07); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); }
.scard img { width: 100%; max-height: 160px; object-fit: contain; background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.18), rgba(255,255,255,0) 70%); }
.scard h3 { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.scard p { margin: 0; font-size: 13px; opacity: .85; flex: 1; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #111; vertical-align: middle; }
@media (max-width: 700px), (max-height: 500px) { #scards { grid-template-columns: repeat(3, minmax(180px, 1fr)); overflow-x: auto; } .scard img { max-height: 90px; } }

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 5; }
#hud.show { display: block; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 0 3px #000; }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 6px 14px; border-radius: 999px; font-weight: 600; display: none; white-space: nowrap; }
#topl { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 6px; }
#area, #items { background: rgba(0,0,0,.42); padding: 4px 10px; border-radius: 8px; font-size: 13px; width: max-content; }
#partyhud { display: flex; flex-direction: column; gap: 3px; }
.ph { display: flex; align-items: center; gap: 6px; font-size: 12px; background: rgba(0,0,0,.35); padding: 2px 8px 2px 4px; border-radius: 8px; width: 170px; }
.ph img { width: 24px; height: 24px; }
.ph .hpb { flex: 1; }
.hpb { height: 7px; background: rgba(255,255,255,.18); border-radius: 4px; overflow: hidden; }
.hpb i { display: block; height: 100%; background: #6ad04a; transition: width .35s; }
.hpb i.mid { background: #e8c23a; } .hpb i.low { background: #e5533a; }
#sneakind { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); color: #cfe8b0; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: 12px; display: none; text-shadow: 0 1px 3px #000; }
#tag { position: absolute; transform: translate(-50%, -100%); text-align: center; display: none; text-shadow: 0 1px 3px #000; font-size: 13px; white-space: nowrap; }
#tag .al { width: 64px; height: 5px; margin: 3px auto 0; background: rgba(255,255,255,.25); border-radius: 3px; overflow: hidden; }
#tag .al i { display: block; height: 100%; width: 0; background: #ffcc33; }
#tag.alarmed .al i { background: #ff5a3a; }
#toast { position: fixed; z-index: 60; pointer-events: none; left: 50%; top: 16%; transform: translateX(-50%); background: rgba(20,26,20,.85); padding: 8px 16px; border-radius: 10px; opacity: 0; transition: opacity .3s; max-width: 86vw; text-align: center; font-weight: 600; }
#toast.on { opacity: 1; }
#keys { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; opacity: .7; background: rgba(0,0,0,.35); padding: 3px 10px; border-radius: 6px; white-space: nowrap; }
#clickhint { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 8px 16px; border-radius: 10px; display: none; }

/* touch */
#touch { position: absolute; inset: 0; pointer-events: auto; display: none; touch-action: none; }
body.touch #touch { display: block; }
body.touch #crosshair { opacity: .6; }
#stick { position: absolute; left: 18%; top: 70%; width: 112px; height: 112px; margin: -56px; border-radius: 50%; background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25); opacity: .55; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(255,255,255,.45); }
.tb { position: absolute; width: 64px; height: 64px; border-radius: 50%; padding: 0; font-size: 13px; background: rgba(30,36,30,.55); color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.tb.down, .tb.lit { background: rgba(242,193,92,.75); color: #111; }
.tb.big { width: 86px; height: 86px; font-size: 15px; right: max(22px, env(safe-area-inset-right)); bottom: max(28px, env(safe-area-inset-bottom)); }
#b-sneak { right: max(120px, calc(env(safe-area-inset-right) + 100px)); bottom: 30px; }
#b-sprint { right: max(24px, env(safe-area-inset-right)); bottom: 130px; }
body.touch #keys { display: none; }

/* encounter */
#encounter { position: fixed; left: 0; right: 0; bottom: 0; display: none; justify-content: center; z-index: 15; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
#encounter.show { display: flex; }
.epanel { background: var(--panel); border-radius: 14px; padding: 14px; width: min(520px, 100%); box-shadow: 0 6px 30px rgba(0,0,0,.4); }
.ehead { display: flex; gap: 12px; align-items: center; }
.ehead img { width: 64px; height: 64px; }
#e-name { font: 700 20px Georgia, serif; }
#e-text { margin: 8px 0 12px; font-size: 14px; }
.ebtns { display: flex; gap: 8px; flex-wrap: wrap; }
.ebtns button { flex: 1; min-width: 90px; }

/* battle */
#battle { position: fixed; inset: 0; display: none; z-index: 15; pointer-events: none; }
#battle.show { display: block; }
.bcard { position: absolute; background: var(--panel); border-radius: 12px; padding: 8px 12px; width: min(300px, 44vw); box-shadow: 0 4px 20px rgba(0,0,0,.35); }
.bcard.foe { left: max(12px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); }
.bcard.ally { right: max(12px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); }
.bcard .nm { font-weight: 700; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.bcard .hpb { height: 9px; margin: 5px 0 2px; }
.bcard .sm { font-size: 12px; opacity: .8; display: flex; justify-content: space-between; }
.xpb { height: 4px; background: rgba(255,255,255,.15); border-radius: 2px; overflow: hidden; margin-top: 3px; } .xpb i { display: block; height: 100%; background: #6ab8ff; transition: width .4s; }
#bbottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
#blog { flex: 1; background: var(--panel); border-radius: 12px; padding: 10px 14px; min-height: 64px; font-size: 16px; font-weight: 500; }
#bacts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(420px, 52vw); }
#bacts button { padding: 12px 8px; font-size: 15px; min-height: 48px; }
#bacts button .mi { display: block; font-size: 11px; font-weight: 500; opacity: .85; }
#bacts button.mv { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
@media (orientation: portrait) and (hover: hover) { #bbottom { flex-direction: column; align-items: stretch; } #bacts { width: 100%; } .bcard { width: calc(50vw - 18px); } }
#timing { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(460px, 86vw); display: none; text-align: center; pointer-events: auto; }
#timing.show { display: block; }
#timing .tlbl { font: 700 22px Georgia, serif; text-shadow: 0 2px 6px #000; margin-bottom: 8px; }
.tbar { position: relative; height: 30px; border-radius: 15px; background: rgba(0,0,0,.6); box-shadow: inset 0 0 0 2px rgba(255,255,255,.4); overflow: hidden; }
.tbar .good { position: absolute; top: 0; bottom: 0; background: rgba(242,193,92,.55); }
.tbar .perf { position: absolute; top: 0; bottom: 0; background: rgba(255,240,170,.95); }
.tbar .mk { position: absolute; top: -2px; bottom: -2px; width: 6px; margin-left: -3px; background: #fff; box-shadow: 0 0 8px #fff; border-radius: 3px; }
#timing.defend .good { background: rgba(110,180,255,.55); } #timing.defend .perf { background: rgba(200,230,255,.95); }
#timing .thint { font-size: 13px; margin-top: 6px; opacity: .85; text-shadow: 0 1px 3px #000; }
.float { position: absolute; font: 800 26px Georgia, serif; color: #fff; text-shadow: 0 2px 6px #000; pointer-events: none; animation: fl 1s ease-out forwards; transform: translate(-50%, -50%); }
@keyframes fl { to { opacity: 0; margin-top: -50px; } }

/* menu */
#menu { background: rgba(10,14,10,.5); z-index: 25; }
.mpanel { background: var(--panel); border-radius: 16px; width: min(900px, 100%); height: min(640px, 100%); display: flex; flex-direction: column; padding: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.mtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mtop h2 { margin: 0; font-family: Georgia, serif; }
#m-tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
#m-tabs button { padding: 7px 14px; }
#m-tabs button:not(.on) { background: rgba(244,234,214,0.1); color: var(--cream); box-shadow: inset 0 0 0 1px var(--line); }
#m-body { flex: 1; min-height: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.mc { background: rgba(244,234,214,.07); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; gap: 10px; }
.mc img { width: 72px; height: 72px; flex: none; }
.mc .b { flex: 1; min-width: 0; }
.mc .nm { font-weight: 700; font-size: 16px; }
.mc .sm { font-size: 12px; opacity: .85; }
.mc .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.mc .acts button { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.hearts { color: #ff7d93; letter-spacing: 1px; } .hearts .e { color: rgba(255,255,255,.25); }
.sec { font: 700 14px system-ui; text-transform: uppercase; letter-spacing: 1.5px; opacity: .75; margin: 14px 0 8px; }
.logc { background: rgba(244,234,214,.07); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; gap: 10px; }
.logc img { width: 64px; height: 64px; flex: none; }
.logc.unseen img { filter: brightness(0) opacity(.5); }
.logc .sm { font-size: 12px; opacity: .85; }
.actrow { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.help p { margin: 6px 0; } .help b { color: var(--gold); }

/* evolve + whats new */
#evolve { background: radial-gradient(circle, rgba(60,50,20,.85), rgba(5,5,5,.92)); z-index: 30; }
.evbox { text-align: center; } .evlbl { font: 700 22px Georgia, serif; min-height: 30px; }
.evimg img { width: min(280px, 60vw, 48vh); height: min(280px, 60vw, 48vh); transition: filter .6s; }
.evimg img.flash { filter: brightness(6) saturate(0); }
#whatsnew { background: rgba(0,0,0,.55); z-index: 40; }
.wnbox { background: var(--panel); border-radius: 16px; padding: 18px 22px; max-width: 460px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.wnbox h2 { margin: 0 0 4px; font-family: Georgia, serif; color: var(--gold); }
.wnbox h3 { margin: 6px 0; font-size: 15px; }
.wnbox ul { padding-left: 20px; margin: 6px 0 14px; } .wnbox li { margin: 4px 0; }
#fatal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 20px; background: #111; z-index: 99; }

/* v0.2: landscape-only on touch devices */
#rotate { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; text-align: center; color: #fff3d6;
  background: radial-gradient(circle at 50% 38%, #2a4a39, #0d1813 75%); padding: 24px calc(24px + env(safe-area-inset-right)) 24px calc(24px + env(safe-area-inset-left)); }
body.rot #rotate { display: flex; }
.rbox { max-width: 320px; } .rbox h2 { font: 700 28px Georgia, serif; margin: 8px 0 6px; } .rbox p { margin: 0; opacity: .85; line-height: 1.4; }
.rphone { width: 170px; height: 170px; }
.rdev { transform-origin: 100px 100px; animation: rturn 2.6s ease-in-out infinite; }
@keyframes rturn { 0%, 20% { transform: rotate(0); } 50%, 75% { transform: rotate(90deg); } 100% { transform: rotate(0); } }
#settings, #about, #dlg { background: rgba(8,10,8,.82); }
.ppanel { overflow-y: auto; }
@media (max-height: 520px) {
  .ppanel { padding: 12px 16px; }
  .ppanel h2 { margin-bottom: 8px; font-size: 20px; }
  #pause .ppanel { width: min(440px, 100%); }
  #pbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #pbtns [data-p=resume] { grid-column: 1 / -1; }
  #p-info { margin-top: 8px; }
}
