/* NEW_IMPLEMENTATION: optional web guidance above the field. Original windows,
   HUD artwork, image pixels and native control coordinates remain unchanged.
   #tc-guide-status must use aria-live="off" in the DOM; CSS cannot set it. */
body > #tc-field-guide {
  position: fixed;
  top: max(4px, var(--tc-safe-top, 0px));
  left: 50%;
  width: min(560px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  margin: 0;
  padding: 0;
  transform: translateX(-50%);
  color: #d0d3b7;
  background: #080d08ed;
  font:
    12px/18px '굴림',
    Gulim,
    sans-serif;
  text-align: left;
  z-index: 44;
  pointer-events: auto;
}

#tc-field-guide,
#tc-field-guide *,
#tc-guide-target,
#tc-guide-target * {
  box-sizing: border-box;
}

#tc-field-guide .tc-guide-summary {
  display: flex;
  flex-flow: row nowrap;
  align-items: stretch;
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: inset 0 0 0 1px #5a624c;
}

#tc-field-guide button {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: 18px;
  text-align: center;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

#tc-field-guide button:hover,
#tc-field-guide button[aria-expanded='true'],
#tc-field-guide button[aria-pressed='true'] {
  color: #ead599;
  background: #b09b4c1f;
}

#tc-field-guide button:focus-visible {
  outline: 2px solid #dcc57e;
  outline-offset: -3px;
}

#tc-field-guide button:disabled {
  opacity: 0.45;
  cursor: default;
}

#tc-field-guide :is(#tc-guide-toggle, #tc-guide-fold) {
  flex: 0 0 44px;
  width: 44px;
  padding: 0 2px;
}

#tc-field-guide #tc-guide-status {
  display: block;
  flex: 1 1 0;
  align-self: center;
  min-width: 0;
  margin: 0;
  padding: 0 6px;
  overflow: hidden;
  color: #c1c5a4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tc-field-guide #tc-guide-primary {
  display: block;
  flex: 0 1 auto;
  min-width: 44px;
  max-width: 40%;
  overflow: hidden;
  border-left: 1px solid #39432f;
  color: #e3cc8e;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tc-field-guide #tc-guide-choices {
  max-height: min(240px, 45dvh);
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid #5a624c;
  border-top: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #666c4f #0a100a;
  touch-action: pan-y;
}

#tc-field-guide #tc-guide-choices[hidden],
#tc-guide-target[hidden] {
  display: none !important;
}

#tc-field-guide .tc-guide-shortcuts {
  display: flex;
  flex-flow: row nowrap;
  border-bottom: 1px solid #39432f;
}

#tc-field-guide .tc-guide-shortcuts button {
  display: block;
  flex: 1 1 0;
  min-width: 44px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#tc-field-guide .tc-guide-shortcuts button + button {
  border-left: 1px solid #39432f;
}

#tc-field-guide #tc-guide-description {
  margin: 0;
  padding: 8px;
  color: #b9c0a2;
  overflow-wrap: anywhere;
}

#tc-field-guide #tc-guide-options {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#tc-field-guide #tc-guide-options button,
#tc-field-guide :is(.tc-guide-map, .tc-guide-manual) {
  justify-content: flex-start;
  width: 100%;
  border-top: 1px solid #303a2a;
  text-align: left;
  overflow-wrap: anywhere;
}

body > #tc-field-guide[data-minimized='true'] {
  width: 44px;
  max-width: 44px;
}

#tc-field-guide[data-minimized='true'] :is(#tc-guide-status, #tc-guide-primary, #tc-guide-fold),
#tc-field-guide[data-minimized='true'] #tc-guide-choices {
  display: none !important;
}

/* Keep the P4 top-left 0..136px and rightmost 96px controls reachable. */
body.tc-playfield > #tc-field-guide {
  top: var(--tc-safe-top, 0px);
  left: calc(140px + var(--tc-safe-left, 0px));
  right: calc(100px + var(--tc-safe-right, 0px));
  width: auto;
  max-width: none;
  transform: none;
}

body.tc-playfield > #tc-field-guide[data-minimized='true'] {
  right: auto;
  width: 44px;
  max-width: 44px;
}

@media (max-width: 600px) and (orientation: portrait) {
  body.tc-playfield > #tc-field-guide {
    top: calc(44px + var(--tc-safe-top, 0px));
    left: calc(4px + var(--tc-safe-left, 0px));
    right: calc(4px + var(--tc-safe-right, 0px));
  }
}

/* A world-space marker, not an extra HUD control. JS sets screen-local left/top.
   --tc-guide-angle uses a right-facing zero: 0deg right, 90deg down. */
#screen > #tc-guide-target {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%);
  border: 2px solid #e0bd57;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 0 0 1px #181a0dc4;
  z-index: 12;
  pointer-events: none;
}

#tc-guide-target .tc-guide-target-label {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  max-width: min(220px, 70vw);
  padding: 0 3px;
  transform: translateX(-50%);
  overflow: hidden;
  color: #f0d88b;
  background: #050905bc;
  font:
    12px/18px '굴림',
    Gulim,
    sans-serif;
  text-overflow: ellipsis;
  text-shadow: 0 1px #000;
  white-space: nowrap;
  pointer-events: none;
}

#tc-guide-target .tc-guide-arrow {
  position: absolute;
  display: none;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%) rotate(var(--tc-guide-angle, 0deg));
  clip-path: polygon(0 0, 100% 50%, 0 100%, 25% 50%);
  background: #e0bd57;
  pointer-events: none;
}

#tc-guide-target[data-offscreen='true'] .tc-guide-arrow {
  display: block;
}

@media (max-height: 300px) {
  #tc-guide-target .tc-guide-target-label {
    display: none;
  }
}

/* These overlays own focus and touch space; the optional guide must yield. */
body:has(#entry-dialog[open]) > #tc-field-guide,
body:has(#loading:not([hidden])) > #tc-field-guide,
body:has(#panel:not([hidden])) > #tc-field-guide,
body:is(.mobile-keyboard, .tc-tools-open, .tc-hud-open, .mobile-chat-open) > #tc-field-guide,
body:has(#entry-dialog[open]) #tc-guide-target,
body:has(#loading:not([hidden])) #tc-guide-target,
body:has(#panel:not([hidden])) #tc-guide-target,
body:is(.mobile-keyboard, .tc-tools-open, .tc-hud-open, .mobile-chat-open) #tc-guide-target {
  display: none !important;
}
