/* YulgangWD shared UI fixes. Loaded after the main stylesheet. Desktop only where the
   mobile HUD already restyles the same buttons (html.mobile-hud-on). */

/* ---- confirm / cancel buttons ----
   These windows drew "ตกลง / ยกเลิก" only in the background art, dim grey, with transparent
   button text, so the buttons read as disabled. Draw real buttons on top. */
html:not(.mobile-hud-on) body :is(
  #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button,
  .item-enhancement-confirm, .item-enhancement-cancel,
  .personal-shop-trade-confirm, .personal-shop-trade-cancel,
  .npc-shop-trade-actions button,
  .item-drop-actions button
) {
  height: 26px; padding: 0 6px; border: 1px solid rgba(201,164,71,.75); border-radius: 2px;
  background: linear-gradient(#4a1f0e, #250c05);
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255,217,136,.22), 0 2px 4px rgba(0,0,0,.6);
  color: #f3d79a; font: 700 12px/24px Tahoma, "Leelawadee UI", sans-serif; text-shadow: 1px 1px 2px #000;
  white-space: nowrap; cursor: pointer; overflow: hidden;
}
/* the action that goes ahead: red lacquer */
html:not(.mobile-hud-on) body :is(
  #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button:is(
    [data-action^="quest-advance-"], [data-action^="quest-open-"], [data-action^="quest-promot"],
    :first-child:not([data-action^="quest-abandon-"]):not([data-action^="npc-menu-"])),
  .item-enhancement-confirm,
  .personal-shop-trade-confirm,
  .npc-shop-trade-actions button:first-child,
  .item-drop-actions button:first-child
) {
  background: linear-gradient(#b23c1c, #6a1808); border-color: #f0cf7a; color: #fff1d6;
  box-shadow: 0 0 0 1px #000, inset 0 1px 0 rgba(255,217,136,.4), 0 0 10px rgba(232,140,74,.35);
}
/* giving up a quest stays quiet */
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button[data-action^="quest-abandon-"] {
  background: linear-gradient(#2a1208, #160703); border-color: rgba(201,164,71,.4); color: #c9ae86;
}
html:not(.mobile-hud-on) body :is(
  #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button,
  .item-enhancement-confirm, .item-enhancement-cancel,
  .personal-shop-trade-confirm, .personal-shop-trade-cancel,
  .npc-shop-trade-actions button, .item-drop-actions button
):is(:hover, :focus-visible) { color: #fff6d8; filter: brightness(1.18); outline: none; }
html:not(.mobile-hud-on) body :is(
  #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button,
  .item-enhancement-confirm, .item-enhancement-cancel,
  .personal-shop-trade-confirm, .personal-shop-trade-cancel,
  .npc-shop-trade-actions button, .item-drop-actions button
):active { filter: brightness(.9); transform: translateY(1px); }
html:not(.mobile-hud-on) body :is(.item-enhancement-confirm, .personal-shop-trade-confirm, .npc-shop-trade-actions button, .item-drop-actions button):disabled {
  filter: grayscale(.8); opacity: .5; cursor: default;
}

/* quest detail: up to three buttons (go ahead / give up / back) across the bottom of the frame */
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions {
  top: 400px; left: 18px; width: 221px; gap: 5px;
}
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button { flex: 1 1 auto; width: auto; min-width: 0; padding: 0 5px; }
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button:only-child { flex: 0 0 120px; }
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button:hover::before { display: none; }
/* "กลับไปรายการภารกิจ" is too long for a third of the row */
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button[data-action^="npc-menu-"] { font-size: 0; }
html:not(.mobile-hud-on) body #npcDialogue[data-view="quest-detail"] .npc-dialogue-actions button[data-action^="npc-menu-"]::after {
  content: "ย้อนกลับ"; font-size: 12px;
}

/* item enhancement: buttons have no text, only aria-label */
html:not(.mobile-hud-on) body .item-enhancement-confirm,
html:not(.mobile-hud-on) body .item-enhancement-cancel { width: 72px; top: 410px; }
html:not(.mobile-hud-on) body .item-enhancement-confirm { left: 56px; }
html:not(.mobile-hud-on) body .item-enhancement-cancel { left: 136px; }
html body :is(.item-enhancement-confirm, .item-enhancement-cancel):empty::after { content: attr(aria-label); }

/* small trade / drop dialogs */
html:not(.mobile-hud-on) body :is(.npc-shop-trade-actions, .item-drop-actions) button { width: 70px; }
html:not(.mobile-hud-on) body :is(.personal-shop-trade-confirm, .personal-shop-trade-cancel) { width: 72px; bottom: 14px; }

/* ---- new letter: make the mailbox icon hard to miss ---- */
html body #mailReceivedIcon:not([hidden]) {
  animation: wd-mail-bounce 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255,214,110,.9));
}
@keyframes wd-mail-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  20% { transform: translateY(-8px); }
  40% { transform: translateY(-3px); }
}

