/* The HUD of phones and tablets in the world (ui/touchpad.js; rebuilt 04.11.2026, user: "clean, lieber weniger anzeigen
   und über Menüs aufrufen", reference the Metin2 mobile HUD). Loaded after imperial.css; nothing here applies on a PC
   (html.touch) except the hidden labels of the menu buttons.
   Scales: the HUD frames (player frame, minimap, quests) keep the art scale (--px), the controls under the thumbs are
   scaled by --tz (~2 CSS px per art px: a 20 px slot = 40 CSS px, the attack button 80), the menu panel and the open
   chat by --wz like the windows.
     bottom left   joystick; above it #tleft: AUTO, pick up, horse, fishing (while possible)
     bottom        right of the joystick the chat button and three faint lines of the chat (a tap opens it)
     bottom right  #tpad: the attack button, quickslots 1-4 on the inner arc, F1-F4 on the outer one (empty ones only
                   while something can be put there: .qs-edit)
     top left      player frame, one row of buffs (+N), the quests (one line until tapped) - the dungeon / rift / arena
                   HUD take their place (top and height set by TouchPad.layout)
     top right     minimap (round, 64 px in a painted ring, no foot); left of it #ttop: the menu button, the world boss and event chips, the
                   ready kettles
     menu panel    #tmenu over a dark back: wallet, the menu bar with labels + "Zur Jagd" / Anti-EXP, the tabs of the
                   left edge (#edge) with their timers */

/* the labels of the menu buttons and of the tabs of the left edge only in the panel (the edge column comes back on the
   character selection with its tabs) */
#ui :is(.mb-l, .et-lbl) { display: none; }

/* ---------- gone from a phone: the PC action bar row, the tabs of the left edge outside the panel ---------- */
html.touch #ui #actionbar { left: 0; right: 0; bottom: 0; transform: none; padding: 0; gap: 0; background: none; box-shadow: none; pointer-events: none; }
html.touch #ui #actionbar .ab-row { display: none; }
/* "talk" next to an NPC (ui/npcprompt.js): a button a finger high in the middle, over the three lines of the chat (they reach the
   middle of the bottom edge) */
html.touch #ui #npc-prompt { z-index: 5; bottom: calc(70px / var(--px)); height: calc(44px / var(--px)); padding: 0 calc(12px / var(--px)); }
html.touch #ui #npc-prompt .np-name { font-size: 9px; }
html.touch #ui #expbar { height: 3px; padding: 0; box-shadow: none; }
/* (its line between the EXP bar and the lines of the chat) */
html.touch #ui #exptext { left: 50%; transform: translateX(-50%); margin-bottom: 1px; font-size: 6px; line-height: 7px; opacity: .85; }
html.touch #ui .mbtn-i .hk, html.touch #ui #quick .slot .key { display: none; }

/* ---------- joystick ---------- */
html.touch #ui #tstick { position: absolute; left: 6px; bottom: 7px; width: 56px; height: 56px; transform: scale(var(--tz)); transform-origin: 0 100%;
  background: url(../assets/ui/touch/stick.png) center / 56px 56px no-repeat; opacity: .72; z-index: 5; }
html.touch #ui #tstick.on { opacity: 1; }
#tstick .knob { position: absolute; left: 16px; top: 16px; width: 24px; height: 24px; pointer-events: none;
  background: url(../assets/ui/touch/knob.png) center / 24px 24px no-repeat; }

/* ---------- round buttons of the thumbs ---------- */
html.touch #ui .tbtn { position: absolute; width: 20px; height: 20px; border-radius: 50%; pointer-events: auto; }
html.touch #ui .tbtn img { display: block; width: 100%; height: 100%; pointer-events: none; }
html.touch #ui .tbtn.on { filter: brightness(1.35); transform: scale(.92); }
html.touch #ui .tbtn.lit { filter: brightness(1.3) drop-shadow(0 0 2px #f2c45a); }
html.touch #ui .tbtn.new::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none; background: radial-gradient(closest-side, #ffd24a88, #ffd24a00); animation: glow-in 1.2s ease-in-out infinite; }

