/* ==========================================================================
   RO RE:START — Guild Window, Emblem Uploader, Live Invites & Nameplates
   Harmonizes automatically with all 4 uaRO themes via --rm-* / --ro-* tokens.
   ========================================================================== */

/* Top lobby bar Guild button emblem + invite badge */
#lobby-guild {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gld-btn-ic {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  flex: none;
  background: rgba(0, 0, 0, 0.25);
}

.gld-inv-badge {
  background: #e11d48;
  color: #ffffff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45), 0 2px 6px rgba(225, 29, 72, 0.45);
}

/* In-world Prontera player nameplate with Guild Emblem + [Name] */
#lobby-labels .lobby-name.has-guild {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 3px;
  text-align: center;
  line-height: 1.18;
}

#lobby-labels .lobby-name .gld-np-guild {
  flex-basis: 100%;
  order: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #cfe6ff;
  text-shadow:
    1px 1px 0 #000,
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    0 1px 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

#lobby-labels .lobby-name.self .gld-np-guild {
  color: #fde68a;
}

#lobby-labels .lobby-name .gld-np-emblem {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  background: rgba(12, 18, 28, 0.45);
}

#lobby-labels .lobby-name .gld-np-tag {
  opacity: 0.88;
  font-size: 9.5px;
}

/* Main Guild floating window (#guild) */
.guild-window {
  width: min(760px, 95vw);
  max-height: min(86vh, 690px);
  display: flex;
  flex-direction: column;
}

.guild-window .ro-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guild-window .ro-title small {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.85;
}

.gld-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  min-height: 300px;
  padding: 14px 16px;
  color: var(--rm-ink, var(--ro-text));
}

.gld-hero,
.gld-tabs,
.gld-card,
.gld-msg {
  flex-shrink: 0;
}

.gld-msg {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--rm-glass-border-strong, rgba(142, 197, 255, 0.5));
  background: rgba(92, 178, 255, 0.14);
  color: var(--rm-ink, var(--ro-text));
}

.gld-msg.err {
  border-color: rgba(239, 68, 68, 0.65);
  background: rgba(239, 68, 68, 0.16);
}

.gld-msg.ok {
  border-color: rgba(34, 197, 94, 0.62);
  background: rgba(34, 197, 94, 0.16);
}

/* Guild Hero Header */
.gld-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--rm-glass-sub, rgba(24, 33, 46, 0.4));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
}

.gld-emblem-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  flex: none;
  border: 1.5px solid var(--rm-glass-border-strong, rgba(142, 197, 255, 0.55));
  background: var(--rm-glass-slot, rgba(18, 26, 38, 0.65));
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.gld-emblem-wrap.sm {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.gld-emblem-wrap.xs {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.gld-emblem-wrap.clickable {
  cursor: pointer;
}

.gld-emblem-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gld-emblem-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: 0.04em;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  background: linear-gradient(145deg, #4b79cf 0%, #2a4780 100%);
}

.gld-emblem-wrap.sm .gld-emblem-fallback {
  font-size: 13px;
}

.gld-emblem-wrap.xs .gld-emblem-fallback {
  font-size: 10px;
}

.gld-emblem-edit-hint {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2px 0;
  font-size: 9px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(10, 16, 26, 0.72);
  opacity: 0;
  transition: opacity 0.14s ease;
}

.gld-emblem-wrap.clickable:hover .gld-emblem-edit-hint {
  opacity: 1;
}

.gld-hero-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gld-hero-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.gld-hero-title b {
  font-size: 17px;
  font-weight: 800;
  color: var(--rm-ink, var(--ro-text));
  overflow-wrap: anywhere;
}

.gld-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  border: 1px solid var(--rm-glass-border-strong, rgba(142, 197, 255, 0.55));
  background: rgba(92, 178, 255, 0.16);
  color: var(--rm-accent, #5cb2ff);
}

.gld-role-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.gld-role-pill.leader {
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fbbf24;
}

.gld-role-pill.officer {
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.55);
  color: #93c5fd;
}

.gld-role-pill.member {
  background: var(--rm-glass-slot, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
  color: var(--rm-muted, var(--ro-muted));
}

:root[data-theme="classic"] .gld-role-pill.leader {
  color: #8a5100;
  background: rgba(217, 119, 6, 0.16);
}

:root[data-theme="classic"] .gld-role-pill.officer {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.14);
}

:root[data-theme="classic"] .gld-tag-pill {
  color: #5d3a1a;
  background: rgba(154, 119, 80, 0.2);
}

.gld-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--rm-muted, var(--ro-muted));
}