:root { --wd-scroll-gold: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2040%2034'%3E%3Cdefs%3E%3ClinearGradient%20id='p'%20x2='0'%20y2='1'%3E%3Cstop%20offset='0'%20stop-color='%23fff5c8'/%3E%3Cstop%20offset='1'%20stop-color='%23f0c45a'/%3E%3C/linearGradient%3E%3ClinearGradient%20id='r'%20x2='0'%20y2='1'%3E%3Cstop%20offset='0'%20stop-color='%23c8402a'/%3E%3Cstop%20offset='1'%20stop-color='%236a1608'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect%20x='6'%20y='6'%20width='28'%20height='22'%20fill='url%28%23p%29'%20stroke='%233a1d08'%20stroke-width='1.4'/%3E%3Cpath%20d='M11%2012h18M11%2016h14M11%2020h17M11%2024h10'%20stroke='%238a3a12'%20stroke-width='1.6'%20stroke-linecap='round'/%3E%3Crect%20x='2'%20y='3'%20width='6'%20height='28'%20rx='2.5'%20fill='url%28%23r%29'%20stroke='%232a1004'%20stroke-width='1.3'/%3E%3Crect%20x='32'%20y='3'%20width='6'%20height='28'%20rx='2.5'%20fill='url%28%23r%29'%20stroke='%232a1004'%20stroke-width='1.3'/%3E%3Ccircle%20cx='5'%20cy='3'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='5'%20cy='31'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='35'%20cy='3'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='35'%20cy='31'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3C/svg%3E"); }
/* ---- quest marks over NPC names: a scroll, gold = ready to hand in, grey = in progress ---- */
html body #npcNameLayer .wd-quest-mark {
  position: absolute; left: 50%; bottom: 100%; margin-bottom: 3px; transform: translateX(-50%);
  width: 44px; height: 37px; pointer-events: none; font-size: 0; color: transparent;
  background: center / contain no-repeat; filter: drop-shadow(0 2px 3px rgba(0,0,0,.8));
}
html body #npcNameLayer .wd-quest-mark.ready {
  background-image: var(--wd-scroll-gold);
  filter: drop-shadow(0 0 6px rgba(255,205,80,.95)) drop-shadow(0 2px 3px rgba(0,0,0,.8));
  animation: wd-mark-bob 1.2s ease-in-out infinite;
}
html body #npcNameLayer .wd-quest-mark.active { background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2040%2034'%3E%3Cdefs%3E%3ClinearGradient%20id='p'%20x2='0'%20y2='1'%3E%3Cstop%20offset='0'%20stop-color='%23e8e4da'/%3E%3Cstop%20offset='1'%20stop-color='%23a9a39a'/%3E%3C/linearGradient%3E%3ClinearGradient%20id='r'%20x2='0'%20y2='1'%3E%3Cstop%20offset='0'%20stop-color='%238a8a8a'/%3E%3Cstop%20offset='1'%20stop-color='%234a4a4a'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect%20x='6'%20y='6'%20width='28'%20height='22'%20fill='url%28%23p%29'%20stroke='%233a1d08'%20stroke-width='1.4'/%3E%3Cpath%20d='M11%2012h18M11%2016h14M11%2020h17M11%2024h10'%20stroke='%235a5650'%20stroke-width='1.6'%20stroke-linecap='round'/%3E%3Crect%20x='2'%20y='3'%20width='6'%20height='28'%20rx='2.5'%20fill='url%28%23r%29'%20stroke='%232a1004'%20stroke-width='1.3'/%3E%3Crect%20x='32'%20y='3'%20width='6'%20height='28'%20rx='2.5'%20fill='url%28%23r%29'%20stroke='%232a1004'%20stroke-width='1.3'/%3E%3Ccircle%20cx='5'%20cy='3'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='5'%20cy='31'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='35'%20cy='3'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3Ccircle%20cx='35'%20cy='31'%20r='2'%20fill='%23f3cf6a'%20stroke='%232a1004'/%3E%3C/svg%3E"); opacity: .9; }
@keyframes wd-mark-bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }
/* badge on the scroll: "!" = quest to take, "?" = ready to hand in */
html body #npcNameLayer .wd-quest-mark.available {
  background-image: var(--wd-scroll-gold);
  filter: drop-shadow(0 0 6px rgba(255,205,80,.95)) drop-shadow(0 2px 3px rgba(0,0,0,.8));
  animation: wd-mark-bob 1.2s ease-in-out infinite;
}
html body #npcNameLayer .wd-quest-mark:is(.available, .ready)::after {
  position: absolute; right: -6px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font: 900 13px/1 Georgia, serif; color: #fff4cf;
  background: radial-gradient(circle at 35% 30%, #e8603c, #8a1c0c); border: 1.5px solid #2a0c04;
  box-shadow: 0 0 0 1px rgba(255,220,150,.7);
}
html body #npcNameLayer .wd-quest-mark.available::after { content: "!"; }
html body #npcNameLayer .wd-quest-mark.ready::after { content: "?"; }