/* ---------- bottom right: attack button and the quickslots on two arcs round it ----------
   #tpad 100 x 100 (scaled by --tz from the bottom right corner); the attack button 40 with its centre at (22, 22) from
   the corner, the inner arc radius 44 (1-4), the outer one 67 (F1-F4), 0 / 30 / 60 / 90 degrees from the left */
html.touch #ui #tpad { position: absolute; right: 4px; bottom: 4px; width: 100px; height: 100px; transform: scale(var(--tz)); transform-origin: 100% 100%;
  pointer-events: none; z-index: 5; }
html.touch #ui #tpad .t-attack { right: 2px; bottom: 2px; width: 40px; height: 40px; }
html.touch #ui #tpad #quick { position: absolute; inset: 0; display: block; pointer-events: none; }
html.touch #ui #tpad #quick .gap { display: none; }
html.touch #ui #tpad #quick .slot { --slot: 20px; position: absolute; width: 20px; height: 20px; pointer-events: auto; background-color: transparent; }
html.touch #ui #tpad #quick .slot[data-q="0"] { right: 56px; bottom: 12px; }
html.touch #ui #tpad #quick .slot[data-q="1"] { right: 50px; bottom: 34px; }
html.touch #ui #tpad #quick .slot[data-q="2"] { right: 34px; bottom: 50px; }
html.touch #ui #tpad #quick .slot[data-q="3"] { right: 12px; bottom: 56px; }
html.touch #ui #tpad #quick .slot[data-q="4"] { right: 79px; bottom: 12px; }
html.touch #ui #tpad #quick .slot[data-q="5"] { right: 70px; bottom: 45px; }
html.touch #ui #tpad #quick .slot[data-q="6"] { right: 45px; bottom: 70px; }
html.touch #ui #tpad #quick .slot[data-q="7"] { right: 12px; bottom: 79px; }
/* empty places only while something can be put there (.qs-edit: inventory or skills open, an item at the finger), then
   faint; the outer arc stays where it is, so a slot never moves */
html.touch #ui #tpad:not(.qs-edit) #quick .slot:is(:not([data-k]), [data-k=""]) { display: none; }
html.touch #ui #tpad #quick .slot:is(:not([data-k]), [data-k=""])::before, html.touch #ui #tpad #quick .slot:is(:not([data-k]), [data-k=""])::after { opacity: .5; }

/* ---------- bottom left: above the joystick AUTO, pick up, horse, fishing ---------- */
html.touch #ui #tleft { position: absolute; left: 5px; bottom: calc(10px + 56px * var(--tz)); display: flex; align-items: flex-end; gap: 4px; pointer-events: none;
  transform: scale(var(--tz)); transform-origin: 0 100%; z-index: 5; }
html.touch #ui #tleft > * { position: relative; flex: none; pointer-events: auto; }
html.touch #ui #tleft .tbtn { position: relative; }
html.touch #ui #tleft #auto-btn { width: 24px; height: 24px; min-width: 0; padding: 0; border-radius: 50%; display: block;
  background: url(../assets/ui/touch/auto.png) center / 100% 100% no-repeat; box-shadow: none; }
html.touch #ui #tleft #auto-btn i { display: none; }
html.touch #ui #tleft #auto-btn span { position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); padding: 0 2px; font-size: 5px; line-height: 6px;
  color: #d8c79f; background: #120e0be6; box-shadow: 0 0 0 1px #6f5634; letter-spacing: .3px; }
html.touch #ui #tleft #auto-btn.on::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; pointer-events: none; background: radial-gradient(closest-side, #ffcf6a88, #ffcf6a00); animation: glow-in 2.4s ease-in-out infinite; }
html.touch #ui #tleft #auto-btn.on span { color: #b6ffa0; box-shadow: 0 0 0 1px #5fb04a; }
html.touch #ui #tleft #ride-btn { width: 20px; height: 20px; padding: 0; border-radius: 50%; background: url(../assets/ui/touch/horse.png) center / 100% 100% no-repeat; box-shadow: none; }
html.touch #ui #tleft #ride-btn i { display: none; }
html.touch #ui #tleft #ride-btn.on { filter: brightness(1.2) drop-shadow(0 0 2px #8fd46a); }
html.touch #ui #tleft :is(#ride-btn, .t-fish).hidden { display: none; }