.gld-hero-notice {
  margin-top: 2px;
  padding: 6px 9px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--rm-glass-slot, rgba(16, 23, 34, 0.45));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
  color: var(--rm-ink-soft, var(--ro-text));
}

/* Tabs row */
.gld-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gld-tabs .tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.gld-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: #e11d48;
  color: #fff;
}

/* Panels & forms */
.gld-card {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--rm-glass-sub, rgba(24, 33, 46, 0.4));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gld-card.danger {
  border-color: rgba(239, 68, 68, 0.42);
}

.gld-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--rm-accent, #5cb2ff);
}

.gld-card.danger .gld-card-title {
  color: #f87171;
}

:root[data-theme="classic"] .gld-card-title {
  color: #6b4423;
}

:root[data-theme="classic"] .gld-card.danger .gld-card-title {
  color: #b91c1c;
}

.gld-form-grid {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px;
}

.gld-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--rm-ink-soft, var(--ro-text));
}

.gld-field small {
  font-weight: 600;
  font-size: 10.5px;
  color: var(--rm-muted, var(--ro-muted));
}

.gld-input,
.gld-textarea {
  width: 100%;
  padding: 7px 10px;
  border-radius: 7px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rm-ink, var(--ro-text));
  background: var(--rm-glass-input, rgba(16, 24, 36, 0.55));
  border: 1px solid var(--rm-glass-border, var(--ro-border));
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

.gld-input:focus,
.gld-textarea:focus {
  border-color: var(--rm-glass-border-strong, #5cb2ff);
  box-shadow: 0 0 0 2px rgba(92, 178, 255, 0.22);
}

.gld-textarea {
  resize: vertical;
  min-height: 58px;
  max-height: 120px;
  line-height: 1.4;
}

/* Logo uploader */
.gld-logo-grid {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.gld-preview-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 9px;
  background: var(--rm-glass-slot, rgba(16, 23, 34, 0.5));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
}

.gld-preview-box {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid var(--rm-glass-border-strong, rgba(142, 197, 255, 0.55));
  background:
    repeating-conic-gradient(rgba(255, 255, 255, 0.08) 0% 25%, rgba(0, 0, 0, 0.14) 0% 50%)
    50% / 12px 12px;
  display: grid;
  place-items: center;
}

.gld-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gld-np-preview {
  width: 100%;
  padding: 8px 6px;
  border-radius: 7px;
  text-align: center;
  background: linear-gradient(180deg, #3c5472 0%, #587596 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.gld-np-preview-char {
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.gld-np-preview-guild {
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fde68a;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.gld-np-preview-guild img {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.gld-preview-meta {
  font-size: 10px;
  color: var(--rm-muted, var(--ro-muted));
  text-align: center;
}

.gld-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 14px 12px;
  border-radius: 9px;
  border: 1.5px dashed var(--rm-glass-border, rgba(142, 197, 255, 0.45));
  background: var(--rm-glass-slot, rgba(16, 23, 34, 0.35));
  text-align: center;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.gld-dropzone:hover,
.gld-dropzone.over {
  border-color: var(--rm-glass-border-strong, #5cb2ff);
  background: var(--rm-glass-slot-hover, rgba(92, 178, 255, 0.12));
}

.gld-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.gld-dropzone b {
  font-size: 12px;
  color: var(--rm-ink, var(--ro-text));
}

.gld-dropzone small {
  font-size: 10.5px;
  color: var(--rm-muted, var(--ro-muted));
}

.gld-logo-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--rm-ink-soft, var(--ro-text));
}

.gld-logo-opts label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.gld-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.gld-presets span {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--rm-muted, var(--ro-muted));
}

.gld-preset-btn {
  width: 30px;
  height: 30px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--rm-glass-border, var(--ro-border));
  background: var(--rm-glass-slot, rgba(0, 0, 0, 0.25));
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.1s ease, border-color 0.14s ease;
}

.gld-preset-btn:hover {
  transform: translateY(-1px);
  border-color: var(--rm-glass-border-strong, #5cb2ff);
}

.gld-preset-btn img {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  display: block;
}

/* Roster & Invite lists */
.gld-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gld-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--rm-glass-slot, rgba(16, 23, 34, 0.45));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
}

.gld-row.me {
  border-color: var(--rm-glass-border-strong, rgba(142, 197, 255, 0.55));
}

.gld-row-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
}

