/* =====================================================================
   KINGDOMFALL — phone & tablet layout (html.touch)
   Compact HUD + on-screen controls. Only applies when Touch.js enables it.
   ===================================================================== */
#touchUI { display: none; }
html.touch, html.touch body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html.touch canvas { touch-action: none; }
html.touch #touchUI { display: block; position: fixed; inset: 0; z-index: 40; pointer-events: none; touch-action: none; font-family: var(--display, serif); }
#touchUI #tZone { position: absolute; inset: 0; pointer-events: none; }
#touchUI.play #tZone { pointer-events: auto; }
#touchUI #tBtns, #touchUI #tTop, #touchUI #tStick { opacity: 0; transition: opacity .3s; }
#touchUI.play #tBtns, #touchUI.play #tTop { opacity: 1; }

/* ---------------------------------------------------------------- joystick */
#tStick { position: absolute; left: 110px; top: 70%; width: 0; height: 0; pointer-events: none; }
#touchUI.play #tStick { opacity: .38; }
#touchUI.play #tStick.on { opacity: 1; }
#tStick .base { position: absolute; left: -62px; top: -62px; width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle, rgba(20,14,8,.25), rgba(20,14,8,.55) 70%); border: 2px solid rgba(240,208,138,.55); box-shadow: 0 0 20px rgba(0,0,0,.5), inset 0 0 18px rgba(240,208,138,.15); }
#tStick .knob { position: absolute; left: 0; top: 0; width: 56px; height: 56px; border-radius: 50%; transform: translate(-50%,-50%);
  background: radial-gradient(circle at 40% 35%, #fff2c8, #d8a850 55%, #7a5420); box-shadow: 0 0 0 2px #1a1208, 0 4px 12px rgba(0,0,0,.6); }
#tStick.run .base { border-color: #ffd27a; box-shadow: 0 0 24px rgba(255,200,100,.6), inset 0 0 18px rgba(255,200,100,.3); }

/* ---------------------------------------------------------------- buttons */
#tBtns { position: absolute; right: 0; bottom: 0; width: 0; height: 0; }
#touchUI.play #tBtns .tb { pointer-events: auto; }
.tb { position: absolute; border-radius: 50%; display: grid; place-items: center; color: #ffe6b0; font-size: 22px; line-height: 1;
  background: radial-gradient(circle at 50% 30%, rgba(70,52,34,.85), rgba(16,11,8,.85) 70%); border: 2px solid rgba(201,164,92,.85);
  box-shadow: 0 0 0 2px rgba(10,8,6,.8), 0 6px 16px rgba(0,0,0,.55), inset 0 0 14px rgba(0,0,0,.6); text-shadow: 0 1px 3px #000; overflow: hidden; }
.tb.on { transform: scale(.92); border-color: #ffe7a8; box-shadow: 0 0 0 2px rgba(10,8,6,.8), 0 0 22px rgba(255,210,120,.7), inset 0 0 18px rgba(255,200,100,.35); }
.tb img { position: absolute; inset: 12%; width: 76%; height: 76%; object-fit: contain; display: none; pointer-events: none; }
.tb.has img { display: block; }
.tb.has > span { display: none; }
.tb .cd { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; background: conic-gradient(rgba(0,0,0,.72) var(--cd, 0%), transparent 0); }
.tb .cdt { position: absolute; left: 0; right: 0; bottom: 14%; text-align: center; font: 700 12px/1 var(--display, serif); color: #fff; text-shadow: 0 1px 3px #000; pointer-events: none; }
.tb.nomana { filter: saturate(.3) brightness(.7); }
.tb.big { width: 88px; height: 88px; right: 22px; bottom: 26px; font-size: 38px; border-width: 3px;
  background: radial-gradient(circle at 50% 30%, rgba(150,40,30,.9), rgba(40,8,6,.9) 72%); }
#tb_heavy { width: 60px; height: 60px; right: 22px; bottom: 128px; font-size: 26px; }
#tb_dodge { width: 60px; height: 60px; right: 124px; bottom: 20px; font-size: 26px; }
#tb_guard { width: 50px; height: 50px; right: 104px; bottom: 100px; }
#tb_lock  { width: 46px; height: 46px; right: 196px; bottom: 26px; }
#tb_jump  { width: 42px; height: 42px; right: 190px; bottom: 82px; font-size: 18px; }
#tb_heal  { width: 48px; height: 48px; right: 92px; bottom: 164px; }
#tb_swap  { width: 38px; height: 38px; right: 30px; bottom: 202px; font-size: 16px; }
.tb.spell { width: 50px; height: 50px; bottom: 22px; font-size: 16px; border-radius: 12px; }
#tb_s1 { right: 256px; } #tb_s2 { right: 314px; } #tb_s3 { right: 372px; } #tb_s4 { right: 430px; }
.tb.spell .cd { border-radius: 12px; }
#tb_ult { right: 256px; bottom: 80px; border-radius: 50%; border-color: #ff9a5a; }
#tb_ult.ready { box-shadow: 0 0 0 2px rgba(10,8,6,.8), 0 0 22px rgba(255,120,60,.9); animation: tUlt 1s ease-in-out infinite alternate; }
@keyframes tUlt { to { box-shadow: 0 0 0 2px rgba(10,8,6,.8), 0 0 34px rgba(255,140,60,1); } }
.tb.spell:not(.has) { opacity: .35; }

/* ---------------------------------------------------------------- top bar & misc */
#tTop { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin-top: 34px; display: flex; gap: 8px; }
#touchUI.play #tTop .tt { pointer-events: auto; }
.tt { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; color: #ffe6b0;
  background: rgba(16,11,8,.72); border: 1px solid rgba(201,164,92,.7); box-shadow: 0 3px 10px rgba(0,0,0,.5); }
#tSkip { position: absolute; right: 16px; top: 16px; padding: 10px 16px; border-radius: 20px; font-size: 14px; color: #ffe6b0; background: rgba(16,11,8,.72); border: 1px solid rgba(201,164,92,.7); display: none; pointer-events: auto; }
#touchUI.cine #tSkip { display: block; }
#tRotate { display: none; }
@media (orientation: portrait) {
  html.touch #tRotate { display: grid; place-content: center; text-align: center; position: fixed; inset: 0; pointer-events: auto; z-index: 99;
    background: radial-gradient(circle at 50% 40%, #2a1a10, #07050a); color: #f0d08a; font-size: 18px; letter-spacing: .08em; }
  html.touch #tRotate div { font-size: 64px; animation: tRot 1.6s ease-in-out infinite; }
  @keyframes tRot { 50% { transform: rotate(90deg); } }
}

/* ---------------------------------------------------------------- compact HUD */
html.touch #chat, html.touch #actionbar, html.touch #micro, html.touch #fps { display: none !important; }
html.touch #vitals { transform: scale(.78); transform-origin: 0 0; left: max(8px, env(safe-area-inset-left)) !important; top: 6px !important; }
html.touch #ui .uframe.target { transform: scale(.7); transform-origin: 0 0; left: max(8px, env(safe-area-inset-left)) !important; top: 78px !important; }
html.touch #ui .uframe.target:not(.show) { opacity: 0 !important; }
html.touch #mmWrap { transform: scale(.66); transform-origin: 100% 0; right: max(4px, env(safe-area-inset-right)) !important; top: 2px !important; }
html.touch #mmWrap .mmBtn { display: none; }
html.touch #compass { transform: translateX(-50%) scale(.72) !important; transform-origin: 50% 0; top: 2px !important; }
html.touch #tracker { top: 160px !important; right: max(6px, env(safe-area-inset-right)) !important; width: 190px !important; transform: scale(.82); transform-origin: 100% 0; max-height: 34vh; overflow: hidden; }
html.touch #tracker #trackOther { display: none; }
html.touch #prompt { bottom: auto !important; top: 58%; left: 50%; transform: translateX(-50%) !important; font-size: 16px; padding: 12px 22px; pointer-events: none; border-color: #ffd27a; box-shadow: 0 0 22px rgba(255,200,100,.45); }
html.touch #prompt .kbd { background: #ffd27a; color: #1a1006; border-radius: 12px; padding: 2px 8px; }
html.touch #prompt.on { transform: translateX(-50%) scale(.95) !important; }
html.touch #hint { top: 70px !important; font-size: 13px !important; max-width: 70vw !important; padding: 8px 12px !important; }
html.touch #toasts { left: 10px !important; bottom: auto !important; top: 110px; transform: scale(.8); transform-origin: 0 0; }
html.touch #subtitle { bottom: 30%; font-size: 16px; max-width: 70vw; }
html.touch #boss { bottom: auto !important; top: 40px; width: 56vw !important; transform: translateX(-50%) scale(.8); transform-origin: 50% 0; }
html.touch #callout { font-size: 28px; }
html.touch #areaTitle .t { font-size: 28px; }
html.touch #areaTitle .s { font-size: 14px; }
html.touch #dialogue { font-size: 15px; max-width: 92vw; }
html.touch #dialogue .choice { padding: 10px 14px; margin: 6px 0; }
html.touch #letterbox-skip { display: none; }
html.touch .ehp { transform: scale(.85); }

/* phones: everything is drawn on a 1180px virtual screen (≈0.7× real size) → bigger thumbs targets */
html.phone #tBtns { zoom: 1.3; }
html.phone #tTop { zoom: 1.3; }
html.phone #tStick .base { left: -80px; top: -80px; width: 160px; height: 160px; }
html.phone #tStick .knob { width: 72px; height: 72px; }
html.phone #prompt { font-size: 22px !important; padding: 16px 28px; }
html.phone #hint { font-size: 17px !important; }
html.phone .fe-brand { top: 4vh; }
html.phone .fe-brand .logoimg { width: min(420px, 34vw); }
html.phone .login-screen .fe-panel.login { left: auto; right: 4vw; top: 5vh; max-height: 90vh; width: 440px; padding: 18px 24px; }
html.phone .lform label { margin-bottom: 8px; }
html.phone .lform input, html.phone .guest input { padding: 8px 12px; }
html.phone .orline { margin: 10px 0 8px; }
html.phone .fe-menu { top: 29vh; width: 660px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
html.phone .fe-menu .btn { padding: 10px 16px !important; min-height: 0 !important; }
html.touch .fe-foot { display: none; }
html.phone .hs-list { top: 15vh; gap: 6px; width: 230px; }
html.phone .hs-list > * { padding-top: 6px !important; padding-bottom: 6px !important; min-height: 0 !important; }
html.phone .hs-arrows { display: none; }
html.phone .hs-info { top: 18vh; width: 340px; max-height: 60vh; padding: 16px 18px; }
html.phone .hs-info .quote { font-size: 16px; }
html.phone .hs-info .lore { font-size: 14px; }
html.phone .hs-actions { bottom: 4vh; }
html.phone .hs-actions .btn.big { padding: 12px 26px !important; font-size: 16px !important; }
html.phone .hs-title { top: 3vh; }
#tb_bomb { width: 44px; height: 44px; right: 160px; bottom: 150px; }