/* ---------- top right: minimap, left of it the menu button and the chips of the timers ---------- */
/* the minimap round in a painted ring (fal, python tools/art/gen_minimap_ring.py: the hole is 0.774 of the picture -
   84 px round a 64 px map), the map's name under it, no foot (zoom stays as it is) */
html.touch #ui #minimap { width: 84px; padding: 0; background: none; box-shadow: none; display: flex; flex-direction: column; align-items: center; }
html.touch #ui #minimap .mm { order: 1; width: 84px; height: 84px; background: none; box-shadow: none; }
html.touch #ui #minimap canvas { position: absolute; left: 10px; top: 10px; width: 64px; height: 64px; border-radius: 50%; }
html.touch #ui #minimap .mm::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: url(../assets/ui/touch/mm_ring.png) center / 84px 84px no-repeat; }
html.touch #ui #minimap .mhead { order: 2; max-width: 84px; height: 9px; line-height: 9px; margin-top: -2px; color: #ecd7a4; }
html.touch #ui #minimap .mfoot { display: none; }
html.touch #ui #minimap .kst-badge { left: 0; bottom: 0; z-index: 1; }
/* the time of day on the ring, only to look at (its tooltip would cover the minimap) */
html.touch #ui #minimap .dn-badge { left: 1px; top: 1px; width: 15px; height: 15px; pointer-events: none; }
html.touch #ui #minimap .dn-badge img { width: 15px; height: 15px; }
/* the channel on the ring, only to look at: the window comes through the menu (ESC menu, ui/channel.js) */
html.touch #ui #minimap .ch-badge { right: 1px; top: 1px; pointer-events: none; }
html.touch #ui #channel .ch-row { grid-template-columns: minmax(0, 1fr) 34px 66px; min-height: var(--finger); }
html.touch #ui #channel .ch-go { min-height: var(--finger); }
html.touch #ui #ttop { position: absolute; top: 4px; right: 92px; display: flex; flex-direction: row-reverse; align-items: flex-start; gap: 4px; z-index: 6; pointer-events: none; }
/* (narrow screens: two rows - menu + world boss, under them events + kettles - clear of the notices in the middle) */
html.touch #ui.compact #ttop { flex-wrap: wrap; max-width: calc(20px * var(--tz) + 84px); }
html.touch #ui #ttop > * { position: relative; inset: auto; flex: none; margin: 0; transform: none; pointer-events: auto; }
html.touch #ui #ttop > .hidden { display: none; }
html.touch #ui #ttop .t-menu { width: calc(20px * var(--tz)); height: calc(20px * var(--tz)); }
html.touch #ui #ttop :is(#alch-ready, #cook-ready, #ah-ready) { width: calc(20px * var(--tz)); height: calc(20px * var(--tz)); }
html.touch #ui #ttop :is(#alch-ready, #cook-ready, #ah-ready) img { width: 70%; height: 70%; }
html.touch #ui #ttop #wb-timer, html.touch #ui #ttop #ev-box { top: auto !important; width: 76px; padding: 3px 4px; }
html.touch #ui #ttop #wb-timer .wb-bar { margin-top: 1px; }
html.touch #ui #ttop #wb-timer .wb-tjoin { position: relative; min-height: calc(36px / var(--px)); margin-top: 2px; width: 100%; }
/* every running boost as its icon with its own draining bar under it, side by side (no shared time: it read as the time
   of all); the next ones: their icons, the one "in 1:08 Std." under them; a tap opens the calendar with every time */