.gld-row-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gld-row-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
}

.gld-row-top b {
  color: var(--rm-ink, var(--ro-text));
  overflow-wrap: anywhere;
}

.gld-row-sub {
  font-size: 11px;
  color: var(--rm-muted, var(--ro-muted));
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gld-title-tag {
  font-size: 10.5px;
  font-style: italic;
  color: var(--rm-accent, #8ec5ff);
}

:root[data-theme="classic"] .gld-title-tag {
  color: #6b4423;
}

.gld-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: none;
  background: #64748b;
}

.gld-dot.on {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
}

.gld-dot.run {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.7);
}

.gld-row-acts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.gld-row-acts .ro-btn,
.gld-actions-bar .ro-btn {
  margin: 0;
  padding: 4px 10px;
  font-size: 11px;
}

.gld-btn-danger {
  border-color: rgba(239, 68, 68, 0.7) !important;
  color: #fecaca !important;
  background: linear-gradient(180deg, #b91c1c 0%, #991b1b 100%) !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45) !important;
}

.gld-btn-danger:hover:not(:disabled) {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%) !important;
}

.gld-invite-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.gld-invite-form .gld-input {
  flex: 1;
}

.gld-invite-form .ro-btn {
  margin: 0;
  white-space: nowrap;
}

.gld-title-editor {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.gld-title-editor .gld-input {
  width: 170px;
  padding: 4px 7px;
  font-size: 11px;
}

.gld-actions-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.gld-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--rm-muted, var(--ro-muted));
  border-radius: 8px;
  border: 1px dashed var(--rm-glass-line, var(--ro-line));
}

.gld-pill-note {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--rm-glass-sub, rgba(255, 255, 255, 0.08));
  border: 1px solid var(--rm-glass-line, var(--ro-line));
  color: var(--rm-muted, var(--ro-muted));
}

/* Floating real-time Guild Invite & Notice toast stack */
#guild-toast-stack {
  position: fixed;
  top: 56px;
  right: 14px;
  z-index: 42;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(330px, calc(100vw - 24px));
  pointer-events: none;
}

body.has-bulletin #guild-toast-stack {
  top: 86px;
}

.gld-toast {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--rm-glass, rgba(36, 48, 66, 0.92));
  color: var(--rm-ink, #f2f6fb);
  border: 1px solid var(--rm-glass-border-strong, rgba(142, 197, 255, 0.58));
  box-shadow: var(--rm-glass-shadow, 0 12px 28px rgba(0, 0, 0, 0.45));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: fade-in 0.18s ease-out;
}

.gld-toast-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.gld-toast-text {
  min-width: 0;
  flex: 1;
  font-size: 12px;
  line-height: 1.35;
}

.gld-toast-text b {
  display: block;
  font-size: 13px;
  color: var(--rm-ink, #ffffff);
  overflow-wrap: anywhere;
}

.gld-toast-text small {
  color: var(--rm-muted, #aebfd4);
  font-size: 11px;
}

.gld-toast-x {
  border: none;
  background: transparent;
  color: var(--rm-muted, #aebfd4);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  padding: 2px 5px;
  line-height: 1;
  border-radius: 5px;
}

.gld-toast-x:hover {
  color: var(--rm-ink, #fff);
  background: rgba(255, 255, 255, 0.12);
}

.gld-toast-acts {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.gld-toast-acts .ro-btn {
  margin: 0;
  padding: 4px 12px;
  font-size: 11.5px;
}

.gld-toast.notice {
  flex-direction: row;
  align-items: center;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
}

.gld-toast.notice.err {
  border-color: rgba(239, 68, 68, 0.72);
}

/* Keep Prontera place header clear of the 5-button top-right action bar on standard laptops */
@media (min-width: 760px) and (max-width: 1480px) {
  #lobby-place {
    left: 12px;
    transform: none;
    text-align: left;
    padding: 4px 14px;
  }
}

@media (min-width: 760px) and (max-width: 1160px) {
  #lobby-actions {
    gap: 4px;
  }

  #lobby-actions .ro-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
}

@media (max-width: 680px) {
  .gld-form-grid,
  .gld-logo-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gld-row {
    flex-direction: column;
    align-items: stretch;
  }

  .gld-row-acts {
    justify-content: flex-start;
  }

  .gld-invite-form {
    flex-direction: column;
    align-items: stretch;
  }
}