/* ---- quest tracker (right side): no panel, text straight over the scene ---- */
html body #wdQuestTracker {
  position: fixed; right: 8px; top: 226px; z-index: 30; width: 240px; max-height: 50vh; display: flex; flex-direction: column;
  background: none; border: 0; pointer-events: none;
  font: 12.5px/1.35 Tahoma, "Leelawadee UI", sans-serif; color: #fff;
  text-shadow: 0 0 2px #000, 1px 1px 1px #000, -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000;
}
html body #wdQuestTracker[hidden], html.mobile-hud-on body #wdQuestTracker { display: none; }
html body #wdQuestTracker > * { pointer-events: auto; }
html body #wdQuestTracker header {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px; height: 22px; padding: 0 2px;
  color: #e8d69d; font-weight: 700; letter-spacing: 1px;
}
html body #wdQuestTracker .wd-qt-toggle {
  width: 20px; height: 18px; padding: 0; border: 1px solid rgba(232,214,157,.55); border-radius: 2px; background: rgba(0,0,0,.35);
  color: #e8d69d; font: 700 12px/14px Tahoma, sans-serif; cursor: pointer; text-shadow: none;
}
html body #wdQuestTracker.collapsed .wd-qt-list { display: none; }
html body #wdQuestTracker.collapsed .wd-qt-toggle { font-size: 0; }
html body #wdQuestTracker.collapsed .wd-qt-toggle::after { content: "+"; font-size: 12px; }
html body #wdQuestTracker .wd-qt-list { overflow-y: auto; scrollbar-width: none; }
html body #wdQuestTracker .wd-qt-row {
  display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 4px 6px 5px 18px; text-align: left; cursor: pointer;
  border: 0; border-radius: 2px; background: none; color: inherit; font: inherit; text-shadow: inherit; position: relative;
}
html body #wdQuestTracker .wd-qt-row::before {
  content: ""; position: absolute; left: 4px; top: 8px; width: 8px; height: 8px; transform: rotate(45deg);
  background: #9a9a9a; box-shadow: 0 0 0 1px #000;
}
html body #wdQuestTracker .wd-qt-row.ready::before { background: #ffd34a; box-shadow: 0 0 0 1px #000, 0 0 6px rgba(255,211,74,.9); }
html body #wdQuestTracker .wd-qt-row.available::before { background: #ff7a4a; }
html body #wdQuestTracker .wd-qt-row:hover { background: linear-gradient(90deg, rgba(0,0,0,.45), rgba(0,0,0,0)); }
html body #wdQuestTracker .wd-qt-name { color: #ffe9a8; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html body #wdQuestTracker .wd-qt-line { color: #f4f4f4; font-size: 12px; padding-left: 2px; }
html body #wdQuestTracker .wd-qt-row.ready .wd-qt-line { color: #ffd34a; font-weight: 700; }
html body #wdQuestTracker .wd-qt-row.available .wd-qt-line { color: #ffb38f; }

/* "ติดตาม" tick box on each row of the quest window */
html body #classicNativeWindow .native-quest-list button[data-quest-id] { position: relative; padding-left: 24px; }
html body #classicNativeWindow .wd-track {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; cursor: pointer;
  border: 1px solid #c9a447; border-radius: 2px; background: rgba(0,0,0,.55); box-shadow: inset 0 1px 2px #000;
}
html body #classicNativeWindow .wd-track.on {
  background: linear-gradient(#fbe7a6, #e0b65a 55%, #a87a2c); border-color: #f0cf7a;
}
html body #classicNativeWindow .wd-track.on::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid #2a1604; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
html body #classicNativeWindow .wd-track:hover { filter: brightness(1.2); }
html body #classicNativeWindow .wd-track-all {
  position: relative; display: flex; align-items: center; gap: 6px; height: 22px; padding-left: 24px; margin: 0 0 3px;
  cursor: pointer; color: #f4dfa8; font: 700 12px Tahoma, sans-serif; user-select: none;
}
html body #classicNativeWindow .wd-track-all b { font-weight: 700; }
html body #classicNativeWindow .wd-track-all:hover { color: #fff1c4; }

/* reward of the selected quest, bottom of the quest detail */
html body #classicNativeWindow .wd-quest-reward {
  margin: 8px 0 2px; padding: 6px 8px; border: 1px solid rgba(201,164,71,.55); border-radius: 2px;
  background: rgba(0,0,0,.35); color: #f4e7c4; font: 12px/1.55 Tahoma, sans-serif;
}
html body #classicNativeWindow .wd-quest-reward b { display: block; color: #ffd34a; font-weight: 700; margin-bottom: 2px; }

/* GM buttons: off the right side (the quest tracker lives under the minimap), down the left edge */
html:not(.mobile-hud-on) body #gmMenuToggle { left: 10px !important; right: auto !important; top: 62px !important; bottom: auto !important; }
html:not(.mobile-hud-on) body #gmToggleBtn { left: 66px !important; right: auto !important; top: 72px !important; bottom: auto !important; }

/* bot status box: left side, under the party list (bot-wd.js keeps --wd-bot-hud-top in step) */
html:not(.mobile-hud-on) body #botSessionHud { left: 8px !important; right: auto !important; top: var(--wd-bot-hud-top, 112px) !important; }