html.touch #ui #ttop #ev-box { display: flex; flex-wrap: wrap; align-content: center; gap: 2px; min-height: 24px; }
html.touch #ui #ttop #ev-box .ev-head { display: none; }
html.touch #ui #ttop #ev-box:not(.live) .ev-head { display: flex; order: 1; width: 100%; }
html.touch #ui #ttop #ev-box .ev-head > span:not(.ev-t) { display: none; }
html.touch #ui #ttop #ev-box .ev-head > .ev-t { margin-left: 0; }
html.touch #ui #ttop #ev-box .ev-row { flex-direction: column; align-items: stretch; gap: 1px; margin: 0; }
html.touch #ui #ttop #ev-box .ev-r1 { display: none; }
html.touch #ui #ttop #ev-box .ev-bar { margin-top: 0; }
html.touch #ui #ttop #ev-box .on[data-type="topup"] { flex: 0 0 100%; flex-direction: row; gap: 3px; align-items: center; }
html.touch #ui #ttop #ev-box .on[data-type="topup"] .ev-r1 { display: flex; }
html.touch #ui #wb-notes { top: calc(8px + 20px * var(--tz)) !important; right: 92px; }
/* a tap on a chip opens its window; give them a finger's height */
html.touch #ui #ttop :is(#wb-timer, #ev-box)::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: max(100%, calc(40px / var(--px))); }

/* ---------- top left: buffs in one row, the quests under them ---------- */
html.touch #ui #affects { max-width: 132px; max-height: 15px; overflow: visible; flex-wrap: nowrap; }
html.touch #ui #affects > :nth-child(n+8) { display: none; }
html.touch #ui #affects[data-more]::after { content: attr(data-more); flex: none; align-self: center; margin-left: 1px; font-size: 7px; line-height: 9px; color: var(--gold); text-shadow: var(--ol); pointer-events: none; }
html.touch #ui #quest-tracker { left: 4px; right: auto; top: 70px; width: 132px; display: flex; flex-direction: column; overflow: hidden; }
html.touch #ui #quest-tracker .qt-head { flex: none; height: 14px; }
html.touch #ui #quest-tracker .qt-head::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: max(14px, calc(40px / var(--px))); }
html.touch #ui #quest-tracker .qt-body { min-height: 0; overflow-y: auto; }
html.touch #ui #quest-tracker.folded { padding-bottom: 3px; }
html.touch #ui #quest-tracker .qt-line { display: flex; align-items: center; gap: 3px; min-height: calc(30px / var(--px)); padding: 0 2px; font-size: 7px; line-height: 9px; color: var(--text); }
html.touch #ui #quest-tracker .qt-line .qt-kind { flex: none; margin: 0; }
html.touch #ui #quest-tracker .qt-line .qt-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.touch #ui #quest-tracker .qt-line .qt-val { flex: none; font-size: 6px; color: var(--gold); }
html.touch #ui #quest-tracker .qt-line.next .qt-name { color: var(--dim); }
html.touch #ui :is(#dg-hud, #rift-hud, #gm-hud, #arena-hud, #fest-hud) { left: 4px; right: auto; top: 70px; width: 132px; overflow-y: auto; }
/* the target on the left (narrow screens) stands under the player frame, the buffs under it */
html.touch #ui:not(.compact) #target { top: 4px; }

/* ---------- the chat: three faint lines right of the joystick (a tap there still reaches the world; the button opens
   it), open with tabs and its field above the button ---------- */
html.touch #ui #tchat-btn { left: calc(8px + 56px * var(--tz)); bottom: 7px; width: 20px; height: 20px; transform: scale(var(--tz)); transform-origin: 0 100%; z-index: 5; }
html.touch #ui #chat { transform: scale(var(--wz)); transform-origin: 0 100%; z-index: 7; }
html.touch #ui.tchat-mini #chat { left: calc(12px + 76px * var(--tz)); bottom: 13px; width: calc((100% - 22px - 182px * var(--tz)) / var(--wz)); max-width: 200px;
  padding: 0; background: none; box-shadow: none; pointer-events: none; }
html.touch #ui.tchat-mini #chat :is(.ctabs, .chat-row, .ch-new) { display: none; }
/* (the background layer of css/imperial.css; folded in the options: not even the faint lines, the button still opens it) */
html.touch #ui.tchat-mini #chat::before { display: none; }
html.touch #ui.tchat-mini #chat.shut { display: none; }
html.touch #ui.tchat-mini #chat .log { height: 27px; overflow: hidden; padding: 0; text-shadow: var(--ol), 0 0 3px #000;
  -webkit-mask-image: linear-gradient(transparent, #000 45%); mask-image: linear-gradient(transparent, #000 45%); }
html.touch #ui.tchat-mini #chat .log::-webkit-scrollbar { display: none; }
html.touch #ui.tchat-open #chat { left: calc(8px + 56px * var(--tz)); bottom: calc(10px + 20px * var(--tz)); width: calc(min(250px * var(--wz), 100% - 20px - 156px * var(--tz)) / var(--wz)); }
/* (while it is open the row above the joystick and the plaque of the auto-hunt step aside: it lies over them) */
html.touch #ui.tchat-open :is(#tleft, #autopill) { visibility: hidden; }
html.touch #ui.tchat-open #chat .ctabs .ctab { height: 13px; line-height: 13px; padding: 0 4px; font-size: 7px; }
html.touch #ui.tchat-open #chat .log { height: 66px; }
html.touch #ui.tchat-open #chat #chat-input { height: 15px !important; font-size: 8px !important; }
html.touch #ui.tchat-open #chat .ch-new { right: 4px; bottom: 21px; height: 18px; line-height: 18px; padding: 0 7px; font-size: 8px; }
/* typing: at the top, above the keyboard */
html.touch #ui #chat:focus-within { left: 50%; top: 4px; bottom: auto; width: min(300px, calc((100% - 8px) / var(--wz))); transform: translateX(-50%) scale(var(--wz)); transform-origin: 50% 0; z-index: 60; }

/* ---------- what shows in the middle: above the lines of the chat (the plaque of the auto-hunt left-aligned with them) ---------- */
html.touch #ui #autopill { left: calc(12px + 76px * var(--tz)); right: auto; top: auto; bottom: calc(16px + 27px * var(--wz)); transform: none; max-width: min(240px, calc(100% - 24px - 182px * var(--tz))); }
html.touch #ui #autopill .ap-zone { display: none; }
html.touch #ui:not(.compact) #autopill .ap-zone { display: inline; }
html.touch #ui #gs-toast { bottom: calc(46px + 2px * var(--tz)); }
html.touch #ui > #mo-loot { bottom: 50px; }
html.touch #ui #arena-q { bottom: 50px; scale: var(--tz); transform-origin: 50% 100%; translate: -50% 0; transform: none; }
html.touch #ui #meter .mt-reset { height: calc(44px / (var(--px) * var(--wz))); line-height: calc(44px / (var(--px) * var(--wz))); padding: 0 6px; }
html.touch #ui #meter { left: auto; right: 4px; top: auto; bottom: calc(10px + 100px * var(--tz)); max-height: calc(100% - 92px - 100px * var(--tz)); overflow-y: auto; overflow-x: hidden; }
/* the colosseum's switches (ui/wbquick.js): left of the attack button and its quickslot arcs (above them the meter had no room
   under the minimap), one row without title, drawn bigger towards the top left - their corner stays; the meter docks on them */
html.touch #ui > #wb-quick { right: calc(8px + 100px * var(--tz)); bottom: 8px; transform-origin: 100% 100%; }
html.touch #ui #wb-quick > .win-title { display: none; }
html.touch #ui #wb-quick .wq-grid { grid-template-columns: repeat(4, 1fr); }
html.touch #ui #wb-quick .wq-sw { height: calc(44px / (var(--px) * var(--wz))); font-size: 5px; }

/* ---------- the menu panel ---------- */
html.touch #ui:not(.tmenu-open) :is(#tmenu, #tmenu-back) { display: none; }
html.touch #ui #tmenu-back { position: absolute; inset: 0; z-index: 9000; background: #050403a6; }
html.touch #ui #tmenu { position: absolute; left: 50%; top: 50%; z-index: 9010; padding: 5px 3px 6px; display: flex; flex-direction: column; gap: 4px;
  transform: translate(-50%, -50%) scale(var(--wz)); transform-origin: 50% 50%; }
html.touch #ui #tmenu::after { content: ''; position: absolute; inset: -2px; border: 8px solid transparent; border-image: var(--imperial-frame) 43 / 8px / 0 stretch; pointer-events: none; z-index: 3; }
html.touch #ui #tmenu .tm-head { position: relative; display: flex; align-items: center; gap: 4px; height: 17px; padding: 0 23px 0 3px; }
html.touch #ui #tmenu .tm-x { position: absolute; right: 1px; top: -1px; width: 18px; height: 18px; background-size: 11px; z-index: 4; }
html.touch #ui #tmenu #wallet { position: static; flex: 1; width: auto; min-width: 0; height: 15px; transform: none; z-index: auto; }
html.touch #ui #tmenu #menubar, html.touch #ui #tmenu #edge { position: static; display: grid; grid-template-columns: repeat(7, 38px); gap: 2px; padding: 0 3px;
  transform: none; z-index: auto; background: none; box-shadow: none; pointer-events: auto; }
html.touch #ui #tmenu #edge { padding: 4px 3px 0; border-top: 1px solid #4c4334; }
/* a cell: icon on top, label (or the timer of a tab) under it */
html.touch #ui #tmenu :is(.mbtn-i, #travel-btn, #isle-trip, #noexp-btn, .edge-tab, #discord) { position: relative; inset: auto; width: 38px; height: 33px; margin: 0; padding: 3px 1px 0;
  display: flex; flex-direction: column; align-items: center; gap: 1px; transform: none; animation-duration: 1.2s; }
html.touch #ui #tmenu .mbtn-i::before { position: static; flex: none; display: block; width: 16px; height: 16px; }
/* (labels break only between words; :where keeps them weak, so the rules for the tabs below win) */
html.touch #ui #tmenu :where(.mb-l, .et-lbl, .et-time, #travel-btn > span, #isle-trip > span) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  width: 100%; height: auto; margin: 0; padding: 0 1px; font-size: 6px; line-height: 6px; text-align: center; color: #d8c79f; white-space: normal; overflow-wrap: normal; word-break: normal; }
/* a tab of the left edge: its countdown while it runs, its name when it is ready (the red stud says so) or has none */
html.touch #ui #tmenu .edge-tab:not(.ready) .et-time:not(:empty) ~ .et-lbl { display: none; }
html.touch #ui #tmenu .edge-tab:is(.ready, :has(> .et-time:empty)) .et-time { display: none; }
html.touch #ui #tmenu .edge-tab .et-ic { flex: none; height: 16px; }
html.touch #ui #tmenu .edge-tab .et-ic img { width: 16px; height: 16px; }
html.touch #ui #tmenu .edge-tab .et-dot { right: 4px; }
html.touch #ui #tmenu .et-bubble { display: none; }
html.touch #ui #tmenu #discord .dc-link { flex: none; height: 16px; }
html.touch #ui #tmenu #discord .dc-link i { width: 16px; height: 13px; background-size: 16px 13px; }
html.touch #ui #tmenu #isle-trip { min-width: min(100%, calc(44px / (var(--px) * var(--wz)))); min-height: calc(44px / (var(--px) * var(--wz))); }
html.touch #ui #tmenu #isle-trip > span { font-size: 6px; line-height: 6px; }
html.touch #ui #tmenu :is(#travel-btn, #isle-trip) i { flex: none; width: 16px; height: 16px; background-size: 16px 16px; }
html.touch #ui #tmenu #noexp-btn { background: linear-gradient(#39342f, #201d1a); box-shadow: inset 0 0 0 1px #84704a; }
html.touch #ui #tmenu #noexp-btn.on { background: linear-gradient(#5a2219, #2c110c); box-shadow: inset 0 0 0 1px #c0503a; }
html.touch #ui #tmenu #noexp-btn.cap { box-shadow: inset 0 0 0 1px #d8b46a; }
html.touch #ui #tmenu #noexp-btn i { flex: none; width: 16px; height: 16px; background-size: 16px 16px; opacity: .9; }
html.touch #ui #tmenu :is(#discord, .edge-tab) { background: linear-gradient(#39342f, #201d1a); box-shadow: inset 0 0 0 1px #84704a; }

/* the first-time hints (ui/hints.js) point into the open panel too */
html.touch #ui.tmenu-open :is(#hint-ring, #hint-arrow, #hint-tag) { z-index: 9020; }

/* watching a player (team panel) nothing is steered */
html.touch #ui.spectating :is(#tstick, #tpad, #tleft, #tchat-btn) { display: none; }
